Latex graphviz 包不接受变音符号

Latex graphviz 包不接受变音符号

尽管 graphviz 的通用点例程接受 UTF8 并且在这方面也接受变音符号,但 latex graphviz 包却不接受。如果标签中包含变音符号,它总是会产生错误(参见https://www.overleaf.com/13308817yvjnvkfvcpxy#/51278614/例如)。

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

答案1

问题是由于

\usepackage[utf8]{inputenc}

.dot然后,变音符号由活动字符组成,当写入文件时,这些字符会意外地扩展:

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

可以通过 e-TeX 的方法来阻止这种扩展\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}

然后,文件ao.dot会保留变音符号:

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

结果:

结果

相关内容