4

Is it possible (i.e. is there any command) to access the version numbers of LaTeX/XeTeX directly from within a tex file?

So far I am simply using a small script that does latex --version or xetex --version, takes just the first line of the output and inserts \newcommand{\LaTeXVersion}{...} or \newcommand{\XeTeXVersion}{...} at a given position in the tex file.

4
  • Which version do you want? That's the engine banner plus other 'stuff'.
    – Joseph Wright
    Apr 30 '18 at 15:45
  • Something like XeTeX 3.14159265-2.6-0.99992 (TeX Live 2015/Debian). I just need the numbers for future reference to know what version I used to make the document.
    – Moked
    Apr 30 '18 at 15:51
  • Will it be sufficient to know just the engine number and not the versions of the used packages (can be updated independently I think). It still gives a hint though.
    – albert
    Apr 30 '18 at 16:01
  • Yep, I guess this would be enough.
    – Moked
    Apr 30 '18 at 16:04
8

XeTeX supports the primitives \XeTeXversion and \XeTeXrevision to get the used version of XeTeX. XeTeX also implemnts the eTeX extensions, so the \eTeXversion and \eTeXrevision primitives are available too to get the eTeX version.

These are the middle parts of the version printed in the banner, for example if you have XeTeX 3.14159265-2.6-0.99992 (TeX Live 2015/Debian), you can use

\documentclass{scrartcl}
\begin{document}
\the\eTeXversion\eTeXrevision-\the\XeTeXversion\XeTeXrevision
\end{document}

to get

2.6-0.99992

This should be enough to identify the engine. The 3.14159265 only says which TeX version your XeTeX is based on.

You also ask for the "LaTeX" version. The version of the LaTeX format is available as \fmtversion, but this is not what is shown when you call latex --version, because this command shows the version of the TeX engine used by latex, normally pdfTeX. If you document uses pdfLaTeX and you want to get the version, you can use primitives similar to the XeTeX ones:

\documentclass{scrartcl}
\begin{document}
\the\eTeXversion\eTeXrevision-\the\pdftexversion.\pdftexrevision
\end{document}

Result:

2.6-140.19

But pdfTeX also allows you to access the full banner:

\documentclass{article}
\begin{document}
\pdftexbanner
\end{document}

On my system for example this gives

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) kpathsea version 6.3.0

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.