使用西里尔字母时出现 fontspec、babel 和 datetime 问题

使用西里尔字母时出现 fontspec、babel 和 datetime 问题

我发现带有俄语 babel 设置的 fontspec 不适用于 datetime 包。我尝试编译这样的代码:

\documentclass[a4paper,11pt]{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[main=russian,english]{babel}
\usepackage{datetime}
\usepackage[cm-default]{fontspec}

\begin{document}
\today
\end{document}

使用 xelatex 并收到错误:Command \cyri unavailable in encoding EU1.

有没有什么办法可以处理呢?

更新:我在 XeLateX 中确实搞砸了字符集。感谢 egreg。我删除了 fontenc 和 inputenc 并使用了一些西里尔字体,所以我的 MWE 现在看起来像这样:

\documentclass[a4paper,11pt]{article}
\usepackage[main=russian,english]{babel}
\usepackage{fontspec}
\setromanfont{PT Sans}
\usepackage{datetime}

\begin{document}
\today
\end{document}

如果我在 babel 中使用俄语作为主要语言,则会出现另一个错误:Undefined control sequence. \\monthnamerussian ...cyrm \cyra \cyrya \or \cyri \cyryu \cyrn \cyrya \or \c...

还是因为 XeLaTeX 吗?

答案1

datetime需要所有这些 \cyrXX 命令的定义。并且您需要一种带有西里尔字符的字体。我使用 t2aenc.dfu 来获取所有名称和号码。我忽略了带有重音符号的命令。它们需要其他 xunicode 定义:

\documentclass[a4paper,11pt]{article}
\usepackage[main=russian,english]{babel}

\usepackage{fontspec}
\setmainfont{Arial Unicode MS}

\DeclareUTFcharacter[\UTFencname]{x0404}{\CYRIE}
\DeclareUTFcharacter[\UTFencname]{x0405}{\CYRDZE}
\DeclareUTFcharacter[\UTFencname]{x0406}{\CYRII}
\DeclareUTFcharacter[\UTFencname]{x0407}{\CYRYI}
\DeclareUTFcharacter[\UTFencname]{x0408}{\CYRJE}
\DeclareUTFcharacter[\UTFencname]{x0409}{\CYRLJE}
\DeclareUTFcharacter[\UTFencname]{x040A}{\CYRNJE}
\DeclareUTFcharacter[\UTFencname]{x040B}{\CYRTSHE}
\DeclareUTFcharacter[\UTFencname]{x040E}{\CYRUSHRT}
\DeclareUTFcharacter[\UTFencname]{x040F}{\CYRDZHE}
\DeclareUTFcharacter[\UTFencname]{x0410}{\CYRA}
\DeclareUTFcharacter[\UTFencname]{x0411}{\CYRB}
\DeclareUTFcharacter[\UTFencname]{x0412}{\CYRV}
\DeclareUTFcharacter[\UTFencname]{x0413}{\CYRG}
\DeclareUTFcharacter[\UTFencname]{x0414}{\CYRD}
\DeclareUTFcharacter[\UTFencname]{x0415}{\CYRE}
\DeclareUTFcharacter[\UTFencname]{x0416}{\CYRZH}
\DeclareUTFcharacter[\UTFencname]{x0417}{\CYRZ}
\DeclareUTFcharacter[\UTFencname]{x0418}{\CYRI}
\DeclareUTFcharacter[\UTFencname]{x0419}{\CYRISHRT}
\DeclareUTFcharacter[\UTFencname]{x041A}{\CYRK}
\DeclareUTFcharacter[\UTFencname]{x041B}{\CYRL}
\DeclareUTFcharacter[\UTFencname]{x041C}{\CYRM}
\DeclareUTFcharacter[\UTFencname]{x041D}{\CYRN}
\DeclareUTFcharacter[\UTFencname]{x041E}{\CYRO}
\DeclareUTFcharacter[\UTFencname]{x041F}{\CYRP}
\DeclareUTFcharacter[\UTFencname]{x0420}{\CYRR}
\DeclareUTFcharacter[\UTFencname]{x0421}{\CYRS}
\DeclareUTFcharacter[\UTFencname]{x0422}{\CYRT}
\DeclareUTFcharacter[\UTFencname]{x0423}{\CYRU}
\DeclareUTFcharacter[\UTFencname]{x0424}{\CYRF}
\DeclareUTFcharacter[\UTFencname]{x0425}{\CYRH}
\DeclareUTFcharacter[\UTFencname]{x0426}{\CYRC}
\DeclareUTFcharacter[\UTFencname]{x0427}{\CYRCH}
\DeclareUTFcharacter[\UTFencname]{x0428}{\CYRSH}
\DeclareUTFcharacter[\UTFencname]{x0429}{\CYRSHCH}
\DeclareUTFcharacter[\UTFencname]{x042A}{\CYRHRDSN}
\DeclareUTFcharacter[\UTFencname]{x042B}{\CYRERY}
\DeclareUTFcharacter[\UTFencname]{x042C}{\CYRSFTSN}
\DeclareUTFcharacter[\UTFencname]{x042D}{\CYREREV}
\DeclareUTFcharacter[\UTFencname]{x042E}{\CYRYU}
\DeclareUTFcharacter[\UTFencname]{x042F}{\CYRYA}
\DeclareUTFcharacter[\UTFencname]{x0430}{\cyra}
\DeclareUTFcharacter[\UTFencname]{x0431}{\cyrb}
\DeclareUTFcharacter[\UTFencname]{x0432}{\cyrv}
\DeclareUTFcharacter[\UTFencname]{x0433}{\cyrg}
\DeclareUTFcharacter[\UTFencname]{x0434}{\cyrd}
\DeclareUTFcharacter[\UTFencname]{x0435}{\cyre}
\DeclareUTFcharacter[\UTFencname]{x0436}{\cyrzh}
\DeclareUTFcharacter[\UTFencname]{x0437}{\cyrz}
\DeclareUTFcharacter[\UTFencname]{x0438}{\cyri}
\DeclareUTFcharacter[\UTFencname]{x0439}{\cyrishrt}
\DeclareUTFcharacter[\UTFencname]{x043A}{\cyrk}
\DeclareUTFcharacter[\UTFencname]{x043B}{\cyrl}
\DeclareUTFcharacter[\UTFencname]{x043C}{\cyrm}
\DeclareUTFcharacter[\UTFencname]{x043D}{\cyrn}
\DeclareUTFcharacter[\UTFencname]{x043E}{\cyro}
\DeclareUTFcharacter[\UTFencname]{x043F}{\cyrp}
\DeclareUTFcharacter[\UTFencname]{x0440}{\cyrr}
\DeclareUTFcharacter[\UTFencname]{x0441}{\cyrs}
\DeclareUTFcharacter[\UTFencname]{x0442}{\cyrt}
\DeclareUTFcharacter[\UTFencname]{x0443}{\cyru}
\DeclareUTFcharacter[\UTFencname]{x0444}{\cyrf}
\DeclareUTFcharacter[\UTFencname]{x0445}{\cyrh}
\DeclareUTFcharacter[\UTFencname]{x0446}{\cyrc}
\DeclareUTFcharacter[\UTFencname]{x0447}{\cyrch}
\DeclareUTFcharacter[\UTFencname]{x0448}{\cyrsh}
\DeclareUTFcharacter[\UTFencname]{x0449}{\cyrshch}
\DeclareUTFcharacter[\UTFencname]{x044A}{\cyrhrdsn}
\DeclareUTFcharacter[\UTFencname]{x044B}{\cyrery}
\DeclareUTFcharacter[\UTFencname]{x044C}{\cyrsftsn}
\DeclareUTFcharacter[\UTFencname]{x044D}{\cyrerev}
\DeclareUTFcharacter[\UTFencname]{x044E}{\cyryu}
\DeclareUTFcharacter[\UTFencname]{x044F}{\cyrya}
\DeclareUTFcharacter[\UTFencname]{x0451}{\cyryo}
\DeclareUTFcharacter[\UTFencname]{x0452}{\cyrdje}
\DeclareUTFcharacter[\UTFencname]{x0454}{\cyrie}
\DeclareUTFcharacter[\UTFencname]{x0455}{\cyrdze}
\DeclareUTFcharacter[\UTFencname]{x0456}{\cyrii}
\DeclareUTFcharacter[\UTFencname]{x0457}{\cyryi}
\DeclareUTFcharacter[\UTFencname]{x0458}{\cyrje}
\DeclareUTFcharacter[\UTFencname]{x0459}{\cyrlje}
\DeclareUTFcharacter[\UTFencname]{x045A}{\cyrnje}
\DeclareUTFcharacter[\UTFencname]{x045B}{\cyrtshe}
\DeclareUTFcharacter[\UTFencname]{x045E}{\cyrushrt}
\DeclareUTFcharacter[\UTFencname]{x045F}{\cyrdzhe}
\DeclareUTFcharacter[\UTFencname]{x0490}{\CYRGUP}
\DeclareUTFcharacter[\UTFencname]{x0491}{\cyrgup}
\DeclareUTFcharacter[\UTFencname]{x0492}{\CYRGHCRS}
\DeclareUTFcharacter[\UTFencname]{x0493}{\cyrghcrs}
\DeclareUTFcharacter[\UTFencname]{x0496}{\CYRZHDSC}
\DeclareUTFcharacter[\UTFencname]{x0497}{\cyrzhdsc}
\DeclareUTFcharacter[\UTFencname]{x0498}{\CYRZDSC}
\DeclareUTFcharacter[\UTFencname]{x0499}{\cyrzdsc}
\DeclareUTFcharacter[\UTFencname]{x049A}{\CYRKDSC}
\DeclareUTFcharacter[\UTFencname]{x049B}{\cyrkdsc}
\DeclareUTFcharacter[\UTFencname]{x049C}{\CYRKVCRS}
\DeclareUTFcharacter[\UTFencname]{x049D}{\cyrkvcrs}
\DeclareUTFcharacter[\UTFencname]{x04A0}{\CYRKBEAK}
\DeclareUTFcharacter[\UTFencname]{x04A1}{\cyrkbeak}
\DeclareUTFcharacter[\UTFencname]{x04A2}{\CYRNDSC}
\DeclareUTFcharacter[\UTFencname]{x04A3}{\cyrndsc}
\DeclareUTFcharacter[\UTFencname]{x04A4}{\CYRNG}
\DeclareUTFcharacter[\UTFencname]{x04A5}{\cyrng}
\DeclareUTFcharacter[\UTFencname]{x04AA}{\CYRSDSC}
\DeclareUTFcharacter[\UTFencname]{x04AB}{\cyrsdsc}
\DeclareUTFcharacter[\UTFencname]{x04AE}{\CYRY}
\DeclareUTFcharacter[\UTFencname]{x04AF}{\cyry}
\DeclareUTFcharacter[\UTFencname]{x04B0}{\CYRYHCRS}
\DeclareUTFcharacter[\UTFencname]{x04B1}{\cyryhcrs}
\DeclareUTFcharacter[\UTFencname]{x04B2}{\CYRHDSC}
\DeclareUTFcharacter[\UTFencname]{x04B3}{\cyrhdsc}
\DeclareUTFcharacter[\UTFencname]{x04B6}{\CYRCHRDSC}
\DeclareUTFcharacter[\UTFencname]{x04B7}{\cyrchrdsc}
\DeclareUTFcharacter[\UTFencname]{x04B8}{\CYRCHVCRS}
\DeclareUTFcharacter[\UTFencname]{x04B9}{\cyrchvcrs}
\DeclareUTFcharacter[\UTFencname]{x04BA}{\CYRSHHA}
\DeclareUTFcharacter[\UTFencname]{x04BB}{\cyrshha}
\DeclareUTFcharacter[\UTFencname]{x04C0}{\CYRpalochka}
\DeclareUTFcharacter[\UTFencname]{x04D4}{\CYRAE}
\DeclareUTFcharacter[\UTFencname]{x04D5}{\cyrae}
\DeclareUTFcharacter[\UTFencname]{x04D8}{\CYRSCHWA}
\DeclareUTFcharacter[\UTFencname]{x04D9}{\cyrschwa}

\usepackage{datetime}
\begin{document}
\today
\end{document}

相关内容