If you write academic papers, especially with formal stuff in them, LaTeX is a great tool. On the other hand, it is often not simple to get it to do stuff you want it to do.
Here is a recent problem I was struggling with. I use several different computers to do work on. On the other hand, I am sufficiently wedded to the MiKTeX + TeXstudio combo that I did not want to move to the cloud by way of Overleaf. Instead, I wanted everything to work with my OneDrive folders, which would automatically sync to any computer I use.
So here is how I made it work. (Indeed, you may use this tutorial to create a self-contained LaTeX deployment from anywhere.)
Step 1 (MiKTeX)
First, you will need portable versions of MiKTeX and TeXstudio. The way this will be implemented, it is more perhaps more precise to say you will need TeXstudio and MiKTeX. (This is normally the incorrect order to go about it.)
Grab the portable version of TeXstudio from the official website. There is no installer for this, it is just a ZIP file. Extract the contents into a folder in your portable location. For me this location is further down the tree, something like this:
C:\Users\<username>\OneDrive - <university name>\LaTeX_PORTABLE\TEXSTUDIO
This immediately shows the general problem: neither
<username> may be shared across devices.
Step 2 (TeXstudio)
Second, grab the portable edition of MiKTeX from their official website. This is a bit confusing, for the portable edition is the same
*.exe as the normal version, but you will have to rename it to
It does not matter where you put this file, though it is probably useful to keep it in the portable location.
What does matter is where you ‘install’ MiKTeX. The important part is to create an empty MiKTeX folder inside the TeXstudio folder (it has to be empty, otherwise the installer will complain). The tree looks like this for me:
C:\Users\<username>\OneDrive - <university name>\LaTeX_PORTABLE\TEXSTUDIO\MikTeX
Try to remember the following path, which includes all the executables:
If the installer failed to coerce you, run
miktex-update from this folder and do the usual update process.
Step 3 (Getting them to play nice)
The final step is to get TeXstudio to run the relevant executables when called to do so. I tried doing this with explicit relative paths, but unfortunately, it wouldn’t play nice. Then I found this answer on StackExchange.
Essentially, the trick is to use the command
[txs-app-dir], which evaluates to the root directory of TeXstudio. “Incidentally”, we put MiKTeX inside the TeXstudio root, so we can start specifying from then on.
In more concrete terms, open the
Configure menu of TeXstudio and go to
Commands. Then, take every executable that stands alone and change it as follows:
latex.exe -src -interaction=nonstopmode %.tex
"[txs-app-dir]/MikTEX/texmfs/install/miktex/bin/x64/latex.exe" -src -interaction=nonstopmode %.tex
That’s it. You should now be able to run TeXstudio with MiKTeX from a portable location without any issues.
Step 4 (Extras)
Clearly, the above makes most sense if you have your
*.tex files themselves in the same portable location. On the other hand, it is arbitrary where you put them, since the build specifications are not relative to the
*.tex file location.
Finally, you can create additional TEXMF root directories wherever you want as described here, which can then be added from the MiKTeX console
miktex-console, run from the usual directory (
[Cover picture parts: clouds created with Adobe AI, logos are that of MiKTeX and TeXstudio, respectively]