当我将主要语言切换为俄语时polyglossia
出现此错误:
! Package polyglossia Error: The current roman font does not contain the Cyrillic script!
(polyglossia) Please define \cyrillicfont with \newfontfamily.
See the polyglossia package documentation for explanation.
我尝试添加:
\newfontfamily\cyrillicfont{Arial}
但它不起作用。
那么如何让它发挥作用呢?
梅威瑟:
\documentclass{article}
\usepackage{xparse}
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usepackage{tikz-timing}
\NewDocumentEnvironment{mytiming}{smmmmmO{}}{%
\IfBooleanT {#1}{
}%
\begin{pgfonlayer}{background}
\node [above = 1.5ex of #3, inner sep = 0, outer sep = 0](T1){};
\node [above = 1.5ex of #5, inner sep = 0, outer sep = 0](T2){};
\node [above = 0.2ex of T1, inner sep = 0, outer sep = 0](W1){};
\node [above = 0.2ex of T2, inner sep = 0, outer sep = 0](W2){};
\draw [help lines] (#2) -- (T1);
\draw [help lines] (#4) -- (T2);
\draw [arrows = {Stealth[inset=0pt, angle=30:6pt]-Stealth[inset=0pt, angle=30:6pt]}] (W1) -- node[pos=0.5, below = 0.2ex](){#6}(W2);
}{%
\end{pgfonlayer}
}
\ExplSyntaxOn
\cs_new:cpn {mytiming*} {\mytiming*}
\cs_new_eq:cN {endmytiming*} \endmytiming
\ExplSyntaxOff
\setotherlanguage[spelling=modern]{russian}
\setotherlanguage[variant=uk]{english}
%\setmainlanguage{english}
\setmainlanguage{russian}
\newfontfamily\cyrillicfont{Arial}
\begin{document}
\begin{tikztimingtable}
signal & 5L N(D1) 4H N(D2) 2L N(D3) 4L N(D4) 4L N(D5) 5L \\
contactor & 5L N(G1) 4L N(G2) 2H N(G3) 4H N(G4) 4H N(G5) 5L \\
relay contact & 5L N(R1) 4L N(R2) 2L N(R3) 4H N(R4) 4H N(R5) 5L \\
& 5S N(O1) 4S N(O2) 2S N(O3) 4S N(O4) 4S N(O5) 5S \\
\extracode
\begin{mytiming}{D2}{O2}{R3}{O3}{delay}
\draw [help lines] (G5) -- (R5);
\end{mytiming}
\end{tikztimingtable}
\end{document}
答案1
您还必须定义\cyrillicfontsf
和\cyrillicfonttt
。
\documentclass{article}
\usepackage{xparse}
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usepackage{tikz-timing}
\setmainlanguage[spelling=modern]{russian}
\setotherlanguage[variant=uk]{english}
\newfontfamily\cyrillicfont{Arial}
\newfontfamily\cyrillicfontsf{Arial}
\newfontfamily\cyrillicfonttt{cmuntt.otf}
\NewDocumentEnvironment{mytiming}{smmmmmO{}}{%
\IfBooleanT {#1}{
}%
\begin{pgfonlayer}{background}
\node [above = 1.5ex of #3, inner sep = 0, outer sep = 0](T1){};
\node [above = 1.5ex of #5, inner sep = 0, outer sep = 0](T2){};
\node [above = 0.2ex of T1, inner sep = 0, outer sep = 0](W1){};
\node [above = 0.2ex of T2, inner sep = 0, outer sep = 0](W2){};
\draw [help lines] (#2) -- (T1);
\draw [help lines] (#4) -- (T2);
\draw [arrows = {Stealth[inset=0pt, angle=30:6pt]-Stealth[inset=0pt, angle=30:6pt]}] (W1) -- node[pos=0.5, below = 0.2ex](){#6}(W2);
}{%
\end{pgfonlayer}
}
\ExplSyntaxOn
\cs_new:cpn {mytiming*} {\mytiming*}
\cs_new_eq:cN {endmytiming*} \endmytiming
\ExplSyntaxOff
\begin{document}
\begin{tikztimingtable}
signal & 5L N(D1) 4H N(D2) 2L N(D3) 4L N(D4) 4L N(D5) 5L \\
contactor & 5L N(G1) 4L N(G2) 2H N(G3) 4H N(G4) 4H N(G5) 5L \\
relay contact & 5L N(R1) 4L N(R2) 2L N(R3) 4H N(R4) 4H N(R5) 5L \\
& 5S N(O1) 4S N(O2) 2S N(O3) 4S N(O4) 4S N(O5) 5S \\
\extracode
\begin{mytiming}{D2}{O2}{R3}{O3}{delay}
\draw [help lines] (G5) -- (R5);
\end{mytiming}
\end{tikztimingtable}
\end{document}