# Latex labels for Graphviz (work in progress)

**URL:** https://forum.graphviz.org/t/latex-labels-for-graphviz-work-in-progress/3402
**Category:** Dev
**Created:** [September 3, 2026, 10:54pm UTC](https://forum.graphviz.org/t/latex-labels-for-graphviz-work-in-progress/3402 "2026-09-03T22:54:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![HermannSW](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/hermannsw/32/2158_2.png) [@HermannSW](https://forum.graphviz.org/u/HermannSW)
#### Post date: [September 3, 2026, 10:54pm UTC](https://forum.graphviz.org/t/latex-labels-for-graphviz-work-in-progress/3402/1 "2026-09-03T22:54:51Z")

</div>

A year ago in Linear Algebra 1 lecture (I study Mathematics in my 60s) I created a big structure diagram with Graphviz.

Now I wanted to create a similar structure diagram for Elementary number theory lecture, but hesitated. Reason was that a year ago I had to lookup each and every Latex symbol, determine unicode and use that in Graphviz HTML label. I did not want to do that again.

So I played with Google Gemini (only today) and it had more problems with the code than for mathematical software or GPU code. But after many many iterations now a nice tool implementing the subject line is available:  
[https://gist.github.com/Hermann-SW/12c7644ac0c75b4eb019f76c3f023fe5](https://gist.github.com/Hermann-SW/12c7644ac0c75b4eb019f76c3f023fe5)

More details in the gist, below as teaser just the layout of current gist — I like it.  
This is how easy Latex can be used for Graphviz labels (Latex cases environment does work!):

```auto
...
thm_3_47_label = latex_to_graphviz_html(
r"""\textbf{Thm 3.47 }For cyclic group G:\ G \cong \begin{cases}
\mathbb{Z} & \text{for }G\text{ infinite,}\
\Z /|G|\mathbb{Z} & \text{for }G\text{ finite.} \end{cases}"""
)

ex_3_48_label = latex_to_graphviz_html(
r"""\textbf{Ex 3.48 } (\Z/5\Z)^{\times} \cong \Z/4\Z\ \psi: \begin{cases}
\Z/4\Z &\to\ (\Z/5\Z)^{\times}\
a &\mapsto\ \bar{2}^a \end{cases}\lbr"""
)
...
    thm_3_47 [label={thm_3_47_label}];
    ex_3_48 [label={ex_3_48_label}];
...

```

Layout created:

 ![image](https://global.discourse-cdn.com/graphviz/original/2X/9/97703a8ac70f27119f547fcb27d32de85b9d434d.png)

I did search for similar projects and found some never completed and terminated decades ago.  
Comments/wishes appreciated.

---

<div class="post-metadata">

### Author: ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)
#### Post date: [September 5, 2026, 11:15am UTC](https://forum.graphviz.org/t/latex-labels-for-graphviz-work-in-progress/3402/2 "2026-09-05T11:15:51Z")

</div>

Cool!

---

<div class="post-metadata">

### Author: ![HermannSW](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/hermannsw/32/2158_2.png) [@HermannSW](https://forum.graphviz.org/u/HermannSW)
#### Post date: [September 7, 2026, 1:31am UTC](https://forum.graphviz.org/t/latex-labels-for-graphviz-work-in-progress/3402/5 "2026-09-07T01:31:21Z")

</div>

Yes — I continued and completed adding (translated) sections 3.3 “prime residue classes and Fermat-Euler theorem” and 3.4 “cyclic groups” of (German language) lecture script sitting behind Heidelberg University VPN. From definition 3.13 until theorem 3.49.

If X is referred to in Y, solid edge X-\>Y is added.

For eg. propositions with no incoming edges I determined dotted edge where reference in script text is missing. For nodes having no outgoing edges, I added at most two dotted links, one to next example where applicable, and one for proposition/theorem/corollary if applicable.

Below is 10× scaled down screenshot, and created PDF.

In browser all labels look nice for me with 75% scaling. Searching for eg. “ord(” gives 7 hits, and clicking on one of them on left list moves view to corresponding node. Really useful for working with that graph! The gist from initial post was updated.

> **[prime\_residue\_classess\_and\_Fermat-Euler\_theorem.cyclic\_groups.pdf](https://stamm-wilbrandt.de/prime_residue_classess_and_Fermat-Euler_theorem.cyclic_groups.pdf)**
>
> 42.48 KB

 ![image](https://global.discourse-cdn.com/graphviz/original/2X/f/fcd92b95125c766225e857117d8da166d3b82781.png)
