2

I aim to add the unicode character U+0435 in the middle of a sentence in latin characters multiple times. Any fast and light-code idea to do it? Thanks!

Example:

\begin{document}
Adding the cyrillic character е in this sentence crashes 
the document so I have to delete the character е.
\end{document}
egreg
  • 1,121,712
Leo
  • 115
  • Just like spanish LATEX writers are able to write é á ó characters in the middle of the sentence I wish to use the cyrillic е in the middle of the sentence. – Leo Dec 06 '14 at 14:08

1 Answers1

2

You have to declare a font encoding that supports cyrillic, for instance T2A. Then, as the commands for producing the characters don't have (for efficiency reason) a default encoding, you have to add it for the characters you need.

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

\DeclareTextSymbolDefault{\cyre}{T2A}
\DeclareTextSymbolDefault{\cyrf}{T2A}


\begin{document}
Adding the cyrillic character е in this sentence doesn't crash
the document so I don't have to delete the character е.

It doesn't crash even with ф.
\end{document}

The names of the letters are easy, usually. For the uppercase Е it's \CYRE and so on. You find them in the file t2aenc.def, lines 102–165.

enter image description here

A hack for enabling all letters in one swoop:

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

\begingroup
\makeatletter
\providecommand\@gobblethree[3]{}
\let\DeclareFontEncoding\@gobbletwo
\let\DeclareFontSubstitution\@gobblefour
\let\DeclareTextAccent\@gobblethree
\let\@tempa\@empty
\renewcommand\DeclareTextCommand[2]{\renewcommand\@tempa}
\let\DeclareTextComposite\@gobblefour
\def\DeclareTextSymbol#1{\expandafter\decidecyr\string#1....\decidecyr{#1}}
\def\decidecyr#1#2#3#4#5\decidecyr#6{%
  \lowercase{\def\@tempa{#1#2#3#4}}\edef\@tempb{\string\cyr}%
  \ifx\@tempa\@tempb
    \expandafter\declarecyr\expandafter#6%
  \else
    \expandafter\@gobbletwo
  \fi
}
\newcommand\declarecyr[3]{%
  \toks@=\expandafter{\the\toks@\DeclareTextSymbolDefault{#1}{T2A}}}
\toks@={}
\input{t2aenc.def}
\expandafter\endgroup\the\toks@

\begin{document}
Adding the cyrillic character е in this sentence doesn't crash
the document so I don't have to delete the character е.

It doesn't crash even with ф.
\end{document}
egreg
  • 1,121,712
  • Thank you so much!! I'm getting trouble to understand the code of the t2aenc.def file, could you give me the code lines for this other two characters? һ ν The code worked perfect, 100% solved for the "е" issue – Leo Dec 06 '14 at 14:59
  • @Leo The first is “CYRILLIC SMALL LETTER SHHA” U+04BB, which should work out of the box with the second version; for the first version you need \DeclareTextSymbolDefault{\cyrshha}{T2A}. The second is “GREEK SMALL LETTER NU”, for which you need Greek support. – egreg Dec 06 '14 at 23:05