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}
5
  • Please, add a minimal example, not a link.
    – egreg
    Commented Jan 20, 2018 at 16:06
  • Works ok for me on mac os with tex live 2017 (after I had done brew install graphviz).
    – Thruston
    Commented Jan 20, 2018 at 16:37
  • Can you also add the error message?
    – egreg
    Commented Jan 20, 2018 at 16:45
  • note the file at overleaf is quite different to the one you show here, please post the error message you get from this file. Commented Jan 20, 2018 at 16:48
  • Well by the help of Heiko's answer I edited the Overleaf code into a working example, that has both the possibility to use double quotes with german babel and umlauts. Thank you. Commented Jan 20, 2018 at 17:53

1 Answer 1

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

1
  • 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. Commented Jan 20, 2018 at 17:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .