dot2tex
dot2tex copied to clipboard
support headlabel and taillabel under tikzedgelabels
As documented in https://dot2tex.readthedocs.io/en/latest/customization_guide.html#customizing-edges
The headlabel and taillabel attributes are currently not affected by the tikzedgelabels option.
Can this support be added? While creating network diagrams, I am trying to add both ends of the interface as head/tail label. The Graphviz does not support rotating any label. But dot2tex can support this (and fairly easily)
Possible Solution:
Currently the generated Latex file will have the following if lblstyle='above, sloped'
is configured in dot Graph file.
\draw [] (53.916bp,143.83bp) .. controls (48.5bp,133.0bp) and (41.644bp,119.29bp) .. (36.207bp,108.41bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (44.195bp,136.83bp) node[above, sloped] {Et2};
\draw (26.486bp,115.41bp) node[above, sloped] {Et1};
based on the co-ordinates used to draw the line i.e (53.916bp,143.83bp)
and (36.207bp,108.41bp)
, we can calculate the angle of the line using: math.degrees(math.atan2((53.916,143.83),(36.207,108.41))
using this angle, we can update the above Latex to include the angle (rotate=<degrees calculated>
):
\draw [] (53.916bp,143.83bp) .. controls (48.5bp,133.0bp) and (41.644bp,119.29bp) .. (36.207bp,108.41bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (44.195bp,136.83bp) node[rotate=63.43] {Et2};
\draw (26.486bp,115.41bp) node[rotate=63.43] {Et1};