Note: this article was last updated on December 30, 2019, for users of Windows 10 only. Your mileage may vary with other versions of Windows.
I’ve had a number of requests to update my tutorial for installing a portable version of for current versions of both MiKTeX and Texmaker. There are very few step-by-step tutorials out there for building your own portable workshop, so I thought it might prove advantageous to document my build to save others the headache of troubleshooting the process.
The advantages of a portable installation is that it is relatively lightweight because it installs only the packages you need to get up and running. If one of your files calls a package that isn’t installed yet, Texmaker will install it for you on the fly. All you need is an empty USB thumbdrive and a little bit of time. Fortunately, since my last update, Texmaker no longer requires Ghostscript or GSView to render PDF files, which makes this process a whole lot simpler and cleaner.
First of all, you need an empty USB thumbdrive. I recommend at least 2GB to give you room to install additional packages as needed. Then, download the following bundles:
- MiKTeX Portable – MiKTeX downloads as a self-extracting executable, so once you’ve saved it locally, run the .exe and choose your thumbdrive as the destination. Make sure to specify a new directory for the files, for example: D:/MiKTeX
- Texmaker USB – extract directly onto the root of your thumbdrive
When you’re done, you should have two subdirectories on your USB drive, one each for MiKTeX Portable and Texmaker USB. It might also be helpful to create a shortcut in your thumbdrive’s root directory to both MiKTeX and Texmaker to save yourself the hassle of needing to dig into each of those directories each time you use .
USB Drive |_____MiKTeX |_____texmakerwin32usb |_____miktex-portable.cmd - Shortcut |_____Texmaker.exe - Shortcut
Start MiKTeX and right-click on the icon that appears in your tray. Click ‘Update MiKTeX’. In most cases, it’s ok to just use the default option of updating from the nearest location. Updating may take a while, so this might be a good time to grab a cup of coffee.
Since Asymptote decided to stop playing nice sometime around version 2.16, I recommend using PGF and TikZ for creating nice-looking 2D graphics. You can download the latest version from its Sourceforge repository:
Extract the Tikz files directly into your MiKTeX directory. A window will pop up with a warning. Click the checkbox for “Do this for all current items (2 found)” then click ‘Yes’. This will install the Tikz files in the appropriate directories of your MiKTeX structure.
Right-click the MiKTeX icon in your system tray again, but this time select ‘MiKTeX Package Manager.’ We need to install two packages so Tikz can run properly — pgf and xcolor. Use the ‘Name:’ field to filter down to pgf, select it, and install. Do the same for xcolor.
Since Texmaker now has a built-in viewer, installing a PDF reader like FoxitReader is no longer necessary. If you would still prefer an external viewer, I recommend grabbing a copy of the FoxIt reader from PortableApps.com. You can install it in its own directory on your thumbdrive, then update the path to it in Texmaker’s configuration options (described below).
You can also install the R Project statistical package. (I may detail how to do this in a later article). If you do so, your file structure will look like this:
USB Drive |_____MiKTeX |_____R |_____texmakerwin32usb |_____miktex-portable.cmd - Shortcut |_____Texmaker.exe - Shortcut
Now we need to configure Texmaker so it knows where to find our custom installation. Launch Texmaker, then click on Options -> Configure Texmaker. The Commands screen should pop up by default. We’re going to modify most of these fields so that Texmaker can process your .tex files while still being able to run from a USB stick on any Windows computer. (Since my build uses neither Asymptote nor Ghostscript/GSView, I have left those paths set to their defaults.) Note that I’m using the 64-bit version of MikTex.
LaTeX: “../miktex/texmfs/install/miktex/bin/x64/latex.exe” -interaction=nonstopmode %.tex PdfLaTeX: “../miktex/texmfs/install/miktex/bin/x64/pdflatex.exe” -interaction=nonstopmode %.tex XeLaTeX: “../miktex/texmfs/install/miktex/bin/x64/xelatex.exe” -interaction=nonstopmode %.tex LuaLaTeX: “../miktex/texmfs/install/miktex/bin/x64/lualatex.exe” -interaction=nonstopmode %.tex Latexmk: “../miktex/texmfs/install/miktex/bin/x64/latexmk.exe” -e “$pdflatex=q/pdflatex -interaction=nonstopmode/” -pdf %.tex Bib(la)tex: “../miktex/texmfs/install/miktex/bin/x64/biber.exe” % Makeindex: “../miktex/texmfs/install/miktex/bin/x64/makeindex.exe” %.idx dvips: “../miktex/texmfs/install/miktex/bin/x64/dvips.exe” -o %.ps %.dvi Dvipdfm: “../miktex/texmfs/install/miktex/bin/x64/dvipdfm.exe” %.dvi ps2pdf: “../miktex/texmfs/install/miktex/bin/x64/ps2pdf.exe” %.ps metapost: “../miktex/bin/x64/mpost.exe” –interaction nonstopmode Asymptote: “C:/Program Files/Asymptote/asy.exe” %.asy ghostscript: “C:/Program Files/gs/gs9.07/bin/gswin32c.exe” R Sweave: “../R/bin/R.exe” CMD Sweave %.Rnw Dvi Viewer: “../miktex/texmfs/install/miktex/bin/x64/yap.exe” -1 -s @%.tex %.dvi PS Viewer: “C:/Program Files/Ghostgum/gsview/gsview32.exe” %.ps (optional: Click the Embed checkbox)
Set your QuickBuild to run PdfLaTeX + View PDF. Once you make these changes, your portable LaTeX setup should be all configured and ready to work on any USB stick.
Inverse Search
With the addition of Texmaker’s built-in viewer, configuring Inverse Search is no longer necessary. If you still need to do this for any external viewer you might be using, refer to the link in the resource section below.
Additional resources:
GSview 4.9 and Ghostscript 8.60 Portable
“Forward/Inverse search” with Texmaker
Were you able to make to get inverse dvi search from Yap back to TeXMaker to work?
Alan, I've updated this post with the information you asked about. Hope it helps.
My recent post 235 – Viral Anarchy
Jim, thanks for going to the trouble of making such a detailed explanation. It helped a lot!! I think your web page editor may have automatically converted the upright quotation symbol that is needed in the command line arguments into slanted quotation symbols. Also, the double dash was converted into the long dash. So, copying and pasting doesn't work. I was not able to get the inverse search with Texmaker to work with either my regular hard drive install or with the USB install. I'm pretty sure I followed the instructions. Apparently other people have had that problem too. However, inverse search did work when I modified your instructions for TexmakerX. I spent a few hours experimenting with various configurations. It didn't even occur to me that Yap needed to be run in administrator mode. I discovered through trial and error, that occasionally,Yap can be given a relative path name and then inverse searching will work for a while, until something changes. I think the problem has to do with telling Yap how to set its current directory, but I didn't find an option for that. Also, I hadn't previous installed ghostscript, Ghostview, or a PDF viewer on my USB LaTeX distribution. Using 7-zip to extract the files from the executable files was a good idea! Since both forward and inverse search are really important to me when I'm editing LaTeX files, I also tried out your suggestions with the Sumatra PDF viewer. The forward and inverse searching from Texmaker and TexmakerX to Sumatra seems to work, except I was getting multiple instances of both the text editor and viewer. I'm getting closer to having a full fledged completely functional LaTeX environment on a USB memory stick with functional forward/inverse search for both dvi and pdf files. I have to say your post about USB LaTeX inspired me to do a lot of experimenting this weekend.
Thanks for the heads-up on the formatting issue, Alan. I didn't even think about that. I converted those commands to preformatted text to preserve the format.
As for the inverse search, it took me quite a bit of experimenting to figure out as much as I did, and even then it wasn't as smooth as I'd like to see. I had the same problem with the multiple instances that you mentioned and have, as yet, to find a way to correct that. If you come up with something, please let me know.
Setting this portable version of LaTeX up has been something of a first for me, so I'm not surprised there's still a few kinks to work out. I'll update this post as I come up with anything new.
My recent post 235 – Viral Anarchy
Can you please be a little bit more specific about which commands to change, thanks.
I've noticed that ps2pdf does not work because ps2pdf in ghostscript uses bat files for processing, most likely due to PATH not being what it should. I suggest using a bat file to start texmaker which temporarily changes PATH to include miktex-portable/miktex/bin, and restore on exit, such that the ps2pdf utilities do not run into issues. This also simplifies the texmaker path settings. The path variable change will only effect the command line instance that it is changed in, and not system wide.
The other suggestion I have is to use sumatrapdf with the -reuse-instance command line option, to reuse the same window for the pdf, instead of opening a new one. I haven't tried doing forward and inverse search with sumatrapdf.
Thanks for the suggestions. I'll definitely take a look into them and see what I can figure out.
My recent post 236 – Crux
Hi, when I download and unpack the ghostscript 8.64 .tar-archive there's no directory "gs864w32" and therefore no "gs8.64" and stuff either. Anyone knows what's up with this…?
You should have downloaded the executable file. The file structure in the other archives is different.
My recent post 240 – Pure
Problem solved. Careful reading really for the better! ;-)
How to compile Metapost whit Texmaker?. Thanks
Thanks man! This page was EXTREMELY HELPFUL!! :)
Great! Glad you found it useful!
Great post ! ! ! =)
It was just what I needed =D
Great post ,,, Now I can finally carry the full installation on a portable drive .. Cheers
It helped a lot, Thanks!!!!!!
Thanks for doing this, it's really helped.
I'd been trying to sort it out myself for hours, found this and it's all working now! :)
Glad it helped! This is far and away the most popular post on my site, so I'm happy that it continues to be useful!
This is a fantastic post! I needed this write my masters dissertation so many thanks!
Great! Glad it helped!
Thank you VERY much for this tut !
Please share the light, its dark here. Says could not start the command.
Please
NICE – very well done – and most importantly: thank you sooooooooo much
Please, what are we supposed to change to make it run, keeps on saying could not start the command. Help please
Does it come with all the packages? If not how can i add them because there is a big problem adding packages with the latest addition of miktex
I don't think it does. I haven't played with this setup in a while, so I don't know what new challenges there may be with recent iterations of miktex. I may have to play with it again at some point and see what's what.
Help, mine isn't working. I dont get what is wrong or what to change in the arguments.
Hi, I’m getting an error when using ps2pdf. It’s returning an error message saying that “mgs.exe” is not regonizable as an internal or external command. Could you help me please?
Thaks a lot
Hi, Raphael, I can’t replicate the problem, so I’m not really sure how to advise you. My best guess at this point is that you may need to change your paths to absolute paths so that your LaTeX editor can find everything. Relative paths can sometimes be a little dicey. Try making that change and see if it makes a difference.
Hi,,
I added the absolute path of the miktex/bin folder to the Add to PATH field in the texmaker config. I.e. “F:/MiKTeX/miktex/bin/”. Linking all the variables to absolute path, didn’t solved the problem for me.
An easier way is to download USBTex at http://146.163.152.131/teaching/USBTeX.zip and just unzip it to a folder on your hard drive. It has had MikTex, TexMaker, and a .pdf viewer. Enjoy!
I meant USB not hard drive.
Hey there,
not sure if it’s still appropriate to reply to such an old posting, but I followed through your tutorial, and Texmaker also seems to run all right, but whenever I press the PDFLaTeX button, I get the message, that the Logfile can’t be found.
Any idea what could be the matter?
thx!
Hey, I am having problems getting this to work with the new versions of MikTeX and TeXMaker. Having followed these instructions I click quick build and TeXMaker grays the button, waits a bit and then un-grays the button, but doesn’t seem to do anything to the pdf. Any ideas?
Hi , i follow the instructions after configuring text maker with recommended settings you say but after quick build the file in text maker i see error “could not start the command”would you please help me
I don’t use LaTeX on a regular basis, so this tutorial hasn’t been updated in over a year. I’m aware that a recent build of TexMaker no longer works with the instructions above but I haven’t taken the time yet to figure out why or to update the tutorial with a fix. I may try to find some time in the next couple of weeks to sort that out and see if I can get things working again.
I’m having the same problem and i also couldn’t fix it by myself :-(
Still trying to make it work somehow…
Thanks a lot from Tuebingen, South-Germany!
Your instructions are still very useful!
One thing, I would propose (after I noticed, that configuration-changes can easily be lost): make the path-adjustments directly in the texmaker.ini-file!
Here some examples to show the syntax in the texmaker.ini-file:
ToolsLatex="../MiKTeX/miktex/bin/latex.exe" -interaction=nonstopmode %.tex
ToolsDvi="../MiKTeX/miktex/bin/yap.exe" -1 -s @%.tex %.dvi
ToolsDvips="../MiKTeX/miktex/bin/dvips.exe" -o %.ps %.dvi
ToolsPs="../PortableApps/GSView/GSviewPortable.exe" %.ps" %.ps
ToolsPs2pdf="../MiKTeX/miktex/bin/ps2pdf.exe" %.ps
ToolsMakeindex="../MiKTeX/miktex/bin/makeindex.exe" %.idx
ToolsBibtex="../MiKTeX/miktex/bin/bibtex.exe" %"
ToolsPdflatex="../MiKTeX/miktex/bin/pdflatex.exe" -interaction=nonstopmode -synctex=1 %.tex
ToolsXelatex="xelatex -synctex=1 -interaction=nonstopmode %.tex"
ToolsLualatex="lualatex -interaction=nonstopmode %.tex"
After I modified the ini-file I made a copy and I enabled write-protection to the file.
Version: Texmaker 4.1, (compiled with Qt 5.1.0 and Poppler 0.22.5).
Interesting idea! That must be a bit of a new bug. I’ve never had trouble with Texmaker losing my configuration settings.
Hey, Joachim, I looked into your suggestion to make the configuration changes directly in the texmaker.ini file and found that Texmaker writes those changes right to that file anyway. I’m not sure why you were having problems losing the configuration, but it’s not something I could replicate. If you want to give me a few more details, I’ll look into it further for you.
I would like to know where is located the file texmaker.ini because I’m not able to find it on my mac. Thanks
I should manage to deal with these scripts. Not confusing from the first look.
For everyone who still has issues with combining Texmaker with MiKTeX: I made some kind of a “bundle” for LaTeX to work with. It’s a portable package which includes the newest versions of Texmaker, MiKTeX and SumatraPDF. It’s called TexPortable and you can have a look at it here:
http://www.symera.de/index.php?id=texportable
Hope this is useful to some of you.
Nice Version! Thanks symera!
New link btw: https://symera.de/texportable
To overcome the Asymptote issue after version 2.16, people may be interested in testing the portable Asymptote (in BETA!) available at:
http://portableapps.com/node/38392
(well.. it is not configured properly as it tries to get help files from a wrong folder)
Very nice tutorial, thanks for update it, just one doubt: Why to download apart pgf/tikz and add it? Isn’t enough with add the package and update it directly from MikTeX? Should I do something similar for get the most recent version of the Tufte-latex class for avoid the problem to can’t compile it using biblatex?
Where is the tutorial for add R to this portable installation, do you know how to update biber, the version is 0.99d!!! When the current version is 1.9 and doesn’t appears available to update in the MikTeX settings.
Thank you so much
I would like to use a WYSIWAYG text editor, specifically, Scientific Word (SWP) and convert the output to portable latex files,. Have you heard about any problems with that?
Vale fera, funcionou aqui!
Thank you very much. Very helpful…..
Thanks it helps a lot !!! Greets from Yucatan, Mexico
I found this page today and I think it is very useful. In my case the path you provided for Texmaker options were wrong. These were working instead. The problem could be related to the folder where MiKTeX is installed. I leave my paths here with the hope that they will be useful to other people.
Thank you for the guide anyway!
LaTeX: “../MiKTeX/texmfs/install/miktex/bin/latex.exe” -interaction=nonstopmode %.tex
PdfLaTeX: “../MiKTeX/texmfs/install/miktex/bin/pdflatex.exe” -interaction=nonstopmode %.tex
XeLaTeX: “../MiKTeX/texmfs/install/miktex/bin/xelatex.exe” -interaction=nonstopmode %.tex
LuaLaTeX: “../MiKTeX/texmfs/install/miktex/bin/lualatex.exe” -interaction=nonstopmode %.tex
Latexmk: “../MiKTeX/texmfs/install/miktex/bin/latexmk.exe” -e “$pdflatex=q/pdflatex -interaction=nonstopmode/” -pdf %.tex
Bib(la)tex: “../MiKTeX/texmfs/install/miktex/bin/biber.exe” %
Makeindex: “../MiKTeX/texmfs/install/miktex/bin/makeindex.exe” %.idx
dvips: “../MiKTeX/texmfs/install/miktex/bin/dvips.exe” -o %.ps %.dvi
Dvipdfm: “../MiKTeX/texmfs/install/miktex/bin/dvipdfm.exe” %.dvi
ps2pdf: “../MiKTeX/texmfs/install/miktex/bin/ps2pdf.exe” %.ps
metapost: “../MiKTeX/bin/mpost.exe” –interaction nonstopmode
Asymptote: “C:/Program Files/Asymptote/asy.exe” %.asy
ghostscript: “C:/Program Files/gs/gs9.07/bin/gswin32c.exe”
R Sweave: “../R/bin/R.exe” CMD Sweave %.Rnw
Dvi Viewer: “../MiKTeX/texmfs/install/miktex/bin/yap.exe” -1 -s @%.tex %.dvi
PS Viewer: “C:/Program Files/Ghostgum/gsview/gsview32.exe” %.ps
Thanks for the feedback, Guilio. As you can see, this article hasn’t been updated in quite some time, so I’m sure certain configurations are different now. I appreciate the update and hope it’s helpful to others.
The paths in your post and the paths posted from Giulio seem not be up to date anymore.
At least I tried both and can´t solve the issue that this command could not be started:
“../MiKTeX/texmfs/install/miktex/bin/pdflatex.exe” -interaction=nonstopmode %.tex
Spending the time on this is really disappointing and due to a lack of time I will switch to overleaf now.