# TeX capacity exceeded with multiple font encodings

I work in humanities, so please forgive my lack of competence and the weirdness of my computing needs. Is there a way to make this work? I need to use three (for starters) languages in the same document. Lithuanian (L7x), polish (LaTeX seems to render it fine without stating \usepackage{polski}) and russian (T2A). I get the error message below as soon as I introduce any third language-specific symbol into the document.

! TeX capacity exceeded, sorry [input stack size=5000].\L ->\L7x-cmd \L
\L7x\L
l.9 ĄąĆćĘęŁ
łŃńÓóŻż
!  ==> Fatal error occurred, no output PDF file produced!


Russian+lithuanian works fine, but a single "ł" triggers an error. The same with russian+polish and a "ė". A cyrillic character only causes non-fatal error (msg. below) for each symbol and cyrillic text is simply ignored in the output file.

! Package inputenc Error: Unicode char \u8:ц not set up for use with LaTeX.


Here is a MWE

\documentclass{article}
\usepackage[L7x,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[lithuanian,russian]{babel}
\begin{document}
%lithuanian
ĄąČčĘęĖėĮįŠšŲųŪūŽž
%russian
БбЖжЬьЯяЭэЩщШшПпЦц
%polish
ĄąĆćĘęŁłŃńÓóŻż
\end{document}

-
The first error looks like a bug in L7x. The second is the standard message if a character hasn't been setup yet (and is easy to adjust). If you use various language you normally have to inform latex about language switches (\selectlanguage{XVY}) so that latex can e.g. change font encodings. Perhaps the errors disappears then. But before everyone try to debug your example: Did you consider to use xelatex? –  Ulrike Fischer Feb 3 '12 at 8:26
On the face of it, it sounds like you need to think about moving to Xe(La)TeX (or LuaTeX) and UTF-8 –  Brent.Longborough Feb 3 '12 at 9:40
Yes, actually, I did consider that, just did not quite get around to it, since I'm still probing possibilities of LaTeX. I promise to think about it when I hit a complete dead end with LaTeX (that has local lithuanian support in one of our universities). –  Naglis Feb 3 '12 at 15:57
add comment

## 1 Answer

There is a bug in l7xenc.def that, as far as I can see, can be fixed. You should also confine the languages in the proper tags. For Polish either use the T1 encoding or, if you want to stay with L7x, add its selection when switching to Polish:

\documentclass{article}
\usepackage[L7x,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[lithuanian,polish,russian]{babel}

%%% Fix for L7x encoding
\makeatletter
\expandafter\let\csname L7x-cmd\endcsname\@changed@cmd
\makeatother

%%% Use L7x for Polish
\addto\extraspolish{\fontencoding{L7x}\selectfont}
\addto\noextraspolish{\fontencoding{\encodingdefault}\selectfont}

\begin{document}

%lithuanian
\begin{otherlanguage*}{lithuanian}
ĄąČčĘęĖėĮįŠšŲųŪūŽž
\end{otherlanguage*}

%russian
БбЖжЬьЯяЭэЩщШшПпЦц

%polish
\begin{otherlanguage*}{polish}
ĄąĆćĘęŁłŃńÓóŻż
\end{otherlanguage*}

\end{document}

-
add comment