2

RUN: xelatex book.tex

\documentclass[a5paper,12pt]{book}
\usepackage[X2,T2A,OT2]{fontenc}
\usepackage[english,russian]{babel}
\usepackage{marvosym}
\usepackage{fontspec}
\usepackage{xunicode,xltxtra,url,parskip}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{supertabular}           
\usepackage{titlesec}
\newpagestyle{mystyle}{\setfoot[\thepage][][]{}{}{\thepage}}
\pagestyle{mystyle}

% \defaultfontfeatures{Mapping=tex-text}
% \setmainfont{OldStandard}[
%              Extension=.otf,
%              UprightFont=*-Regular,
%              ItalicFont=*-Italic,
%              BoldItalicFont =*-BoldItalic,
%              BoldFont=*-Bold
% ]
\newcommand{\И}{{\fontencoding{X2}\selectfont\CYRII}} % І
\newcommand{\и}{{\fontencoding{X2}\selectfont\cyrii}} % і
\newcommand{\Е}{{\fontencoding{X2}\selectfont\CYRYAT}} % Ѣ
\newcommand{\е}{{\fontencoding{X2}\selectfont\cyryat}} % ѣ
\newcommand{\Ф}{{\fontencoding{X2}\selectfont\CYROTLD}} % Ө
\newcommand{\ф}{{\fontencoding{X2}\selectfont\cyrotld}} % ө
\newcommand{\Ы}{{\fontencoding{X2}\selectfont\CYRIZH}} % Ѵ
\newcommand{\ы}{{\fontencoding{X2}\selectfont\cyrizh}} % ѵ

\usepackage[absolute]{textpos}
\begin{document}

\И \и \Е \е \Ф \ф \Ы \ы         % IT WORKS with trailing space!
Нар\еч\ие                       % Нарѣчіе, ERROR: Undefined control sequence.

\end{document}

Why aliases , and etc do not work without trailing space? Is it possible to create such kind of alias?

3
  • 1
    Don't use fontencodings like X2 or T2A with xelatex Commented Mar 13, 2020 at 20:10
  • 1
    LaTeX considers all characters until the next non-letter as part of the command, so it is looking for the command \еч followed by the command \ие, which are both undefined. LaTeX is not smart enough to check if there are shorter alternatives if a longer command is not defined (which would make the implementation of the parser much more complex). The space is disregarded when parsing, so the output should be ok when you use Нар\е ч\и е or alternatively Нар\е{}ч\и{}е. But don't do that - XeLaTeX is not designed to use the older fontencodings as @UlrikeFischer said.
    – Marijn
    Commented Mar 13, 2020 at 20:46
  • xelatex is designed to use Unicode fonts but with \usepackage[X2,T2A,OT2]{fontenc} you are forcing legacy 8 and 7 bit encodings so losing almost all the benefits of xetex and making it impossible to get correct hyphenation. It is recommended not to use either xunicode or xltxtra with current xelatex as well. Commented Mar 13, 2020 at 20:51

1 Answer 1

2

You're looking for complications. Here's a working version, provided you use a font with the required glyphs.

\documentclass[a5paper,12pt]{book}
\usepackage[english,russian]{babel}
\usepackage{fontspec}

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

\begin{document}

И и Е е Ф ф Ы ы 

Наречие

Нарѣчіе

\end{document}

enter image description here

The package fontenc may be used, but in very special cases. Don't load xunicode nor xltxtra.

If you are not able to easily input the ancient characters, you could do something like

\newcommand{\И}{І}

but then should be followed by a space, unless you change the category code of И (which might be dangerous). If you like to be bold,

\newcommand{\И}{І} \catcode`И=12

(and similarly for the other characters) might do.

I'd prefer a different approach, namely to define \? that looks for the following character and takes the appropriate action. The list is easily extendable to other combinations.

\documentclass[a5paper,12pt]{book}
\usepackage[english,russian]{babel}
\usepackage{fontspec}

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

\ExplSyntaxOn
\NewDocumentCommand{\?}{m}
 {
  \str_case:nnF { #1 }
   {
    {И}{І} {и}{і}
    {Е}{Ѣ} {е}{ѣ}
    {Ф}{Ѳ} {ф}{ѳ}
    {Ы}{Ѵ} {ы}{ѵ}
   }
   {??}
 }
\ExplSyntaxOff

\begin{document}

\?И\?и\?Е\?е\?Ф\?ф\?Ы\?ы

Наречие

Нарѣчіе

Нар\?еч\?ие

\end{document}

enter image description here

6
  • Does OldStandard have BoldItalic? Commented Mar 13, 2020 at 21:05
  • @OlegLobachev The version I have (TeX Live 2019) does.
    – egreg
    Commented Mar 13, 2020 at 21:23
  • I want to insert \ just before Cyrillic letters и, е or ф because there are no і ѣ, Ө and ѵ on standard keyboard.
    – 111
    Commented Mar 14, 2020 at 5:28
  • @111 OK, I added some suggestions.
    – egreg
    Commented Mar 14, 2020 at 9:14
  • @egreg Thank you a lot! But form of FITA is not appropriate. Is is better to use \newcommand{\Ф}{{\fontencoding{X2}\selectfont\CYROTLD}} % Ө
    – 111
    Commented Mar 14, 2020 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .