[Tex/LaTex] Serbian Latin & Cyrillic Script

cyrillicfont-encodings

I am using the fontenc package in order to write texts in either Serbian Latin script (OT1 encoding) or Serbian Cyrillic script (OT2 encoding). My objective is to typeset an appreciable quantity of body text by compiling a single LaTeX code and to produce the Serbian Latin output text or Serbian Cyrillic output text depending on the used fontenc encoding. However, this appears impossible as switching from one fontenc encoding to the other implies the use of different letter representations in the LaTeX code. For instance, letter ž (Latin) is identical to ж (Cyrillic). Yet, they must be differently encoded in OT1 and OT2 as \v{z} and zh, respectively. I have given two examples below in which the same sentence meaning "Perhaps Novak Djokovic can win a match against Nadal on clay" has the two outputs (Latin and Cyrillic), but their LaTeX codes are unfortunately different, and not universal as wanted. Any help would be more than welcome. Thanks in advance.

% Example_1
\documentclass{scrartcl}
\usepackage[OT1]{fontenc}
\usepackage[english,serbian]{babel}
\begin{document}
Mo\v{z}da Novak \DJ{}okovi\'{c} mo\v{z}e da osvoji me\v{c} protiv Nadala na \v{s}ljaci.
\end{document}
% Example_2
\documentclass{scrartcl}
\usepackage[OT2]{fontenc}
\usepackage[english,serbian]{babel}
\begin{document}
Mozhda Novak DJokovic1 mozhe da osvoji mech protiv Nadala na shljaci.
\end{document}

Best Answer

For Serbian language the best option is to use the cmsrb package. You will also get the correct italic shape of Cyrillic italic letters.

\documentclass{article}
\usepackage{cmsrb}
\usepackage[OT2,T1]{fontenc} %better to use T1, but OT1 will also work
\usepackage[serbian]{babel}
\begin{document}

Mo\v{z}da Novak \DJ{}okovi\'{c} mo\v{z}e da osvoji me\v{c} protiv Nadala na \v{s}ljaci.

\textit{abc\v c\'cdd\v z\dj efghijklljmnnjoprs\v stuvz\v z}

\fontencoding{OT2}\selectfont

Mo\v{z}da Novak \DJ{}okovi\'{c} mo\v{z}e da osvoji me\v{c} protiv Nadala na \v{s}ljaci.

\textit{abc\v c\'cdd\v z\dj efghijklljmnnjoprs\v stuvz\v z}

\end{document}

cmsrb Example

This will also work with UTF-8 input.

Related Question