How does one properly install two (parallel) versions of the SAME LaTeX package inside TeX Live ? Take for example, biblatex 2.8 and 2.9. I currently have one installed inside TL 2013 and another in TL 2014, and can go back and forth to compared produced files, etc. ... but that is not optimal, and I now need both inside TL 2014!
- 259,911
- 34
- 706
- 1,036
- 2,405
3 Answers
TeX searches the current/working folder first for files/packages to include before it searches elsewhere (your local/texmf or the root TeX folder).
So, the only way to do this "efficiently" is to use your working folder to store the two versions. Place one in a folder called X and another in a folder called Y. Then, with every run of LaTeX, you can execute a script to copy the required version (X or Y) to your working folder (either before compilation, or mid-compilation using --shell-escape).
Otherwise you're left up to TeX to pick the first package name that matches your requirement based on the way it sets up its package/file hash table, which may not be the version you're after.
- 603,163
-
Let's assume if we don't know
Xhasbiblatex 2.8andYhas2.9How to check which version is TeX running for the existing.texfile? – texenthusiast Jul 01 '14 at 03:09 -
1
-
@Werner: I am not sure I understand all the details of what you wrote, but I guess you are on to something - could you elaborate your answer in the steps necessary to accomplish this? I guess they will include de-installing the version that comes with TeXLive ? What happens if the two versions have files named differently (american.lbx vs. en-US.lbx) ? – Paulo Ney Jul 01 '14 at 11:51
-
-
@Jubobs: When you look at the output of running
texhash, you see that the hash table includestexmf-localbeforetexmf-distwhere all the default repository versions are stored. And I know the local folder is searched first (a cause for many problems people have on this site). So, the sequence is (1) working folder, (2)texmf-local, (3)texmf-dist, since TeX would just find the first available match and use it... – Werner Jul 01 '14 at 20:04 -
@Werner If I run
texhashwith MacTeX (TeX Live 2014),texmf-localgets listed aftertexmf-dist. Perhaps the order of priority varies from one platform/distro to another... – jub0bs Jul 01 '14 at 20:13 -
@Jubobs Maybe it is displayed differently but the order of priority is definitely the same on Mac OS X and GNU/Linux. (Unless MacTeX has recently changed this which seems unlikely.) – cfr Jul 01 '14 at 21:34
-
You can use e.g.
kpsewhich -show-path=.styto get the actual search path for style files, for example. This showstexmf-localbefore the main distribution directories even thoughtexhashlists the local path last. So I don't think thattexhashreflects the priority search-wise at all. Indeed, it doesn't even include the directories with highest priority because they don't have filename databases. (At least, they do not on unix-like systems.) – cfr Jul 01 '14 at 22:26 -
If possible, keep a complete copy of version
Xin folderXand a complete copy of versionYin folderY. Now copy the entire contents of folderXto the working folder and run your.texfile. When you want to switch to versionY, copy the entire contents of folderYto your working folder (most likely overwriting a bunch of existing versionXfiles). You can leave the installed (current/correct) version of the package that comes with TeX Live. As mentioned, TeX looks in the working folder first, before searching elsewhere for files. – Werner Jul 03 '14 at 06:26
I have quite a lot testing/development/experimental/local versions of packages that I want to use temporarly with my TeXsystems.
I always put such packages in their own texmf tree and than attach this texmf trees to the texsystem(s) when needed.
Side remark:
biblatex is a special case: When switching the biblatex version you must also use a different biber.exe. To avoid to have to fight with the PATH variable I renamed the additional biber executables to biberexp.exe and biberdev.exe and call this executables when I switch to another biblatex version.
With miktex attaching a texmf tree is rather straightforward: I run on the command line or through some script/shortkey initexmf --register-root=path/to/texmf to register the root and initexmf --unregister-root=path/to/texmf to remove it.
With a current texlive (2017, 2018) one can use
tlmgr conf auxtrees add /quick/test/tree
tlmgr conf auxtrees remove /quick/test/tree
to the same effect.
With older texlive it is not so easy. There I'm using currently a mixed strategy: For the biblatex packages I change TEXMFCNF so that it points to a different texmf.cnf, in other cases I manually change a texmf.cnf that I have in my main local tree, or I change TEXMFHOME with tlmgr conf texmf TEXMFHOME=. That's all not very satisfying and I think that when I find some time I will write a script that can add and remove roots from my local main texmf.cnf and can be used like the miktex tool. (Edit 2018: I wrote such a script but due to the changes in texlive it is no longer needed.)
- 327,261
-
As usual - the devil is in the details - I would love to see such a script, or even to see more details of the 3 strategies above, with the values of the variables, etc ... – Paulo Ney Jul 01 '14 at 12:09
Fundamentals
The basic idea of this approach relies on calling executables using their full paths. That is, running
/usr/local/texlive/2014/bin/x86_64-linux/pdflatex
and
/usr/local/texlive/2014/bin/x86_64-linux/biber
or
/usr/local/texlive/2013/bin/x86_64-linux/pdflatex
and
/usr/local/texlive/2013/bin/x86_64-linux/biber
If you don't need to do this often, that might be the simplest way - just specify the full paths. Or create bash aliases as shortcuts.
[Of course, one of 2013 or 2014 is presumably your default so you'd only actually need to do this for the non-default case.]
Calling the relevant executables automatically ensures that packages from the appropriate version are used. That is, when you call the 2013 executables, you get 2013 packages even if 2014 is your default.
A more sophisticated strategy
If you need to do this a lot, though, I'd suggest using an approach which allows you to switch between 2013 and 2014 from within your .tex file.
Here I explain how to use arara to switch between TeX Live 2013 and TeX Live 2014 by switching directives within the .tex file. Obviously you could do something similar for other executables. Just copy and adapt the scripts from /usr/local/texlive/2014/texmf-dist/scripts/arara/rules/ as I've done for pdflatex and biber.
Step 1: Add directives to the file
Here I'm just using the standard directives which arara provides by default.
% arara: pdflatex
% arara: biber
% arara: pdflatex
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
\begin{filecontents}{\jobname.bib}
@article{some-article,
author = {Dude, Some},
title = {Some Title},
year = 1066,
journal = {Some Journal},
pages = {1000456--1005027}}
\end{filecontents}
\bibliography{\jobname}
\begin{document}
\autocite{some-article}
\printbibliography
\end{document}
From the log:
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2014.6.28) 1 JUL 2014 22:31
entering extended mode
...
(/usr/local/texlive/2014/texmf-dist/tex/latex/biblatex/biblatex.sty
Package: biblatex 2014/06/25 v2.9a programmable bibliographies (PK/JW/AB)
From the .bbl:
% $ biblatex bbl format version 2.4 $
Step 2: Create variant arara rules
Start by creating a configuration file in your home directory, araraconfig.yaml, with the following content:
!config
paths:
- <arara> @{userhome}/.arara/rules
# vim: set nospell:
Obviously omit the last line if you don't use vim. Also, change the path for the rules if you'd prefer something different. For example:
!config
paths:
- <arara> @{userhome}/rules
Then create the following four files in your rules directory. For example, mine are in ~/.arara/rules because that's what I put in my configuration file.
File 1
Name: biber2013.yaml
Content:
!config
# Based on Biber rule for arara
# Biber rule author: Marco Daniel
# requires arara 3.0+
identifier: biber2013
name: Biber 2013
command: <arara> /usr/local/texlive/2013/bin/x86_64-linux/biber @{options} "@{getBasename(file)}"
arguments:
- identifier: options
flag: <arara> @{parameters.options}
# vim: set nospell:
File 2
Name: biber2014.yaml
Content:
!config
# Based on Biber rule for arara
# Biber rule author: Marco Daniel
# requires arara 3.0+
identifier: biber2014
name: Biber 2014
command: <arara> /usr/local/texlive/2014/bin/x86_64-linux/biber @{options} "@{getBasename(file)}"
arguments:
- identifier: options
flag: <arara> @{parameters.options}
# vim: set nospell:
File 3
Name: pdflatex2013.yaml
Content:
!config
# Based on PDFLaTeX rule for arara
# PDFLaTeX rule author: Marco Daniel
# PDFLaTeX rule last edited by: Paulo Cereda
# requires arara 3.0+
identifier: pdflatex2013
name: PDFLaTeX 2013
command: <arara> /usr/local/texlive/2013/bin/x86_64-linux/pdflatex @{action} @{draft} @{shell} @{synctex} @{options} "@{file}"
arguments:
- identifier: action
flag: <arara> --interaction=@{parameters.action}
- identifier: shell
flag: <arara> @{isTrue(parameters.shell,"--shell-escape","--no-shell-escape")}
- identifier: synctex
flag: <arara> @{isTrue(parameters.synctex,"--synctex=1","--synctex=0")}
- identifier: draft
flag: <arara> @{isTrue(parameters.draft,"--draftmode")}
- identifier: options
flag: <arara> @{parameters.options}
# vim: set nospell:
File 4
Name: pdflatex2014.yaml
Content:
!config
# Based on PDFLaTeX rule for arara
# PDFLaTeX rule author: Marco Daniel
# PDFLaTeX rule last edited by: Paulo Cereda
# requires arara 3.0+
identifier: pdflatex2014
name: PDFLaTeX 2014
command: <arara> /usr/local/texlive/2014/bin/x86_64-linux/pdflatex @{action} @{draft} @{shell} @{synctex} @{options} "@{file}"
arguments:
- identifier: action
flag: <arara> --interaction=@{parameters.action}
- identifier: shell
flag: <arara> @{isTrue(parameters.shell,"--shell-escape","--no-shell-escape")}
- identifier: synctex
flag: <arara> @{isTrue(parameters.synctex,"--synctex=1","--synctex=0")}
- identifier: draft
flag: <arara> @{isTrue(parameters.draft,"--draftmode")}
- identifier: options
flag: <arara> @{parameters.options}
# vim: set nospell:
Step 3: Use the new directives
First, let's change the defaults to the 2014 directives. These should be essentially identical except for name and identifier:
% arara: pdflatex2014
% arara: biber2014
% arara: pdflatex2014
From the log:
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2014.6.28) 1 JUL 2014 22:39
...
(/usr/local/texlive/2014/texmf-dist/tex/latex/biblatex/biblatex.sty
Package: biblatex 2014/06/25 v2.9a programmable bibliographies (PK/JW/AB)
From the .bbl:
% $ biblatex bbl format version 2.4 $
Now let's test the 2013 directives:
% arara: pdflatex2013
% arara: biber2013
% arara: pdflatex2013
From the log:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013) (format=pdflatex 2014.4.9) 1 JUL 2014 22:42
entering extended mode
...
(/usr/local/texlive/2013/texmf-dist/tex/latex/biblatex/biblatex.sty
Package: biblatex 2013/11/25 v2.8a programmable bibliographies (PK/JW/AB)
From the .bbl:
% $ biblatex bbl format version 2.3 $
- 198,882
-
Looks quite complicated. And I have some doubts that every tool find "its" texlive tree. What about lualatex, makeindex, xindy, updmap, fc-cache, luaotfload-tools etc? When I want to switch tex systems I simply prepend the path to the binaries to the standard path. In Winedt speak
SetEnvVar('PATH','%$(UFTeXLivePath14);%$(xPATH);');– Ulrike Fischer Jul 02 '14 at 08:58 -
@UlrikeFischer I was surprised this worked and believe I discovered it by accident. But it does seem to work. Note that for any binary you must specify the full path. So you'd need to give the full path to those binaries. (Not
fc-cacheas that's not a TeX Live binary anyway. Unless they provide it for Windows but the OP can't be on Windows since they use symbolic links.) – cfr Jul 02 '14 at 16:28 -
But the "you must specify the full path" is the problem. That's fine for a single pdflatex call. But how should this work if e.g. a document calls epstopdf or another application? See e.g. the packages imakeidx or getmap or auto-pst-pdf. And did you check if xetex finds the right xdvipdfmx? – Ulrike Fischer Jul 02 '14 at 16:37
-
@UlrikeFischer I don't disagree. If I was using packages which called further binaries, I'd just switch the sym links in
/usr/local/texlive. While you could getararato do everything, I think it would be madness to make the attempt. I also think it would be nuts to try to figure out what would happen in these cases. Switching the sym links is easier than worrying about those things. Personally, I don't useararafor this. I just specify the full path to the binary. And I only use it forbiblatex/biber. It was not intended as a general solution for all possible cases. – cfr Jul 04 '14 at 00:27
biberrequires the matching version ofbiblatexso the binary is going to be wrong for 2.8 in any case. If it weren't for this, you could just link the old version from your working directory. But that won't work in this case. (Unless you don't usebiberbut that is definitely not optimal.) – cfr Jul 01 '14 at 02:01biberyou use. What you can't do is usebiblatexfrom 2013 withbiberfrom 2014 or vice versa. That's why I said that in other cases, you could link from your current directory. Normally, that'll work. Justbiblatex/biberis a special case where matching versions are required. – cfr Jul 01 '14 at 11:48latex(orpdflatexor whatever) andbiber. Then the relevant packages will be automatically used. But you'll be using all TL 2013 or all 2014 in that case - not a mixture. If you use something likeararayou could switch this within thetexfile. – cfr Jul 01 '14 at 11:49arararules accordingly. Also, regardless of method, renaming means you must deal with complications following updates. Since it is unnecessary, only rename if you enjoy unnecessary work ;). – cfr Jul 01 '14 at 22:15