[Tex/LaTex] How to get LuaLaTeX to work with babel’s \textgreek

babelluatex

I'm completely at a loss with how to get LuaLaTeX to output Greek text. I have tested the following MWE with PDFLaTeX and LuaLaTeX on both TeXlive 2009 (Linux) and TeXlive 2011 (Win32) and in both cases PDFLaTeX produces the expected output while LuaLaTeX seems to gobble up the Greek text and then do nothing with it.

\documentclass{minimal}
% Use LGRx if installed else LGR. 
% Forcing one or the other makes no difference either.
\IfFileExists{lgrxenc.def}{%
    \usepackage[LGRx,T1]{fontenc}}{%
    \usepackage[LGR,T1]{fontenc}}
%\fi
\usepackage{lmodern,trace,ifluatex}
\usepackage[greek,british]{babel}
\unless\ifluatex
  \usepackage[utf8]{inputenc}
\fi
\begin{document}
% pdflatex: OK. 
%lualatex:  "τρίγωνον" is missing from the output, 
%           and the sum total of output from \traceon is this: 
%             {into \tracingonline=1}
%             {the character τ}
%             {end-group character }}
Triangle: \textgreek{\traceon τρίγωνον}.
\end{document}

Best Answer

If you want to use the original CB fonts for Greek, there is a way out, but you need to have lgrenc.dfu, so I'll assume it's available along with its sibling lgrxenc.def:

\documentclass{minimal}
\usepackage[LGRx,T1]{fontenc}
\usepackage{lmodern,ifluatex}
\usepackage[greek,british]{babel}
\ifluatex
  \let\LtxDeclareUnicodeCharacter\DeclareUnicodeCharacter
  \def\DeclareUnicodeCharacter#1{%
    \catcode\string"#1=\active
    \begingroup
    \lccode`~=\string"#1\relax
    \lowercase{\endgroup
      \protected\def~}}
  \input{lgrenc.dfu}
  \let\DeclareUnicodeCharacter\LtxDeclareUnicodeCharacter
\else
  \usepackage[utf8]{inputenc}
\fi
\begin{document}
Triangle: \textgreek{τρίγωνον}.
\end{document}

With LuaLaTeX I use lgrenc.dfu for a different purpose, that is for activating the Greek characters and defining them to the required meaning.

However I don't see the advantages of using LuaLaTeX, in this case.

Related Question