在拉丁字符短语中添加西里尔字符 е

在拉丁字符短语中添加西里尔字符 е

我打算在拉丁字符的句子中间多次添加 unicode 字符 U+0435。有什么快速且简单的代码方法可以做到这一点吗?谢谢!

例子:

\begin{document}
Adding the cyrillic character е in this sentence crashes 
the document so I have to delete the character е.
\end{document}

答案1

您必须声明支持西里尔字母的字体编码,例如 T2A。然后,由于生成字符的命令没有默认编码(出于效率原因),您必须为所需的字符添加它。

\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}

通常,字母的名称很简单。对于大写字母 Е,其名称为\CYRE等等。您可以在文件 的t2aenc.def第 102-165 行中找到它们。

在此处输入图片描述

一次性启用所有字母的技巧:

\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}

相关内容