3

Though graphviz' generic dot routine accepts UTF8 and in that respect also umlauts, the latex graphviz package does not. It always generates an error if an umlaut is included in a label (See https://www.overleaf.com/13308817yvjnvkfvcpxy#/51278614/ for example).

\documentclass{standalone}
\usepackage[pdf]{graphviz}

\begin{document}
\digraph{ao}{rankdir=LR; 
   a [label="Ä"]; % graphviz allows double quoted labels
   o [label=<Ö>]; % and html labels
   a->o;}
\end{document}
egreg
  • 1,121,712

1 Answers1

5

The problem is caused by

\usepackage[utf8]{inputenc}

Then, the umlauts consists of active characters that unexpectedly get expanded, when the .dot file is written:

digraph ao {rankdir=LR;
a [label="\unhbox \voidb@x \bgroup \let \unhbox \voidb@x \setbox \@tempboxa \hbox {A\global \mathchardef \accent@spacefactor \spacefactor }\accent 127 A\egroup \spacefactor \accent@spacefactor "]; o [label=<\unhbox \voidb@x \bgroup \let \unhbox \voidb@x \setbox \@tempboxa \hbox {O\global \mathchardef \accent@spacefactor \spacefactor }\accent 127 O\egroup \spacefactor \accent@spacefactor >]; a->o;}

The expansion can be prevented by e-TeX's \detokenize:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[pdf]{graphviz}

\begin{document}
\digraph{ao}{rankdir=LR;
   a [label="\detokenize{Ä}"]; % graphviz allows double quoted labels
   o [label=<\detokenize{Ö}>]; % and html labels
   a->o;}
\end{document}

Then, the file ao.dot preserves the umlauts:

digraph ao {rankdir=LR;
a [label="Ä"]; o [label=<Ö>]; a->o;}

The result:

Result

Heiko Oberdiek
  • 271,626
  • Thanks a lot. That answer solved the problem.

    Besides, It would help to reuse this answer if it were possible to add some more relevant tags. I'm not allowed to add tags like 'umlaut' or 'graphviz' that would be more appropriate.

    – user1491229 Jan 20 '18 at 17:43