0

Xelatex, while processing graphviz code doubles the hashmark (#) char before the RGB color specification.

E.g. latex/graphviz code:

\digraph [scale=1]{mygraph} {
  node [color="#365559"]
  a->b
}

Resulting mygraph.dot:

digraph mygraph {
  node [color="##365559"]
  a->b
}

How do I overcome this {bug/feature}, without touching the shell (e.g. sed)?

1 Answers1

0

In the graphviz package a macro is defined that has three arguments: the graph options, the name of the graph file and the contents. Within that macro the content of those arguments is written to a .dot file using the \write command.

LaTeX tries to avoid that the # character inside the contents of a macro argument is seen as an argument itself, therefore the character is doubled. It would be a bit more intuitive in the current use case if the # was treated verbatim instead. However, you can define it as verbatim yourself with the newverbs package (similar to https://tex.stackexchange.com/a/37757) and use that macro in the code for the graph.

MWE:

\documentclass{article}
\usepackage{newverbs}
\usepackage{graphviz}
\begin{document}
\Verbdef\myhash{#}
\digraph [scale=1]{mygraph} {
  node [color="\myhash FF0000"]
  a->b
}
\end{document}

Result:

enter image description here

Marijn
  • 37,699