How can I replicate this LaTeX command in Typst?

The correct way to add indices and exponents in equations is using the Attach Functions – Typst Documentation. Your function will then be

#let p3(a, b, c) = $attach(p, tl: #a, tr: #b, br: #c)$
$p3(A, B, C)$

If you call this in an equation, you do not need quotation marks and the letters will be italic by default. I named the function p3() since the function p() would just be interpreted as the character p in an equation. You could still call the function with #p(), but the arguments will not “inherit” the math mode in that case. (I’m not sure if there is some trick/workaround to use single-character function names in equations.)

4 Likes