[Tex/LaTex] dot2tex and math mode

graphsmath-mode

I have successfully installed dot2texi but I'm facing an issue with the math mode. The sign (_) in math mode works fine however other symbols do not work. For example it ignores the bar over b in the following example.

\documentclass{article}

\usepackage{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\makeatletter
\@ifundefined{verbatim@out}{\newwrite\verbatim@out}{}
\makeatother
\begin{document}
\begin{dot2tex}[tikz,options=-t math]
digraph G {
a\bar{b} -> c;
}
\end{dot2tex}

\end{document}

is there anyway to fix this? Also, is it possible to write regular LaTeX and $$ in the dot2texi without worring about define it as math/verbatim/raw mode.

Best Answer

You are not using correct dot language.

Underscores in node names work fine indeed, as node names have to consist of digits, letters, and underscores, not starting with a digit. Your graph defines nodes a, bar, b, and c, where b is contained in a subgraph.

What you actually want to achieve is probably:

\documentclass{article}

\usepackage{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\makeatletter
\@ifundefined{verbatim@out}{\newwrite\verbatim@out}{}
\makeatother

\begin{document}
\begin{dot2tex}[tikz,options=-t math]
digraph G {
n0[label="a\bar{b}"];
n0 -> c;
}
\end{dot2tex}
\end{document}

which yields

sample output

Regarding your second question, you can put LaTeX commands, including math stuff ($...$) in any label if you add them as texlbl attributes, see the dot2tex manual for details. But remember that the graph must still be defined in valid dot language.

Related Question