Using txfonts with Polish characters breaks tables
It's not a good idea to say \selectlanguage{<language>}
in the middle of a paragraph, as this command does many things with unpredictable results in case of a page break and, as you experienced, also in other cases.
For short inserts in a different language, use
\foreignlanguage{polish}{ę}
while for longer passages you can choose between
\begin{otherlanguage*}{polish}
...
\end{otherlanguage*}
and
\begin{otherlanguage}{polish}
...
\end{otherlanguage}
The difference is that the former doesn't change the fixed words (the chapter's name and so on), while the latter does. Both change the settings for hyphenation and language shortcuts.
It's actually not necessary to write \foreignlanguage{polish}{<polish passage>}
:
\newcommand{\pl}[1]{\foreignlanguage{polish}{#1}}
makes available the syntax \pl{polish passage}
.
Workaround
There is a tragic error in txfonts.sty
where \k
is redefined in a wrong way: the \ooalign
macro is not protected by braces and so, as soon as one uses a letter with an ogonek at the outer group level, the setting \lineskiplimit=-\maxdimen
becomes global.
One can correct it with
\makeatletter
\AtBeginDocument{\let\T@n@@nc@d@ngM@cr@M@d\relax}
\makeatother
\usepackage{txfonts}
This will avoid the wrong redefinition, so no other trick is necessary, as the definition of \k
will remain the correct one issued by the fontenc package. However, a better loading order would be
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[polish,english]{babel}
\makeatletter
\AtBeginDocument{\let\T@n@@nc@d@ngM@cr@M@d\relax}
\makeatother
\usepackage{txfonts}
A possible cleaner solution might be to write a "corrected package", say fixtxfonts.sty
that says
\ProvidesPackage{fixtxfonts}
\AtEndOfPackage{%
\let\T@n@@nc@d@ngM@cr@M@d\relax
\DeclareTextCommand{\k}{LY1}[1]{{\ooalign{\hidewidth\char7\crcr#1}}}%
}
\RequirePackage{txfonts}
and say \usepackage{fixtxfonts}
instead of \usepackage{txfonts}
The shortest fix: use braces around ę:
\pl {ę} \ee
For longer text, you could use the otherlanguage
environment instead of switching by \selectlanguage
to Polish and back to English:
\begin{otherlanguage}{polish}
ę
\end{otherlanguage}
Before, with \pl ę \ee
(\selectlanguage
), for illustration:
Afterwards, with braces or otherlanguage
: