I've read this question about doing what I'm asking, however for it to work, one needs to have texlive preinstalled (or texlive-base).

I was searching for a way to be totally (or nearly) independant from a system, in order to share a TeX project more easily.

The workflow I was hoping for is something like :

  1. Create an environment
  2. Install tlmgr (I'm on Ubuntu) or other (like MikTeX) in the environment
  3. Clone existing project or else
  4. Locally install packages from the required.txt
  5. Compile project with all it's dependencies installed locally
  6. Profit because your system is unencumbered by a big installation of texlive

In this mindset, when one is done with a project, he can safely store dependencies in the required.txt file, easily remove the texlive installation from the environment without having to go through these steps.

In other words, a more isolated way to have a latex installation without occupying all your system. Inspired by python virtualenv.

  • No pythons were harmed by this comment 1) Python generally has nothing to do with TeX it is just a small part so you can TeX happily without any of it I generally run either TeX Live or W32TeX or MiKTeX without any of those additional "& Friends". Without tying into the system just simply script in and script out However I do need a Kernel running on a piece of hardware It would be pointless to ask for a system without 1) Hardware Layer 2) a DiskOS Layer 3) A TeX Environment Layer 4) A Tex engine such as e-Tex or PdfLaTeX or contex I take this where I want & call this portable mode working
    – user170109
    Commented Mar 12, 2019 at 20:04
  • Agreed with all you're saying! I know python has nothing to do with TeX. I'm just saying that the workflow with the python virtual environments is very practical and well thought. I was hoping for the same kind of way to manage dependencies and path, without having TeXLive (or alternatives) installed systemwide.
    – Alex
    Commented Mar 12, 2019 at 20:22
  • I don't have any installed on the system that's my point I use dozens of editors cant have any native else it would skew the others, I can change my priority order so any one of 10 different ghostscripts versions or 3 different pythons or java or a string of perls or a dozen viewers such as okular evince sumatra acrobat etc etc etc can be switched on or off that is what environment settings were designed to do i.e allow you to SET environment at runtime
    – user170109
    Commented Mar 12, 2019 at 20:30
  • Ok, and how do you do that ?
    – Alex
    Commented Mar 12, 2019 at 21:01
  • I'm focused on Windows Environments your asking for Ubuntu or similar Hence comments rather than answer (however principles should be similar)
    – user170109
    Commented Mar 12, 2019 at 21:04

2 Answers 2


Asked to give a framework answer this is one way it may be done the key is not to install anything such that all settings are provided at runtime.

Although examples here are for Windows and just part of many scripts suited to each application, the principle is the same on any OS (the terminology and methods may differ) Note not every part is shown here but should give an idea for setting and chaining interdependent groups of applications without add permanently to one system

Here is a the core loader for MiKTeX so that all variables are added at runtime before any other app such as Python SageMath etc

@echo off
:: Ensure HOME is set OUTSIDE system default (consider if it needs to be RESET)

:: Prepare TeX environment this is for a windows portable installation (need similar scripting for bash)
set GS=%~d0\Apps\Graphics\Artifex\gs9.26
set IMAGEMAGICK=%~d0\LyX-23\LyX-232-2\imagemagick
set INKSCAPE=%~d0\Apps\Graphics\inkscape\0.92.3xp\App
set MIKTEX=%~d0\MiKTeX app
set PERL=%~d0\LyX-23\LyX-232-2\Perl

:: Use a TeXmf specific to MiKTeX keep separate from the TeX Live/W32TeX one
set TEXMF=%MIKTEX%\texmf-local

:: Need a similar list of alias for nix
set PATH=%MiKTeX%\texmfs\install\miktex\bin;%inkscape%\inkscape;%imagemagick%;%GS%;%GS%\x32\bin;%Perl%\bin;%path%

echo About to start MiKTeX console in background (Ctrl-C to abort)

:: ENSURE Update font mapping as system font mapping may have changed
start " " "%~d0\MiKTeX app\texmfs\install\miktex\bin\miktex-console"  --mkmaps

echo Please update MiKTeX Packages / Use TeXworks
echo or press any key to continue to secondary shell
pause > nul:

:: Add choice of editor or other supporting apps here
cmd /k

An alternative script for Tex Live can be run so that all variables are added at runtime before any other app such as Python SageMath etc

If I wish to run ANKI on top of MiKTeX (or TeX Live) then this one calls the other

