First a remark:
I do not use MikTeX portable myself, and honestly I don’t understand it entirely. So let me give some hints from what I’ve found. Maybe some other can give additional information.
MiKTeX apparently does not take use of the kpse mechanism. The recommended method in MikTeX for adding a local TeXMF tree is to use the MiKTeX Options dialogue:
- Start MiKTeX portable by execution of the included
miktex-portable.cmd.
- Do a right mouse click on the traybar icon, that appeared and choose “MiKTeX Options”.
- Choose there the tab “Roots” and add your local TEXMF tree. It will be saved as relative path in the
<miktex-portable>\miktex\config\miktexstartup.ini. Your local TEXMF tree must not be a subfolder of <miktex-portable>.
What I wanted to do now doesn’t seem to work, I consider it a bug in MiKTeX 2.9: After activation of “Show MiKTeX-maintained root directories” one should be able to change the order of the folders, but I couldn’t manage this.
- After clicking on “OK” all will be saved in ini as written above.
According to <miktex-portable>\doc\miktex\miktex.pdf, section 4.6, (or see <miktex-portable>\doc\miktex\localadditions.html, as web link : http://docs.miktex.org/manual/localadditions.html) there are 2 other ways:
- Use the command-line option
--include-directory=dir, e.g. latex --include-directory=C:\path\to\my\style\files thesis.tex. I don’t know, whether this works with a full local TEXMF tree, but I fear it does not.
- Set environment variables, which are useful in scripts alias batch files. The given example is
set TEXINPUTS=C:\path\to\my\style\files
latex thesis.tex
Instead of absolute paths I would favour relative ones together with the use of command line parameters, e.g. if you save a batch script latex.cmd directly in lets say X:\miktex-portable and have your local TEXMF tree in X:\localtexmf
@echo off
setlocal
set LOCALDRIVE=%~d0
set LOCALPATH=%~dp0
:: %~d0 enhances to X: here, %~dp0 to X:\miktex-portable\
set PATH=%LOCALPATH%miktex\bin;%PATH%
set TEXINPUTS=%LOCALDRIVE%\localtexmf
:: I fear, this does not work in the wanted manner
:: There are some other possible environment variables
latex %*
:: %* pipes all command line options, given to to batch file, to the call of latex.exe
Then you could do latex.cmd <command line options> file_to_compile.tex.
On the other hand you could consider the use of the portable texlive version.