How to combine italic text with superscript in mixed content?

I’m trying to format Vibrio^(ΔACD) where “Vibrio” is italic and “ΔACD” is superscript, but can’t get it to work.

Attempted:

_Vibrio_$^(Delta"ACD")$

Error: “Unexpected hat”

Also tried:

  1. $italic("Vibrio")^(Delta"ACD")$ - Works, but “Vibrio” renders in math font instead of text italic
  2. _Vibrio_#super[$Delta$ACD] - Only Δ is superscripted, not “ACD”

What’s the minimal way to achieve italic text followed by superscript that includes both a Greek letter and regular text?

I think there are few solutions, but quotes seems like an easy one:

_Vibrio_$""^(Delta"ACD")$

image

Though I think there probably should be a canonical way. I guess it might’ve been

_Vibrio_#super[$Delta"ACD"$]

but it doesn’t work.

2 Likes

Thank you this works and is simple enough. Can you explain why this works but without the double quotes (before Delta) it doesn’t. Is this an expected behavior?

^ is the shorthand for math.attach, you must provide the base content. Empty quotes just happen to output nothing. See https://typst.app/docs/reference/math/attach/#syntax.

2 Likes

If you don’t actually need math mode, just the greek letter, you can also use the letter plainly:

_Vibrio_#super[#sym.Delta;ACD]

The semicolon here is to terminate the Delta identifier without inserting whitespace. The superscript will not use the math font.

I assume you meant the reverse—Δ is not superscipted in my testing. I have reported this on Github: Math within `super` or `sub` is not shown as super/subscript · Issue #7673 · typst/typst · GitHub

2 Likes

Yes, you are right. Delta is not superscripted in mine too.

Thank you, this is good to learn. For now, I am using _Vibrio_$""^(Delta"ACD")$ as I prefer the clarity of the math mode text in superscript.

Thank you, this is good to learn. For now, I am using _Vibrio_$""^(Delta"ACD")$ as I prefer the clarity of the math mode text in superscript.