:: The standard Anki builds use hardware acceleration by default, and the ALTernate builds do not.
:: If you experience graphical issues, or problems starting Anki, changing the hardware acceleration setting
:: in Anki’s preferences screen may help. If Anki shows an error message on startup on Windows and restarting
:: it a few times does not help, you can manually change the video driver by running the following in cmd.exe:
:: may need one time EITHER OR ?
:: echo auto > %APPDATA%\Anki2\gldriver
:: echo angle > %APPDATA%\Anki2\gldriver
:: Note this is the ALT version so above should not be needed
set ANKI=%~d0\anki\anki_alt

echo The ANKI undo shortcut is different in the alternate version due to an issue with the toolkit.
echo You can discover the alternate shortcut by looking at the Edit menu of the main screen.
echo The toolkit ANKI uses can have trouble with cut and paste when other clipboard programs are running.

:: use default MiKTeX script which loads Artifex Ghostscript 9.2, ImageMagik (convert), Inkscape 0.9, Perl 5.24.2

:: will alter the scale of Anki’s web views (like the deck list, study screen, etc), while leaving interface elements like the menu bar alone. Replace 1 with the desired scale, such as 1.5 or 2. 
:: will turn off some of Qt’s high dpi support 
following is for proxy issues (beware security compromise)
start /b %~d0\anki\anki_alt\anki.exe -b %~d0\anki\data
  • If I understand correctly, MikTeX and all the others are already available on you system and you tell it to work in your specified directory, so any further package installation and produced documents will go there ?
    – Alex
    Commented Mar 13, 2019 at 0:35
  • All components are dotted about on a 64gb drive partition but I can move any cohesive parts to a 2gb drive if needs be. The tex folders can be and are on drives A: to Z: or the cloud or sometimes the machines on my right or left (any that run windows) I have not tried on the Linux machines because my binaries are windows but I really should switch its just that I know cpm/dos better than posix/nix which I still find alien to me
    – user170109
    Commented Mar 13, 2019 at 0:52
  • Probably ought to point out there are pitfalls due to the way I work. For me its easy to get paths mixed which you would avoid by sticking with one TeX not 4 or 5 as I have You would need to set aliases for the latest Perl and Python to the one that's best for you e.g. you need a simple switch between ONE copy of Python 2.7 and 3.7 not lots of others IF there are dependencies on your ~/home folders and system shell start-up scripts you need to work with those (in windows this can involve peeking and poking the registry = not for the feint hearted, but easily actioned)
    – user170109
    Commented Mar 13, 2019 at 1:05
  • Holy hell, I'm really not at that level yet haha ! You gave me some ideas, but in the end it all comes back to have TeX installed somewhere and bringing it back to you work folder !
    – Alex
    Commented Mar 13, 2019 at 1:18
  • Yes it needs to be structured as if it were installed (BUT NOT :-) this is why Portable apps are so popular I used to keep rolls of punched paper in my back pocket but often they got torn and the programmers would go ape in case I got mud in the machine, then we went to cards, tape reels, floppy disk so small it went in the back pocket again :-) hard drives and Zip Disk now a chip as big as your little finger nail what ever next ? but always portable no dependency on one machine
    – user170109
    Commented Mar 13, 2019 at 1:55

Found a lovely little package called TinyTeX who does approximately what I wanted. I only had to change a few of the environments variables to make in install in my virtual environment's bin !

Even if not to install in a virtual environment, I strongly recommend you take a look at TinyTeX ! It works really good !

  • Tiny TeX like W32Tex and several others are a TeX Live variation in comparison to the MiKTeX alternative e.g. Tiny tex is effectively "TeX Live on the fly" You will certainly need the Tex Live manager to add the necessary packages do not use the MiKTeX package manager generally I find MiKTeX portable more reliable.
    – user170109
    Commented Mar 22, 2019 at 13:25
  • The thing is that I was able to modify TinyTeX script in order to make the installation in the venv. I still have to use TeXLive manager yes, but everything installs in the venv's bin ! Since I don't know a lot about shell, I've found editing an already existing script that does what I wanted, easier.
    – Alex
    Commented Mar 22, 2019 at 13:49
  • @KJO , could you take a look at my other question, you seem pretty knowledgeable about TeX related subjects : here
    – Alex
    Commented Mar 22, 2019 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .