# Configuring Texmaker USB With MiKTeX Portable

Note: this article was last updated on February 24, 2014, for users of Windows 7 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 $\LaTeX$ for current versions of both MiKTeX and Texmaker. There are very few step-by-step tutorials out there for building your own portable $\LaTeX$ 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 $\LaTeX$ 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 $\LaTeX$.

```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.)

```LaTeX: "../MiKTeX/miktex/bin/latex.exe" -interaction=nonstopmode %.tex
PdfLaTeX: "../MiKTeX/miktex/bin/pdflatex.exe" -interaction=nonstopmode %.tex
XeLaTeX: "../MiKTeX/miktex/bin/xelatex.exe" -interaction=nonstopmode %.tex
LuaLaTeX: "../MiKTeX/miktex/bin/lualatex.exe" -interaction=nonstopmode %.tex
Latexmk: "../MiKTeX/miktex/bin/latexmk.exe" -e "\$pdflatex=q/pdflatex -interaction=nonstopmode/" -pdf %.tex
Bib(la)tex: "../MiKTeX/miktex/bin/bibtex.exe" %
Makeindex: "../MiKTeX/miktex/bin/makeindex.exe" %.idx
dvips: "../MiKTeX/miktex/bin/dvips.exe" -o %.ps %.dvi
Dvipdfm: "../MiKTeX/miktex/bin/dvipdfm.exe" %.dvi
ps2pdf: "../MiKTeX/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/miktex/bin/yap.exe" -1 -s @%.tex %.dvi
PS Viewer: "C:/Program Files/Ghostgum/gsview/gsview32.exe" %.ps
Pdf Viewer: Set this to use the Built-in Viewer (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.

GSview 4.9 and Ghostscript 8.60 Portable
“Forward/Inverse search” with Texmaker

## 60 thoughts on “Configuring Texmaker USB With MiKTeX Portable”

1. Alan says:

Were you able to make to get inverse dvi search from Yap back to TeXMaker to work?

2. Alan says:

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.

1. 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

2. Goofy says:

Can you please be a little bit more specific about which commands to change, thanks.

3. wt8008 says:

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.

1. Thanks for the suggestions. I'll definitely take a look into them and see what I can figure out.
My recent post 236 – Crux

4. Peter says:

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…?

1. You should have downloaded the executable file. The file structure in the other archives is different.
My recent post 240 – Pure

2. Peter says:

Problem solved. Careful reading really for the better! ;-)

5. Isaias says:

How to compile Metapost whit Texmaker?. Thanks

6. Oscar says:

7. JMJáureguiG says:

Great post ! ! ! =)
It was just what I needed =D

8. Venkat says:

Great post ,,, Now I can finally carry the full installation on a portable drive .. Cheers

9. benigurion says:

It helped a lot, Thanks!!!!!!

10. katie says:

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! :)

1. 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!

11. Pete says:

This is a fantastic post! I needed this write my masters dissertation so many thanks!

12. Anon says:

Thank you VERY much for this tut !

1. Goofy says:

Please share the light, its dark here. Says could not start the command.

1. Goofy says:

13. Ramona says:

NICE – very well done – and most importantly: thank you sooooooooo much

1. Goofy says:

Please, what are we supposed to change to make it run, keeps on saying could not start the command. Help please

14. Goofy says:

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

1. 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.

15. Goofy says:

Help, mine isn't working. I dont get what is wrong or what to change in the arguments.

16. Raphael says:

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

1. 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.

1. M says:

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.

17. Sarah says:

I meant USB not hard drive.

18. meee says:

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!

19. Tim says:

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?

20. kianaa says:

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

1. 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.

2. Dino says:

I’m having the same problem and i also couldn’t fix it by myself :-(
Still trying to make it work somehow…

21. Joachim Wirth says:

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).

1. Interesting idea! That must be a bit of a new bug. I’ve never had trouble with Texmaker losing my configuration settings.

2. 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.

3. Bob says:

I would like to know where is located the file texmaker.ini because I’m not able to find it on my mac. Thanks

22. imtheone says:

I should manage to deal with these scripts. Not confusing from the first look.

23. 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.

24. Saleh says:

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)

25. 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?

26. 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.

27. usha says:

Thank you so much

28. 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?

29. gildo says:

Vale fera, funcionou aqui!