When using both subscript and superscripts on a node label, is it possible to alter the positioning so that they are directly above each other.
Example:
digraph G {
x11[label=<X<SUB>1</SUB><SUP>(1)</SUP>>];
x21[label=<X<SUB>2</SUB><SUP>(1)</SUP>>];
x11 -> x21
}
Which produces
Is it possible to have the (#)
directly above the #
rather than slightly to the right? thanks
I tried to add a custom css
script (re: HTML: can I place subscript text right under the superscript?)
to my dot
script with stylesheet = "styles.css";
(re: Using CSS classes in HTML labels on Graphviz), however, it it returns an error
Error: Unknown HTML element
<span>
on line 1
The native HTML-like node rendering of Graphviz is quite limited. The Graphviz docs say this clearly. I don't believe there's a way to coax it to do what you want. Even if there is a way to tweak e.g. a <table>
definition to do it, the results are likely to look bad.
Therefore, I recommend you look at dot2tex. Its whole purpose is to allow the full power of LaTeX for rendering nodes. Setup isn't trivial, but results are worth it.
Here's a page showing examples of graphs containing LaTeX-set math in nodes.
You didn't say what the output should be. But there are ways to convert LaTeX to many different forms. Easiest are Postscript and PDF. But images formats are also possible.
Addition
Okay I installed dot2tex, and here's a result:
Here's the corresponding dot
code:
digraph G {
a_1 [texlbl="$X_{1}^{(1)}$"];
a_2 [texlbl="$X_{1}^{(2)}$"];
a_3 [texlbl="$X_{1}^{(3)}$"];
a_1-> a_2 -> a_3 -> a_1;
}
I compiled with
$ dot2tex foo.gv -f tikz > foo.tex
$ pdflatex foo.tex
Since you're already using LaTeX, you should be able to adjust this to meet your exact requirements without much trouble.