# How to typeset Cyrillic characters in tikzpicture nodes?

So I have this tikzpicture environment (dot2texi-generated):

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


with Cyrillic "а" and "б" nodes. pdfLaTeX, though, gives me the following error:

! Missing \endcsname inserted.
<to be read again>
\T2A\cyra
l.4 \node (а) at (5bp,51bp) [draw,ellipse] {а};


So the question is: how to use Cyrillic characters in tikzpicture nodes?

UPD:

I should've actually include contents of original dot2tex environment. Andrey has given the basic idea of a possible solution: instead of

\begin{dot2tex}[]
digraph { "а" -> "б" };
\end{dot2tex}


one can use:

\begin{dot2tex}[]
digraph { a [label="а"]; b [label="б"]; a -> b }
\end{dot2tex}

-
You can't use Cyrillic characters in node names with pdfTeX. See this answer for a more elaborate discussion and possible solution: tex.stackexchange.com/questions/24969/… – Andrey Vihrov Nov 11 '11 at 11:34
<sub>Too long for a comment</sub> You can't use special characters in the node names because they must be used in contexts where TeX needs to see only string of characters, while a cyrillic б, for instance, is translated by LaTeX into its internal representation, which is \cyrb, which in turn is subject to further processing that ultimately is transformed into \char"E1 (where hexadecimal E1 is the letter position in the T2A encoding) and this is disallowed in those contexts. This wouldn't happen with a Unicode savvy engine such as xelatex or lualatex. – egreg Nov 11 '11 at 13:22
You can post your addition as a self-answer; I've added another comment which tries to explain what's going on. – egreg Nov 11 '11 at 13:41
Will do (I have to wait 8 hours to post answers to my own questions until I have 100 rep). – Egor Tensin Nov 11 '11 at 15:56

You should distinguish between a node name and a node label. The first is how TeX references a node, and must be in ASCII. The second is how TeX presents the node, and may be anything TeX understands. See here:

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


-
I had thoughts on posting my addition to the question as a self-answer, but your explanation is much more detailed. – Egor Tensin Nov 11 '11 at 19:51