![如何在 tikzpicture 节点中排版西里尔字符?](https://linux22.com/image/242470/%E5%A6%82%E4%BD%95%E5%9C%A8%20tikzpicture%20%E8%8A%82%E7%82%B9%E4%B8%AD%E6%8E%92%E7%89%88%E8%A5%BF%E9%87%8C%E5%B0%94%E5%AD%97%E7%AC%A6%EF%BC%9F.png)
所以我有这个 tikzpicture 环境(dot2texi 生成的):
\documentclass{beamer}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}[>=latex,line join=bevel,]
%%
\node (а) at (5bp,51bp) [draw,ellipse] {а};
\node (б) at (5bp,5bp) [draw,ellipse] {б};
\draw [->] (а) ..controls (5bp,39.554bp) and (5bp,29.067bp) .. (б);
%
\end{tikzpicture}
\end{frame}
\end{document}
带有西里尔字母“а”和“б”节点。但是,pdfLaTeX 给出了以下错误:
! Missing \endcsname inserted.
<to be read again>
\T2A\cyra
l.4 \node (а) at (5bp,51bp) [draw,ellipse] {а};
所以问题是:如何在 tikzpicture 节点中使用西里尔字符?
更新型多巴胺:
我实际上应该包含原始dot2tex
环境的内容。Andrey 给出了一个可能的解决方案的基本思路:
\begin{dot2tex}[]
digraph { "а" -> "б" };
\end{dot2tex}
可以使用:
\begin{dot2tex}[]
digraph { a [label="а"]; b [label="б"]; a -> b }
\end{dot2tex}
答案1
您应该区分节点姓名和一个节点标签。第一个是 TeX 如何引用节点,必须使用 ASCII。第二个是 TeX 如何呈现节点,可以是 TeX 能理解的任何内容。参见此处:
\documentclass{beamer}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}[>=latex,line join=bevel,]
%%
\node (Moscow) at (5bp,51bp) [draw,ellipse] {Москва};
\node (SPb) at (5bp,5bp) [draw,ellipse] {Санкт-Петербург};
\draw [->] (Moscow) ..controls (5bp,39.554bp) and (5bp,29.067bp) .. (SPb);
%
\end{tikzpicture}
\end{frame}
\end{document}