1

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.

Thanks.

  • 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 '16 at 21:10
  • do you mean \mathsc (which is not defined by default) – David Carlisle Jan 4 '16 at 21:41
2

enter image description here

\documentclass{article}

\newcommand\zzz[1]{\zz#1}
\newcommand\zz[5]{{\mathrm{#1}}^{\mathsf{#3}}_{\mathit{#5}}}

\begin{document}


$\zzz{{string1}^{string2}\_{string3}}$

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.