改善下标和上标在节点标签上的定位

问题描述:

在节点标签上同时使用下标和上标时,可以更改位置使其彼此直接位于上方.

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.

示例:

digraph G {
        x11[label=<X<SUB>1</SUB><SUP>(1)</SUP>>];   
        x21[label=<X<SUB>2</SUB><SUP>(1)</SUP>>];
        x11 -> x21 
    }

哪个生产

是否可以将(#)直接放在#的上方,而不是稍微向右移?谢谢

Is it possible to have the (#) directly above the # rather than slightly to the right? thanks

我尝试添加自定义css脚本(例如:到我的dot脚本中(例如:使用CSS类在Graphviz上的HTML标签中),但是它会返回错误

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

错误:第1行上的未知HTML元素<span>

Graphviz的类似于HTML的本机HTML节点呈现非常有限. Graphviz文档清楚地说了这一点.我不相信有什么办法可以哄它去做您想要的事情.即使有一种方法可以调整例如<table>定义可能会导致结果看起来很糟糕.

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.

因此,我建议您查看 dot2tex .它的全部目的是允许LaTeX具有渲染节点的全部功能.设置并非易事,但结果值得.

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.

这是一个页面,其中显示了包含LaTeX-在节点中设置数学.

Here's a page showing examples of graphs containing LaTeX-set math in nodes.

您没有说输出应该是什么.但是,有一些方法可以将LaTeX转换为许多不同的形式.最简单的是Postscript和PDF.但是图像格式也是可以的.

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.

添加

好的,我安装了dot2tex,结果如下:

Okay I installed dot2tex, and here's a result:

以下是相应的dot代码:

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

我用

$ dot2tex foo.gv -f tikz > foo.tex
$ pdflatex foo.tex

由于您已经在使用LaTeX,因此应该可以对其进行调整以满足您的确切要求,而不会带来太多麻烦.

Since you're already using LaTeX, you should be able to adjust this to meet your exact requirements without much trouble.