11

This question already has an answer here:

I just installed Texlive 2014, and ran into this problem: lgrxenc.def not nound. The solution is apparently to remove LGRx from \usepackage[LGRx,T1]{fontenc}; but I'd rather use something like this:

\ifnum \texliveVersion<2013
  \usepackage[LGRx,T1]{fontenc}
\else
  \usepackage[T1]{fontenc}
  \usepackage[greek,english]{babel}
\fi

Anything like this out there, which would not require me to run -shell-escape everytime - just in case I need to compile the same document on the machine that has earlier TexLive?


EDIT: this is what I meant - this should be the code in https://tex.stackexchange.com/a/191705/2595 , but with a conditional switch for Texlive2014; unfortunately it crashes with ! Undefined control sequence. l.50 ...\bbl@monogreek \bbl@monogreek=\l@monogreek:

\documentclass[a4paper]{article}

% https://tex.stackexchange.com/a/16794/2595

\begingroup\makeatletter\endlinechar=\m@ne\everyeof{\noexpand}
\edef\x{\endgroup\def\noexpand\TeXLiveVersion{\@@input|"pdflatex -version | awk '/TeX Live/{print substr($5, 0, length($5)-1);}'" }}\x

\typeout{TexLive version is: \TeXLiveVersion}

% https://tex.stackexchange.com/a/191705/2595

\ifnum\TeXLiveVersion<2014 %
  \typeout{TexLive version is smaller than 2014, using LGRx} %
  \usepackage[LGRx,T1]{fontenc} %
\else %
  \typeout{TexLive version is >= 2014, NOT using LGRx} %
  \usepackage[T1]{fontenc} %
\fi %

% \usepackage{xgreek}
\usepackage[utf8x]{inputenx}
\usepackage[english,greek]{babel}

\begin{document}

The starting verse of the Iliad is
\begin{quotation}\greektext
Μῆνιν ἄειδε, θεά, Πηληιάδεω Ἀχιλῆος
\end{quotation}
and it's really great.

\end{document}

marked as duplicate by Peter Grill, percusse, clemens, Bordaigorl, Andrew Oct 9 '14 at 0:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Maybe this answer could be helpful. – Aradnix Oct 8 '14 at 22:02
  • 1
    Thanks for that @Aradnix - but that is the answer to exactly the same question I quoted; and I of course saw the answer. The thing is, I don't just want to delete from the code - I want to handle it depending on texlive version from inside pdflatex; I'd thus need a variable/command, which I can obtain by parsing a command line call, but that then requires -shell-escape, which I don't want; hence my question. Cheers! – sdaau Oct 8 '14 at 22:10
  • 5
    Why don't you test for the existence of the file \IfFileExists{lgrxenc.def}...? [Untested as you haven't provided an MWE.] – cfr Oct 8 '14 at 22:16
  • Thanks for that, @cfr - added a (somewhat unsuccessful) MWE; interesting idea with \IfFileExists{lgrxenc.def}, will give it a spin. Cheers! – sdaau Oct 8 '14 at 22:39
  • 1
    @sdaau Why bother with LGRx if you then use utf8x? I don't understand. However, use utf8 and your live will be happier. – egreg Oct 8 '14 at 22:47
8

This works with pdflatex and lualatex.

\documentclass{article}

\def\gettexliveversion#1(#2 #3 #4#5#6#7#8)#9\relax{#4#5#6#7}
\edef\texliveversion{\expandafter\gettexliveversion\pdftexbanner\relax}

\ifnum\texliveversion<2013
  \usepackage[LGRx,T1]{fontenc}
\else
  \usepackage[T1]{fontenc}
\fi
\usepackage[greek,english]{babel}

Tested on a “vanilla TeX Live” and also on a Debian provided one.

Explanation: \pdftexbanner expands to

This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) kpathsea version 6.2.0

on a vanilla TeX Live, but to

This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/Debian) kpathsea version 6.2.0

