This question is directly inspired by Martin Schroder's answer to this question. Namely, I am wondering how would one use LuaTeX or XeTeX to produce Serbian (little bit different than Russian) Cyrillic output using American keyboard layout? How would produce the same output using Serbian keyboard layout? The correct way to produce such output using pdfTeX engine and American keyboard layout is:
\documentclass{article}
\usepackage[OT2,T1]{fontenc}
\input{cyracc.def}
\newcommand\textcyr[1]{{\fontencoding{OT2}\fontfamily{wncyr}\selectfont #1}}
\begin{document}
Serbian alphabet again \dots \textcyr{\cyracc
A B V G D DJ E Zh Z I J K L LJ M N NJ O P R S T \'C U F Kh C Ch \Dzh\ Sh
}
\end{document}
which gives
One can use of course inputenc to use Serbian keyboard. On another hand Babel unfortunately requires Serbian keyboard so for me personally was not interesting.
Best Answer
Here is a method for XeLaTeX.
Prepare a file
ascii-to-serbian.map
with the following content:Then process it with
This will produce a file
ascii-to-serbian.tec
that you can put anywhere XeTeX will find it (in the working directory, for instance). Then make the following test file:Sample output after
xelatex test.tex
Note 1: the characters
Џ
andџ
can be input also asDZH
(orDzh
) anddzh
. If this is incorrect (it might bring to incorrect ligatures) then remove the corresponding lines fromascii-to-serbian.map
.Note 2: if you find it inconvenient to type
C1
andc1
to get Ћ and ћ, you can add the linesand
after the
C1
andc1
entries. This will allow you to input the characters as'C
and'c
.If you want to input them as
\'C
and\'c
, then insert this code after having loaded the Serbian language with PolyglossiaNote 3 (added Feb. 17): If one has available Unicode input, then also
are mapped to
respectively.