I would like to redefine the underscore _ to automatically set subscripts in math mode in roman type, as I currently find myself almost always using _\mathrm{}. I can't find a way of redefining what _ does:
\renewcommand_ gives
! Missing control sequence inserted.
<inserted text>
\inaccessible
and \show_ just tells me
subscript character _.
I found a description of how to make _ an active character on Anthony Lieken's website, but that just brings _ and ^ to text mode and does not change the behaviour in math mode.
Question:
How do I make _x behave like _\mathrm{x}?
\sb. Also, if you write\ensuremath{\sb{\textrm{#1}}}, you have the added benefit of being able to use it in text mode. – Bruno Le Floch Jan 20 '11 at 10:32\mathrmover\textrm: it scales better, for instance when writing$\sum\sb{n=n_{min}}\sp{n_{max}}$. – Bruno Le Floch Jan 20 '11 at 10:44\mathrm. You should have written this answer ... – Hendrik Vogt Jan 20 '11 at 10:50amsmath, then\mathrmand\textrmscale the same, but still,\mathrmis better since it gives the same output in an italic context. – Hendrik Vogt Feb 15 '13 at 16:10\mathrmand\textare very common as subscript. What I did recently was to "overload" the unicode character⌄to do just this (I also added a shortcut, control-altGR+"-" to type it) and added the code\catcode⌄ PRIMECHAR =\active \newcommand⌄[1]{\ensuremath{\sb{\mathrm{#1}}}}or...\text{...(needsxelatex) – alfC Apr 09 '14 at 21:10