5

I started to learn russian, and I need to write russian in LaTeX. I am aware of the \foreignlanguage{russian}{text} function. But how do I make a new command, so I only need to type \rl{text}?

\documentclass{article}
\usepackage[OT2, T1]{fontenc}
\usepackage[russian, english]{babel}

\begin{document}
\newcommand{\rl}[1] {\foreignlanguage{russian}{}}  

\rl{This should be russian}

\end{document}
3
6

The main problem is that you're not telling TeX what to typeset in the cyrillic script: your definition ends up in discarding the argument and typesetting nothing in Russian.

You need

\newcommand{\rl}[1]{\foreignlanguage{russian}{#1}}

where #1 stands for the contents of the argument following \rl when called.

Since TeX is a macro expansion language, also

\newcommand{\rl}{\foreignlanguage{russian}}

would work, because when TeX sees \rl{Russkii0 yazyk}, it would replace \rl with \foreignlanguage{russian}. But probably the first way is easier to understand.

However, if you plan to use the default Computer Modern font, you'd better make a change to how \cyrillictext (the internal macro called when switching to Russian) works. The problem is that the cmr font family in the encoding OT2 is associated to a font that's only available as bitmap. A very similar font is distributed by AMS also as Type1. The change I propose is thus

\documentclass{article}
\usepackage[OT2, T1]{fontenc}
\usepackage[russian, english]{babel}

%% Let's patch \cyrillictext so that it uses
%% the Washington University fonts
\usepackage{xpatch}
\xpatchcmd{\cyrillictext}
 {\selectfont}
 {\fontfamily{wncyr}\selectfont}
 {}{}
\let\cyr\cyrillictext

\newcommand{\rl}[1] {\foreignlanguage{russian}{#1}}

\begin{document}

\rl{Russkii0 yazyk}

\end{document}

A comparison of the output should say all. In the first image you see pixelated fonts. The “ka” and the “ya” in the second example are slightly different, but “more Cyrillic” in my opinion.

Output with the default Cyrillic fonts

enter image description here

Output with the Washington University fonts

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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