4

The majority of math subscripts I am writing are not variables, but rather names (it's engineering). It is therefore appropriate to typeset them upright. My code would look much, much cleaner, if the default behaviour would be that

$a_m$

typesets the 'm' upright, while for the few cases where I need the normal italic font, I could use something like

$a_\mathnormal{m}$

To clarify: I am not looking for a macro that makes it a bit less cumbersome to typeset an index upright. I already have that. Instead, I want to change/overwrite the default behaviour (in the preamble).

Also, if you want to tell me that I should not change the default behaviour, consider me already notified.

Related questions (none of them provide the answer I am looking for):

Is there a way to make math mode subscripts automatically non-italic?

Typeset subscript material automatically in upright font shape

How to globally put subscripts in math-mode in upright font using amsmath?

5
  • 2
    wipet's solution in the question that you link to should answer this, doesn't it? tex.stackexchange.com/a/303840/1090 Commented Jun 20, 2019 at 8:55
  • Thank you David, that looks promising indeed. Sadly, it currently produces an error with the scrartcl class. I will create an MnWE and edit the original post.
    – RL-S
    Commented Jun 20, 2019 at 10:51
  • I'd actually really like to know why I got downvoted for my question.
    – RL-S
    Commented Jun 20, 2019 at 12:32
  • 1
    wasn't me:-) the question should probably be closed as duplicate (even if you post an updated answer over there the actual question is identical) but that doesn't make it a bad question. Perhaps someone objects to you posting the question after having found the duplicates, but since you explicitly referenced the older questions doesn't seem that bad to me, anyway I added 1 to put you back to 0:-) Commented Jun 20, 2019 at 12:42
  • How very nice of you! :)
    – RL-S
    Commented Jun 20, 2019 at 13:01

1 Answer 1

2

David Carlisle pointed me to this answer in one of the linked questions. It does not immediately work with the scrartcl class, as it then produces the error "undefined old font command '\rm'." So it has to be changed to a font that is recognized:

\documentclass{scrartcl}
\usepackage{amsmath}

% typesetting indexes upright by default
\def\subinrm#1{\sb{\textnormal{#1}}}
{\catcode`\_=13 \global\let_=\subinrm}
\mathcode`_="8000
\def\upsubscripts{\catcode`\_=12 } \def\normalsubscripts{\catcode`\_=8 }
% the toggle for upright subscripts
\upsubscripts
% the toggle for italic subscripts
%\normalsubscripts

\begin{document}
    $A_{läke}$, $\normalsubscripts \sum_{i=1}^\infty {1\over n}$
\end{document}

\def\subinrm#1{\sb{\mathrm{#1}}} was my first attempt, but that does not support accented characters such as ä,ö,ü, which, while not pretty, might still show up in my German document. With the amsmath package, \textnormal works in the intended way: Umlauts can be used and subscripts are correctly scaled.

Credit should go to wipet for his original solution and David Carlisle for pointing me to it.

EDIT: updated MWE.

3
  • you want \mathrm not textnormal{\scriptsize Commented Jun 20, 2019 at 11:25
  • As I wrote directly under the code, I used \mathrm first. It does not work with umlauts.
    – RL-S
    Commented Jun 20, 2019 at 11:34
  • oh OK, I see you have seen the amsmath version of \textzzz in the meantime. Commented Jun 20, 2019 at 11:47

You must log in to answer this question.

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