on Debian TeX Live (and similarly for other packaged distributions). The \gettexliveversion macro gets as its first argument everything up to (; #2 is TeX, #3 is Live, #4#5#6#7 is the year, #8 everything up to the ) and #9 is the rest. One might also use #8 for other purposes, so I left it there instead of gobbling everything after the year.

Alternative (and easier) version:

\IfFileExists{lgrxenc.def}
  {\usepackage[LGRx,T1]{fontenc}}
  {\usepackage[T1]{fontenc}}

Test 1

\documentclass{article}

\def\gettexliveversion#1(#2 #3 #4#5#6#7#8)#9\relax{#4#5#6#7}
\edef\texliveversion{\expandafter\gettexliveversion\pdftexbanner\relax}

\ifnum\texliveversion<2013
  \usepackage[LGRx,T1]{fontenc}
\else
  \usepackage[T1]{fontenc}
\fi

\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}

\begin{document}

The starting verse of the Iliad is
\begin{quotation}\greektext
Μῆνιν ἄειδε, θεά, Πηληιάδεω Ἀχιλῆος
\end{quotation}
and it's really great.

\end{document}

Test 2

\documentclass{article}

\IfFileExists{lgrxenc.def}
  {\usepackage[LGRx,T1]{fontenc}}
  {\usepackage[T1]{fontenc}}

\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}

\begin{document}

The starting verse of the Iliad is
\begin{quotation}\greektext
Μῆνιν ἄειδε, θεά, Πηληιάδεω Ἀχιλῆος
\end{quotation}
and it's really great.

\end{document}

Both test tried with TeX Live 2012 and 2014. The output is always the same:

enter image description here

  • 4 minutes too late... :( – cfr Oct 9 '14 at 0:00
4

Here's a version which just tests for the existence of the encoding file and is therefore independent of the TL version etc. (I assume this should work with e.g. MiKTeX etc. as well. It would also work if you installed a local version of the encoding although I am by no means suggesting that doing so would be wise.)

\documentclass[a4paper,greek,british]{article}% or american note that the LAST specified language is default

\IfFileExists{lgrxenc.def}{%
  \typeout{TexLive version is smaller than 2014, using LGRx} % probably better to change this to a more accurate message e.g. 'lgrxenc.def not found...'
  \usepackage[LGRx,T1]{fontenc}%
}{%
  \typeout{TexLive version is >= 2014, NOT using LGRx}%
  \usepackage[T1]{fontenc}%
}

% \usepackage{xgreek}
\usepackage[utf8]{inputenc}
\usepackage{babel}

\begin{document}

  The starting verse of the Iliad is
  \begin{quotation}\greektext
    Μῆνιν ἄειδε, θεά, Πηληιάδεω Ἀχιλῆος
  \end{quotation}
  and it's really great.

\end{document}

For TL 2014, for example, I get

TexLive version is >= 2014, NOT using LGRx

TL 2014

  • Thanks for this, @cfr - good to have as reference; cheers! – sdaau Oct 8 '14 at 23:53
  • @sdaau I see, however, that I was 4 minutes too late. Maybe I should delete this. It doesn't really add anything since egreg included the second test. – cfr Oct 9 '14 at 0:00
2

Quick and dirty test -- without lua, running with pdflatex and lualatex (but not needed in this case) ;-)

\documentclass{article}

\usepackage{xstring}

\IfSubStr{\pdftexbanner}{2014}{%
  \usepackage[T1]{fontenc}%
  \usepackage[greek,english]{babel}
}{%
  \usepackage[LGRx,T1]{fontenc}
}

\usepackage{blindtext}
\begin{document}
\blindtext
\end{document}
  • 1
    It could be also 2013 – egreg Oct 8 '14 at 22:28
  • 1
    @egreg: I did not say it's failsafe ;-) Well, it works on my computer. If I say 2013, it will branch to load the non existing file (since I have TL 2014) – user31729 Oct 8 '14 at 22:32
  • 1
    Thanks for that, @ChristianHupfer - I accepted egreg's answer due to somewhat stricter parsing; cheers! – sdaau Oct 8 '14 at 22:42
  • 1
    @sdaau: No problem at all ;-) Basically, this is a feature request to the TL team ;-) – user31729 Oct 8 '14 at 22:43

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