I want to set all sub-/superscripts in math mode of an existing document in non-italic style. How can I change the commands ^ and _, appropriately?


1 Answer 1


Stealing from and extending (for superscripts) wipet's answer at cited question, Typeset subscript material automatically in upright font shape

EDITED to replace \rm with \mathrm{}, since the memoir class (used by the OP) does not support \rm. Of course, this will break the use in plain TeX, which wipet touted.

{\catcode`\_=13 \global\let_=\subinrm}
{\catcode`\^=13 \global\let^=\supinrm}
\def\upsubscripts{\catcode`\_=12 } \def\normalsubscripts{\catcode`\_=8 }
\def\upsupscripts{\catcode`\^=12 } \def\normalsupscripts{\catcode`\^=7 }
$A_{lake}  a_x a_x^y$

$A_{lake}  a_x a_x^y$

$A_{lake}  a_x a_x^y$

enter image description here

  • Thanks a lot. One comment: I use document class memoir. Only the first letter of subscript "lake" in the first and second formulation is typed non-italic. Maybe a conflict of document class?
    – Mathias
    Sep 22, 2017 at 12:55
  • @Mathias With memoir, I get \rm not supported in math mode error. Sep 22, 2017 at 13:02
  • @Mathias Please see my revision. Sep 22, 2017 at 13:07
  • In memoir following is necessary: \renewcommand{\sl}{\textsl} \renewcommand{\rm}{\textrm}
    – Mathias
    Sep 22, 2017 at 13:09
  • @Mathias I think one wants \mathrm rather than \textrm. That way, the supscripts can contain, for example, \cos and \alpha, etc.. Sep 22, 2017 at 13:13

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