I need to define a macro, lets call it DifferentFontMacro, that takes a single string x as input. This string x is of the form {string1}^{string2}\_{string3}. Now, I want the output of this macro to be {string1}^{\mathsf{string2}}_{\mathsc{string3}}. One approach that I could find is using the xstring package to extract string1, string2 and string3 from x, and then outputting the desired output. However, it seems cumbersome, and I don't know if there's a better solution.


  • 1
    Will you always have the subscript and superscript and in that specific order (superscript followed by subscript)? If so, one could use a delimited parameter text to extract the content...
    – Werner
    Jan 4, 2016 at 21:10
  • do you mean \mathsc (which is not defined by default) Jan 4, 2016 at 21:41

1 Answer 1


enter image description here






You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .