I need to set subscripts and superscripts automatically in mathematical equations in roman font style for a book publication. I do not want to apply \mathrm{...} to each subscript or superscript separately.
Fortunately I found a solution to globally set subscripts in roman font style in Redefine underscore to produce roman subscript. I made a slight adaptation in order to have all indexes in sequence in roman font style:
\catcode`_=\active
\newcommand_[1]{\ensuremath{\sb{\mathrm{#1}}}}
Original typeset $x_{abc}^{de}$: 
Roman subscripts with code above $x_{abc}^{de}$: 
I can, however, not figure out how to apply this code to superscripts. Does anyone have a solution so set both the subscript and superscript font style to roman?



_by^and\sbby\sp? – David Carlisle Jul 19 '17 at 07:47$x \mathrm{e}^{\mathrm{x}}$the twoxs are different entities, while in$x \mathrm{e}^x$they're not. – Chris H Jul 19 '17 at 08:53