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.

2
  • 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
    Commented Jan 4, 2016 at 21:10
  • do you mean \mathsc (which is not defined by default) Commented Jan 4, 2016 at 21:41

1 Answer 1

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}

You must log in to answer this question.

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