6

Here is my code (utf8):

\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage{anttor}
\begin{document}
text $math$

Russian: Щ
\end{document}

The problem is, "math" is still the CM font; and the Cyrillic font does not appear.

6

The Antykwa Toruńska font has support for the Cyrillic script and also for math; if you want to use XeLaTeX, then this is how you can do it

\documentclass{article}
\usepackage[math]{anttor}
\usepackage[no-math]{fontspec}
\setmainfont[Ligatures=TeX]{Antykwa Torunska}

\begin{document}
text $math$

Russian: Щ
\end{document}

You may need to find out how to actually load the AT font on your machine, possibly with

\setmainfont[
  Ligatures = TeX,
  Extension = .otf,
  UprightFont = *-Regular,
  BoldFont = *-Bold,
  ItalicFont = *-Italic,
  BoldItalicFont = *-Italic
]{AntykwaTorunska}

that should work with a TeX Live distribution. If you have installed the Antykwa Toruńska fonts in your system, then the simpler declaration above should suffice.

enter image description here

If you want to use pdflatex, then the approach with font encodings is necessary:

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[math]{anttor}

\DeclareRobustCommand{\cyr}[1]{%
  {\fontencoding{T2A}\selectfont#1}%
}

\begin{document}
text $math$

Russian: \cyr{Щ}
\end{document}

It's not possible to write Cyrillic characters without changing the font encoding, unfortunately, without extensive work.

5

You don't have to use inputenc and fontenc packages with XeLaTeX, since it already works with Unicode. So you have first to remove the lines:

\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}

Then you have to use fonts which contain Unicode glyphs. The corresponding of Computer Modern (CM) are Computer Modern Unicode (CMU).

If you change your MWE to

\documentclass{article}
\usepackage[no-math]{fontspec}

\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

\begin{document}
text $math$

Russian: Щ
\end{document}

and compile it with XeLaTeX, it should work.

  • And what about anttor? You're overriding it, which is not wanted. – egreg Jun 23 '13 at 9:06
  • @egreg You are right, I forgot to delete that line. Anyway there is your answer now, to explain how to use anttor with XeLaTeX. Thanks for pointing it out. – karlkoeller Jun 23 '13 at 9:57
2

Generally speaking, using inputenc with XeTeX is wrong. XeTeX treats Щ as one Unicode character (U+0429), while pdfTeX treats it as two characters (0xD0, 0xA9) in UTF-8 encoding. That's a big difference.

If you want to typeset Cyrillic letters in XeTeX, it is better to use a Unicode font (TrueType or OpenType) with fontspec package, as karlkoeller said. Not all fonts supports Cyrillic letters. For CM fonts, CMU families are good choices.


It is still possible, however, to use the old T2A fonts.

\XeTeXinputencoding "byte"
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1,T2A]{fontenc}
\usepackage{anttor}
\begin{document}
text $math$

Russian: Щ
\end{document}

But in this case, fontspec is not used at all, and why not use pdfTeX directly?

2

If you just need cyriliic letters in math, try \text{} command from amsmath package. It works with any engine, either (pdf)latex or xelatex.

\documentclass{article}
\usepackage{ifxetex}
\ifxetex
  \usepackage{fontspec}
  \setmainfont{CMU Serif}
  \setsansfont{CMU Sans Serif}
  \setmonofont{CMU Typewriter Text}
\else
  \usepackage[T1,T2A]{fontenc}
  \usepackage[utf8]{inputenc}
\fi
\usepackage[english,russian]{babel}% you need babel 3.9

\begin{document}
\[
\text{Щ}
\]
Russian: Щ
\end{document}

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.