I recently found myself typesetting equations on a sphere (if you need to know – preview for an eggbot), and that got me thinking it would be nice to be able to have content follow an arbitrary path (2D), like tikz decoration library does, but also for maths. Maybe that’s one for Cetz, or maybe it’s a core thing?
A quote from Text along/on a path · Issue #395 · cetz-package/cetz · GitHub :
This isn’t easily possible without extra support from the Typst compiler. You could try and break up content but it would be tricky to rotate each piece correctly while keeping styling correct and would break very easily.
My suggestion is to just patiently wait. But if you absolutely need this, then you obviously can do this. It’s just that it will be pretty hard to implement, at least for general purpose. But I think for the most basic/narrow use case (e.g., no styling) it shouldn’t take too long to have a working prototype.
You could achieve text along a path by creating an SVG file that uses the textPath
feature of SVG. However, this doesn’t support math equations, so it’s somewhat limited.
It looks like postscript had some pretty decent support for this kind of thing, e.g.
\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{pst-text}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psset{linestyle=none}
\pstextpath[l](0,0){%
\parametricplot[plotstyle=curve,%
plotpoints=500]{0}{5000}{%
/r {t 600 div} def t sin r mul t cos r mul }
}{$- \frac{1}{2}\partial_{\nu}g_{\mu}^{a}\partial_{\nu}g_{\mu}^{a} - g_{s}f^{abc}\partial_{\mu}g_{\nu}^{a}g_{\mu}^{b}g_{\nu}^{c} - \frac{1}{4}g_{s}^{2}f^{abc}f^{ade}g_{\mu}^{b}g_{\nu}^{c}g_{\mu}^{d}g_{\nu}^{e} + \frac{1}{2}ig_{s}^{2}\left( {q_{i}^{- }}^{\sigma}\gamma^{\mu}q_{j}^{\sigma} \right)g_{\mu}^{a} + {G^{- }}^{a}\partial^{2}G^{a} + g_{s}f^{abc}\partial_{\mu}{G^{- }}^{a}G^{b}g_{\mu}^{c} - \partial_{\nu}W_{\mu}^{+}\partial_{\nu}W_{\mu}^{-} - M^{2}W_{\mu}^{+}W_{\mu}^{-} - \frac{1}{2}\partial_{\nu}Z_{\mu}^{0}\partial_{\nu}Z_{\mu}^{0} - \frac{1}{2c_{w}^{2}}M^{2}Z_{\mu}^{0}Z_{\mu}^{0} - \frac{1}{2}\partial_{\mu}A_{\nu}\partial_{\mu}A_{\nu} - \frac{1}{2}\partial_{\mu}H\partial_{\mu}H - \frac{1}{2}m_{h}^{2}H^{2} - \partial_{\mu}\phi^{+}\partial_{\mu}\phi^{-} - M^{2}\phi^{+}\phi^{-} - \frac{1}{2}\partial_{\mu}\phi^{0}\partial_{\mu}\phi^{0} - \frac{1}{2c_{w}^{2}}M\phi^{0}\phi^{0} - \beta_{h}\left\lbrack \frac{2M^{2}}{g^{2}} + \frac{2M}{g}H + \frac{1}{2}\left( H^{2} + \phi^{0}\phi^{0} + 2\phi^{+}\phi^{-} \right) \right\rbrack + \frac{2M^{4}}{g^{2}}\alpha_{h} - igc_{w}\left\lbrack \partial_{\nu}Z_{\mu}^{0}\left( W_{\mu}^{+}W_{\nu}^{-} - W_{\nu}^{+}W_{\mu}^{-} \right) - Z_{\nu}^{0}\left( W_{\mu}^{+}\partial_{\nu}W_{\mu}^{-} - W_{\mu}^{-}\partial_{\nu}W_{\mu}^{+} \right) + Z_{\mu}^{0}\left( W_{\nu}^{+}\partial_{\nu}W_{\mu}^{-} - W_{\nu}^{-}\partial_{\nu}W_{\mu}^{+} \right) \right\rbrack - igs_{w}\left\lbrack \partial_{\nu}A_{\mu}\left( W_{\mu}^{+}W_{\nu}^{-} - W_{\nu}^{+}W_{\mu}^{-} \right) - A_{\nu}\left( W_{\mu}^{+}\partial_{\nu}W_{\mu}^{-} - W_{\mu}^{-}\partial_{\nu}W_{\mu}^{+} \right) + A_{\mu}\left( W_{\nu}^{+}\partial_{\nu}W_{\mu}^{-} - W_{\nu}^{-}\partial_{\nu}W_{\mu}^{+} \right) \right\rbrack - \frac{1}{2}g^{2}W_{\mu}^{+}W_{\mu}^{-}W_{\nu}^{+}W_{\nu}^{-} + \frac{1}{2}g^{2}W_{\mu}^{+}W_{\nu}^{-}W_{\mu}^{+}W_{\nu}^{-} + g^{2}c_{w}^{2}\left( Z_{\mu}^{0}W_{\mu}^{+}Z_{\nu}^{0}W_{\nu}^{-} - Z_{\mu}^{0}Z_{\mu}^{0}W_{\nu}^{+}W_{\nu}^{-} \right) + g^{2}s_{w}^{2}\left( A_{\mu}W_{\mu}^{+}A_{\nu}W_{\nu}^{-} - A_{\mu}A_{\mu}W_{\nu}^{+}W_{\nu}^{-} \right) + g^{2}s_{w}c_{w}\left\lbrack A_{\mu}Z_{\nu}^{0}\left( W_{\mu}^{+}W_{\nu}^{-} - W_{\nu}^{+}W_{\mu}^{-} \right) - 2A_{\mu}Z_{\mu}^{0}W_{\nu}^{+}W_{\nu}^{-} \right\rbrack - g\alpha\left\lbrack H^{3} + H\phi^{0}\phi^{0} + 2H\phi^{+}\phi^{-} \right\rbrack - \frac{1}{8}g^{2}\alpha_{h}\left\lbrack H^{4} + \left( \phi^{0} \right)^{4} + 4\left( \phi^{+}\phi^{-} \right)^{2} + 4\left( \phi^{0} \right)^{2}\phi^{+}\phi^{-} + 4H^{2}\phi^{+}\phi^{-} + 2\left( \phi^{0} \right)^{2}H^{2} \right\rbrack - gMW_{\mu}^{+}W_{\mu}^{-}H - \frac{1}{2}g\frac{M}{c_{w}^{2}}Z_{\mu}^{0}Z_{\mu}^{0}H - \frac{1}{2}ig\left\lbrack W_{\mu}^{+}\left( \phi^{0}\partial_{\mu}\phi^{-} - \phi^{-}\partial_{\mu}\phi^{0} \right) - W_{\mu}^{-}\left( \phi^{0}\partial_{\mu}\phi^{+} - \phi^{+}\partial_{\mu}\phi^{0} \right) \right\rbrack + \frac{1}{2}g\left\lbrack W_{\mu}^{+}\left( H\partial_{\mu}\phi^{-} - \phi^{-}\partial_{\mu}H \right) - W_{\mu}^{-}\left( H\partial_{\mu}\phi^{+} - \phi^{+}\partial_{\mu}H \right) \right\rbrack + \frac{1}{2}g\frac{1}{c_{w}}(Z_{\mu}^{0}\left( H\partial_{\mu}\phi^{0} - \phi^{0}\partial_{\mu}H \right) - ig\frac{s_{w}^{2}}{c_{w}}MZ_{\mu}^{0}\left( W_{\mu}^{+}\phi^{-} - W_{\mu}^{-}\phi^{+} \right) + igs_{w}MA_{\mu}\left( W_{\mu}^{+}\phi^{-} - W_{\mu}^{-}\phi^{+} \right) - ig\frac{1 - 2c_{w}^{2}}{2c_{w}}Z_{\mu}^{0}\left( \phi^{+}\partial_{\mu}\phi^{-} - \phi^{-}\partial_{\mu}\phi^{+} \right) + igs_{w}A_{\mu}\left( \phi^{+}\partial_{\mu}\phi^{-} - \phi^{-}\partial_{\mu}\phi^{+} \right) - \frac{1}{4}g^{2}W_{\mu}^{+}W_{\mu}^{-}\left\lbrack H^{2} + \left( \phi^{0} \right)^{2} + 2\phi^{+}\phi^{-} \right\rbrack - \frac{1}{4}g^{2}\frac{1}{c_{w}^{2}}Z_{\mu}^{0}Z_{\mu}^{0}\left\lbrack H^{2} + \left( \phi^{0} \right)^{2} + 2\left( 2s_{w}^{2} - 1 \right)^{2}\phi^{+}\phi^{-} \right\rbrack - \frac{1}{2}g^{2}\frac{s_{w}^{2}}{c_{w}}Z_{\mu}^{0}\phi^{0}\left( W_{\mu}^{+}\phi^{-} + W_{\mu}^{-}\phi^{+} \right) - \frac{1}{2}ig^{2}\frac{s_{w}^{2}}{c_{w}}Z_{\mu}^{0}H\left( W_{\mu}^{+}\phi^{-} - W_{\mu}^{-}\phi^{+} \right) + \frac{1}{2}g^{2}s_{w}A_{\mu}\phi^{0}\left( W_{\mu}^{+}\phi^{-} + W_{\mu}^{-}\phi^{+} \right) + \frac{1}{2}ig^{2}s_{w}A_{\mu}H\left( W_{\mu}^{+}\phi^{-} - W_{\mu}^{-}\phi^{+} \right) - g^{2}\frac{s_{w}}{c_{w}}\left( 2c_{w}^{2} - 1 \right)Z_{\mu}^{0}A_{\mu}\phi^{+}\phi^{-} - g^{1}s_{w}^{2}A_{\mu}A_{\mu}\phi^{+}\phi^{-} - {e^{- }}^{\lambda}\left( \gamma\partial + m_{e}^{\lambda} \right)e^{\lambda} - {\nu^{- }}^{\lambda}\gamma\partial\nu^{\lambda} - {u_{j}^{- }}^{\lambda}\left( \gamma\partial + m_{u}^{\lambda} \right)u_{j}^{\lambda} - {d_{j}^{- }}^{\lambda}\left( \gamma\partial + m_{d}^{\lambda} \right)d_{j}^{\lambda} + igs_{w}A_{\mu}\left\lbrack - \left( {e^{- }}^{\lambda}\gamma^{\mu}e^{\lambda} \right) + \frac{2}{3}\left( {u_{j}^{- }}^{\lambda}\gamma^{\mu}u_{j}^{\lambda} \right) - \frac{1}{3}\left( {d_{j}^{- }}^{\lambda}\gamma^{\mu}d_{j}^{\lambda} \right) \right\rbrack + \frac{ig}{4c_{w}}Z_{\mu}^{0}\left\lbrack \left( {\nu^{- }}^{\lambda}\gamma^{\mu}\left( 1 + \gamma^{5} \right)\nu^{\lambda} \right) + \left( {e^{- }}^{\lambda}\gamma^{\mu}\left( 4s_{w}^{2} - 1 - \gamma^{5} \right)e^{\lambda} \right) + \left( {u_{j}^{- }}^{\lambda}\gamma^{\mu}\left( \frac{4}{3}s_{w}^{2} - 1 - \gamma^{5} \right)u_{j}^{\lambda} \right) + \left( {d_{j}^{- }}^{\lambda}\gamma^{\mu}\left( 1 - \frac{8}{3}s_{w}^{2} - \gamma^{5} \right)d_{j}^{\lambda} \right) \right\rbrack + \frac{ig}{2\sqrt{2}}W_{\mu}^{+}\left\lbrack \left( {\nu^{- }}^{\lambda}\gamma^{\mu}\left( 1 + \gamma^{5} \right)e^{\lambda} \right) + \left( {u_{j}^{- }}^{\lambda}\gamma^{\mu}\left( 1 + \gamma^{5} \right)C_{\lambda\kappa}d_{j}^{\kappa} \right) \right\rbrack + \frac{ig}{2\sqrt{2}}W_{\mu}^{-}\left\lbrack \left( {e^{- }}^{\lambda}\gamma^{\mu}\left( 1 + \gamma^{5} \right)\nu^{\lambda} \right) + \left( {d_{j}^{- }}^{\kappa}C_{\lambda\kappa}^{\dagger}\gamma^{\mu}\left( 1 + \gamma^{5} \right)u_{j}^{\lambda} \right) \right\rbrack + \frac{ig}{2\sqrt{2}}\frac{m_{e}^{\lambda}}{M}\left\lbrack - \phi^{+}\left( {\nu^{- }}^{\lambda}\left( 1 - \gamma^{5} \right)e^{\lambda} \right) + \phi^{-}\left( {e^{- }}^{\lambda}\left( 1 + \gamma^{5} \right)\nu^{\lambda} \right) \right\rbrack - \frac{g}{2}\frac{m_{e}^{\lambda}}{M}\left\lbrack H\left( {e^{- }}^{\lambda}e^{\lambda} \right) + i\phi^{0}\left( {e^{- }}^{\lambda}\gamma^{5}e^{\lambda} \right) \right\rbrack + \frac{ig}{2M\sqrt{2}}\phi^{+}\left\lbrack - m_{d}^{\kappa}\left( {u_{j}^{- }}^{\lambda}C_{\lambda\kappa}\left( 1 - \gamma^{5} \right)d_{j}^{\kappa} \right) + m_{u}^{\lambda}({u_{j}^{- }}^{\lambda}C_{\lambda\kappa}\left( 1 + \gamma^{5} \right)d_{j}^{\kappa} \right\rbrack + \frac{ig}{2M\sqrt{2}}\phi^{-}\left\lbrack m_{d}^{\lambda}\left( {d_{j}^{- }}^{\lambda}C_{\lambda\kappa}^{\dagger}\left( 1 + \gamma^{5} \right)u_{j}^{\kappa} \right) - m_{u}^{\kappa}({d_{j}^{- }}^{\lambda}C_{\lambda\kappa}^{\dagger}\left( 1 - \gamma^{5} \right)u_{j}^{\kappa} \right\rbrack - \frac{g}{2}\frac{m_{u}^{\lambda}}{M}H\left( {u_{j}^{- }}^{\lambda}u_{j}^{\lambda} \right) - \frac{g}{2}\frac{m_{d}^{\lambda}}{M}H\left( {d_{j}^{- }}^{\lambda}d_{j}^{\lambda} \right) + \frac{ig}{2}\frac{m_{u}^{\lambda}}{M}\phi^{0}\left( {u_{j}^{- }}^{\lambda}\gamma^{5}u_{j}^{\lambda} \right) - \frac{ig}{2}\frac{m_{d}^{\lambda}}{M}\phi^{0}\left( {d_{j}^{- }}^{\lambda}\gamma^{5}d_{j}^{\lambda} \right) + {X^{- }}^{+}\left( \partial^{2} - M^{2} \right)X^{+} + {X^{- }}^{-}\left( \partial^{2} - M^{2} \right)X^{-} + X^{(- )^{0}}\left( \partial^{2} - \frac{M^{2}}{c_{w}^{2}} \right)X^{0} + Y^{- }\partial^{2}Y + igc_{w}W_{\mu}^{+}\left( \partial_{\mu}X^{(- )^{0}}X^{-} - \partial_{\mu}{X^{- }}^{+}X^{0} \right) + igs_{w}W_{\mu}^{+}\left( \partial_{\mu}Y^{- }X^{-} - \partial_{\mu}{X^{- }}^{+}Y \right) + igc_{w}W_{\mu}^{-}\left( \partial_{\mu}{X^{- }}^{-}X^{0} - \partial_{\mu}X^{(- )^{0}}X^{+} \right) + igs_{w}W_{\mu}^{-}\left( \partial_{\mu}{X^{- }}^{-}Y - \partial_{\mu}Y^{- }X^{+} \right) + igc_{w}Z_{\mu}^{0}\left( \partial_{\mu}{X^{- }}^{+}X^{+} - \partial_{\mu}{X^{- }}^{-}X^{-} \right) + igs_{w}A_{\mu}\left( \partial_{\mu}{X^{- }}^{+}X^{+} - \partial_{\mu}{X^{- }}^{-}X^{-} \right) - \frac{1}{2}gM\left\lbrack {X^{- }}^{+}X^{+}H + {X^{- }}^{-}X^{-}H + \frac{1}{c_{w}^{2}}X^{(- )^{0}}X^{0}H \right\rbrack + \frac{1 - 2c_{w}^{2}}{2c_{w}}igM\left\lbrack {X^{- }}^{+}X^{0}\phi^{+} - {X^{- }}^{-}X^{0}\phi^{-} \right\rbrack + \frac{1}{2c_{w}}igM\left\lbrack X^{(- )^{0}}X^{-}\phi^{+} - X^{(- )^{0}}X^{+}\phi^{-} \right\rbrack + igMs_{w}\left\lbrack X^{(- )^{0}}X^{-}\phi^{+} - X^{(- )^{0}}X^{+}\phi^{-} \right\rbrack + \frac{1}{2}igM\left\lbrack {X^{- }}^{+}X^{+}\phi^{0} - {X^{- }}^{-}X^{-}\phi^{0} \right\rbrack$}
\end{pspicture}
\end{document}
As a moderation note:
I have changed the title from “Glyphs typeset along a path” to " How to typeset glyphs along a path?".
The question guidelines recommend this:
Good titles are questions you would ask your friend about Typst.
For this question, you were already there: it was easy to reformulate the title into a question so that’s what I did.
Also remember to mark the answer that helped you resolve your problem as a Solution using the icon. Don’t feel pressed to do though if there hasn’t been a good solution so far!
I wonder what demons does this protect from…
Maybe Laplace’s or Maxwell’s.