Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to be able to automatically determine which release of TeXLive that I am running. I sometimes encounter a problem where it is useful to test that the file compiled correctly in an older release first, before trying to debug the problem.

Currently, I have updated my code to use the new features of the the datatool package as per No room for a new \count with datatool. Along with the datatool update, I updated all the other packages and am now encountering a problem that at least seemed to have worked properly for over a year now.

But it is not simple to switch back to running the older TeXLive2011 as it does not have the new packages. And of course updating the packages of the 2011 would kind of defeat the purpose of here. :-)

The MWE below runs fine with the latest updated TeXLive2012 (Version 2.13 of datatool or later). But, in order for this to run with an older release, one needs to manually edit the \def\TeXLiveVersion version to something other than 2012.

References:

Notes:

  • For the MWE to be useful, an older release is required as there is no issue here with the current TeXLive2012. Or, if you have not updated your packages lately and have v2.12 (or older) version of datatool package (in which case this won't run unless you manually edit the \TeXLiveVersion to:

    \def\TeXLiveVersion{2011}%
    
  • Here is an older question where I had a problem with TeXLive2011 (but the file compiled fine with TeXLive2010): Debugging Advice: TeX Capacity Exceeded with TeXLive2011 (but not with TeXLive2010). At that time I had manually changed the preamble, but again that is a case where an automated solution would have been useful.

  • In case it is not obvious, the actual output of the MWE here is not important. It is a cooked up example to show a case where I need to know which version of TeXLive I am using, and a way to test that the proposed solution of determining the version actually worked.

Code:

\def\TeXLiveVersion{2012}% <--- Don't want to have to manually specify this

\documentclass{article}
\usepackage{datatool}
\usepackage{pgffor}
\usepackage{xstring}
\usepackage{letltxmacro}

%\usepackage{filecontents}% Commented to prevent overwriting MyData.csv
\begin{filecontents*}{MyData.csv}
    Directory, Color
    ../dirB,    red
    ../dirC,    yellow
\end{filecontents*}

\LetLtxMacro\MyDTLcleardb{\DTLcleardb}% Default to 2012 and future
\IfEq{\TeXLiveVersion}{2012}{%
}{%
    \newif\ifDTLnewdbonload%
    \LetLtxMacro\MyDTLcleardb{\DTLdeletedb}%
}%

\begin{document}

\DTLnewdb{MyDB}
\DTLnewdbonloadfalse% don't let \DTLloaddb create a new database 

\foreach \x in {1,...,5}{% Read DB numerous times
    \typeout{count=\x}%
    \MyDTLcleardb{MyDB}% clear database
    \DTLloadrawdb[keys={Directory,Color}]{MyDB}{MyData.csv}%
}%

\par\noindent\DTLdisplaydb{MyDB}% Some output to have a PDF
\end{document}
share|improve this question
1  
Testing versions of TeX Live won't help here: you are interested in package versions. People tend to think that the version of TeX Live they use covers everything, but unless you only use the DVD versions then there is no easy correspondence between TL and package versions. –  Joseph Wright Feb 3 '13 at 9:08
1  
@JosephWright: Yes I understand that and reverting to earlier versions of packages would also be useful as well. Ideally if I would like to be able to create a snapshot and say run "TeXLive2012 with packages as of Jan 1, 2013". However, it is still useful to be able to run with an older known good release to see if it is indeed a new problem or not. –  Peter Grill Feb 3 '13 at 9:13
add comment

1 Answer

up vote 7 down vote accepted

With pdflatex or lualatex it's possible, because TeX Live programs advertise the release year in their banner:

\documentclass{article}

\makeatletter
\def\getversion{\expandafter\get@version\pdftexbanner\@nil}
\def\get@version#1201#2)#3\@nil{\def\TeXLiveVersion{201#2}}
\makeatother
\getversion

\begin{document}
This has been run with \TeX~Live~\TeXLiveVersion.

\texttt{\pdftexbanner}
\end{document}

enter image description here

This might be fooled by other "201" strings in the banner, but one should analyze banners produced by different packagings of TeX Live (Debian modifies it, for instance) in order to find a robust scheme.

However, testing just for the release year is not sufficient; it's better to rely on looking at package versions with \@ifpackagelater.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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