7

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!

9
  • 1
    You can't. How would TeX know which one to use? Why do you need 2.8 in TL 2014? Note that biber requires the matching version of biblatex so 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 use biber but that is definitely not optimal.)
    – cfr
    Jul 1 '14 at 2:01
  • The reasons for running two parallel versions of the same package are - most of the time - reasons of testing and compare produced output. In this particular case, I want to modify several dozen files and name make sure the output is correct.
    – Paulo Ney
    Jul 1 '14 at 11:42
  • As for You can't I am not sure I buy that! I already do it by moving symbolic links - but it is extremely inefficient and very messy.
    – Paulo Ney
    Jul 1 '14 at 11:44
  • When you change symbolic links, you are also changing which biber you use. What you can't do is use biblatex from 2013 with biber from 2014 or vice versa. That's why I said that in other cases, you could link from your current directory. Normally, that'll work. Just biblatex/biber is a special case where matching versions are required.
    – cfr
    Jul 1 '14 at 11:48
  • Note that you don't need to use symbolic links. You can just specify the full path for latex (or pdflatex or whatever) and biber. 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 like arara you could switch this within the tex file.
    – cfr
    Jul 1 '14 at 11:49
5

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.

9
  • Let's assume if we don't know X has biblatex 2.8 and Y has 2.9 How to check which version is TeX running for the existing .tex file? Jul 1 '14 at 3:09
  • 1
    @texenthusiast: See Which package version am I using?
    – Werner
    Jul 1 '14 at 3:26
  • @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 1 '14 at 11:51
  • @Werner Do you have a reference for local/texmf taking precedence?
    – jub0bs
    Jul 1 '14 at 17:47
  • @Jubobs: When you look at the output of running texhash, you see that the hash table includes texmf-local before texmf-dist where 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 1 '14 at 20:04
5

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.)

1
  • 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 1 '14 at 12:09
3

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 $
4
  • 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);'); Jul 2 '14 at 8: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-cache as 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 2 '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? Jul 2 '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 get arara to 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 use arara for this. I just specify the full path to the binary. And I only use it for biblatex/biber. It was not intended as a general solution for all possible cases.
    – cfr
    Jul 4 '14 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.