Note: this article is for Windows platforms only.
After a lot of trial-and-error—not to mention a wee bit of teeth gnashing, hair pulling, and weeping uncontrollably—I have finally managed to get Texmaker USB configured work with MiKTeX Portable. Since there seems to be a relative dearth of information on this particular setup on the Web, I thought I’d detail the setup for anyone else trying to get these two programs to communicate. It’s a bit of work to set up, but the bonus is that it doesn’t require any batch files to run and each module can be updated independently.
First of all, you need to create an empty folder somewhere. I called mine LaTeX Portable. Then, download the following programs:
- MiKTeX Portable – extract into the new folder you just made
- Texmaker USB – extract into LaTeX Portable/miktex-portable/ (you’ll need to create a new directory for MiKTeX Portable)
- Foxit Reader Portable – extract into LaTeX Portable
When you’re done, you should have three subdirectories in your LaTeX Portable folder, one each for MiKTeX Portable, Texmaker USB, and Foxit Reader Portable.
LaTeX Portable
|_____FoxitReaderPortable
|_____miktex-portable
|_____texmakerwin32usb
Then, go to http://pages.cs.wisc.edu/~ghost/ and download the latest versions of Ghostscript and GSView (8.64 and 4.9, respectively, at the time of this writing). Both of these files are self-extracting executable archives. Save them to your computer. Rather than running the .exe files, use a program like 7-zip to extract their contents to your LaTeX Portable directory. Again, you’ll need to create a new directory for each of these archives to extract the files into. When you’re done, your folder structure should look something like this:
LaTeX Portable
|_____FoxitReaderPortable
|_____ghostscript
|_____GSView
|_____miktex-portable
|_____texmakerwin32usb
Inside your ghostscript directory, you’ll see:
ghostscript
|_____gs864w32
|_____gs8.64
|_____filelist.txt
|_____setupgs.exe
|_____uninstgs.exe
Copy the gs8.64 directory into your GSView directory, then delete the ghostscript directory. Your LaTeX Portable folder structure should now look like:
LaTeX Portable
|_____FoxitReaderPortable
|_____GSView
|_____gs8.64
|_____gsview
|_____pstotext
|_____miktex-portable
|_____texmakerwin32usb
The next step is to configure Texmaker to access the MiKTeX Portable and Ghostscript/GSView files. 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.
<strong>LaTeX:</strong> "../miktex-portable/miktex/bin/latex.exe" --src -interaction=nonstopmode %.tex %0 "%N%T" <strong>dvips:</strong> "../miktex-portable/miktex/bin/dvips.exe" -o %.ps %.dvi <strong>Bibtex:</strong> "../miktex-portable/miktex/bin/bibtex.exe" % <strong>Makeindex:</strong> "../miktex-portable/miktex/bin/makeindex.exe" <span>.idx <strong>Dvi Viewer:</strong> "../miktex-portable/miktex/bin/yap.exe" -1 -s @</span>.tex %.dvi <strong>PS Viewer:</strong> "../GSView/GSviewPortable.exe" %.ps <strong>PdfLaTeX:</strong> "../miktex-portable/miktex/bin/pdflatex.exe" -interaction=nonstopmode %.tex <strong>Dvipdfm:</strong> "../miktex-portable/miktex/bin/dvipdfm.exe" %.dvi <strong>ps2pdf:</strong> "../miktex-portable/miktex/bin/ps2pdf.exe" %.ps <strong>Pdf Viewer:</strong> "../FoxitReaderPortable/FoxitReaderPortable.exe" %.pdf <strong>metapost:</strong> "../miktex-portable/miktex/bin/mpost.exe" --interaction nonstopmode <strong>ghostscript:</strong> "../GSView/gs8.64/bin/gswin32c.exe"
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
To set up Yap to run inverse search, it’s important to run it as an administrator (Right-click -> ‘Run as Administrator’) so that it will be able to permanently save your setting. Go to View -> Options -> Inverse DVI Search. Click ‘New’. Type
Texmakerin Name and
"%f" -line %lwhere it says to specify the program arguments. YAP doesn’t support relative paths, so you’ll have to point YAP at the absolute path to Texmaker. Once you’ve completed all three of these steps, click ‘Ok’ and Texmaker will be displayed in the list. Select Texmaker, click Apply, and Ok. You should now be able to conduct both Forward and Inverse search.
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.