Setting Math in Adobe Illustrator: The Impossible Dream

A while back, I posted on social media:

I did not suspect, Gentle Reader, just how many people would have questions about this, nor how many of them there would be. Especially over on Quora, where it raised quite an interesting discussion.

So, in the interests of elaborating, so that I can refer people to this entry:

The equation is real. It’s the Higgs field Lagrangian, the equation that describes how the Higgs gives mass to massive particles. (On a side note, the Higgs field is only a small part of the inertial mass of everyday objects; more than 90% of the mass of things in our normal world comes not from the Higgs, but from the binding energy in the particles that make up those things).

I needed the Higgs Lagrangian for a porn novel Eunice and I are planning but haven’t yet started working on. Specifically, I’m noodling about with an image for that novel, and I needed the Higgs Lagrangian in Adobe Illustrator.

This is the image I’m noodling about with. Everything here, including the face, is vector, built entirely in Illustrator, not raster.

If you look at the largest gold band, that’s the Higgs Lagrangian.

I realize that Illustrator is not in fact an appropriate tool for typesetting math. The proper tool for this is LaTeX; indeed, it’s what LaTeX was created for. And I did in fact originally create the equation in LaTeX, and exported it to SVG to place in Illustrator.

Thereupon I found a problem.

I want to set the equation on a curve. And it is indeed possible to set an image like a PDF or SVG placed into Illustrator on a curve.

But Illustrator treats placed images as, well images, which means if you set them along a curve, it will distort them.

Here’s what I mean. On the top, the Higgs Lagrangian set as type in Illustrator, which did in fact take me about two hours to do; below that, exported from LaTeX; and below that, exported from LaTeX and placed on a curve.

And honestly that would simply not do.

So I set it as type in Illustrator. That required, among other things, installing a typesetting font on my computer to use in Illustrator (New Computer Modern, available here, just in case any other Illustrator users should run into a problem typesetting math equations in Illustrator and stumble across this post in the future), and frequent trips to the Wikipedia list of mathematical symbols here to copy-paste characters into Illustrator in New Computer Modern Math Regular).

I did all this because getting the equation set as type in Illustrator meant I could use Illustrator’s type on a path tool to curve the type while perfectly preserving the shape of each letter.

This also meant it would print smoothly as vectors. I could bend the type in a different graphics program, but any raster (pixel) program would break the letters up into pixels, meaning they look slightly fuzzy on press.

Illustrator’s math typesetting is, bluntly, nonexistent. Which honestly surprises me. I’ve used Illustrator since 1988 and the fact it doesn’t have any typesetting library for math still surprises me. They could, for instance, easily license, oh, I don’t know, something like LaTeX…but I digress.

You can do superscripts and subscripts, but it treats them as text in a line, like X2adoesn’t work correctly on superscripts and subscripts that have to be aligned one right under the other. For that, I had to type the superscript, type the subscript, and set the superscript’s tracking to -1000 to scoot it over the subscript. Big pain in the ass.

The whole equation took a ton of ugly hackery like that (and if you’re reading this because it’s six years after I wrote it and you’re searching for a way to set math in Illustrator, you’re welcome, and also, cry havoc, you mad bastard).

Anyway, I got it done, if not perfectly than at least acceptably, but my god, those are hours of my life I’ll never have back.

2 thoughts on “Setting Math in Adobe Illustrator: The Impossible Dream

  1. Another way is to use the TikZ package in LaTex to write the text along a curve. The standalone class can create a pdf of precisely the size of the graphic. Since LaTeX generated PDFs have a transparent background, you just drag and drop the pdf into Illustrator. Here’s the LaTeX code (it wasn’t easy, though; for example, a^b has to be enclosed in curly braces {a^b}. Same for subscripts. Same for spaces \, and so on. I still think it was a lot faster!)

    \documentclass[border=0.2cm, tikz]{standalone}
    \usetikzlibrary{decorations.text}
    \begin{document}
    \begin{tikzpicture}
    \path[decoration={text along path,
    text={${\mathcal{L}_H}{\,}={\,}[({\partial_\mu}{\,}-{\,}ig{W^a_{\,\mu}}{t^a}{\,}-{\,}ig'{Y_\Phi}{B_\mu}){\phi}{]^2}{\,}+{\,}{\mu^2}{\phi^{\dagger}}{\phi}{\,}-{\,}{\lambda}({\phi^{\dagger}}{\phi}{)^2}$},
    text align={center},raise=0cm}, decorate] % modify the raise if required
    (0,0) arc (180:360:5cm); % arc beginning at (0,0), arc angle going from 180 deg to 360 deg, arc radius 5 cm
    \end{tikzpicture}
    \end{document}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.