Conditional typesetting based on the used Babel language

Here is a short piece of code that shows how the set document language may be evaluated during the LaTeX run. Credit goes to Heiko Oberdiek for his nice iflang package.

\documentclass[english]{scrartcl}
\usepackage{babel,iflang}
\newcommand{\tr}[2]{\IfLanguageName{ngerman}{#1}{#2}}
 
\begin{document}
 
\tr{Deutscher Text}{English text}
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website