I'm currently working on a report where the majority of subscripts will be non-italic. The way I know how to do this currently is via \mathrm{}
, which is an absolute horror when you have to do it many times per equation. Any ways around this? I do have the mtpro2
package, but not sure if there is an option I'm overlooking.
-
6tex.stackexchange.com/questions/156641/…, is one way. you may get into problems with other packages etc.– daleifCommented Feb 6, 2014 at 9:53
4 Answers
Are the subscript materials you have in mind the names of variables? If so, the variable names should probably be set in upright mode regardless of their position relative to the math baseline. However, other subscript material, such as the letters i
and t
that serve to index elements of sequences, should probably continue to be set in italics. Thus, an approach that typesets all subscript material in upright-roman mode isn't entirely desirable, right?
Fortunately, typesetting all variable names in upright-roman letters can be achieved easily by taking the following two-step approach:
Set up a macro named (say)
\V
in the preamble to denote that its argument is a variable name:\usepacakge{amsmath} % loads 'amstext' package, which redefines \textup to be scalable \newcommand{\V}[1]{\textup{#1}} % Next, define various freqently-used variable names using the \V macro: \newcommand\Initial{\V{Initial}} \newcommand\Final{\V{Final}}
In the body of the document, you might then write something like
\begin{equation} F_{\Final} = 3F_{\Initial} + 2F_{\V{Intermediate}} \end{equation}
Note that this approach lets you inform LaTeX on the fly, with a minimum of fuss, that certain strings are variable names.
Another important virtue of this two-step approach is that if you change your mind later on and decide that variable names should be typeset differently -- e.g., in text-italics instead of text-upright roman -- all you'll need to do to accomplish this is to change the definition of the \V
macro.
-
since when is
\textup
defined byamsmath
, it comes from the kernel :-P– daleifCommented Feb 6, 2014 at 10:39 -
2@Mico: I would use package
amsmath
(oramstext
) with\textup
, because the package makes\textup
scalable as\text
is working. Commented Feb 6, 2014 at 10:53 -
@HeikoOberdiek, interesting to know, BTW which part of
amstext
is responsible for that part (normal interest)?– daleifCommented Feb 6, 2014 at 11:01 -
2@daleif: The assignment
\let\nfss@text\text
makes all commands that uses\nfss@text
scalable. Commented Feb 6, 2014 at 11:24
Not an answer, but what I'd usually do is to have macros defined for the most common "complex" variables: e.g.,
\newcommand{\GammaD}{\Gamma_{\mathrm{D}}}
.
A semi-answer from personal experience, that I'm sure some people will disagree with - and to my mind more useful than Joce's (who beat me too it while I was writing this):
Define macros for the common stuff, just stick with _\mathrm{...}
for the rest.
For example if you use $\lambda_\mathrm{pump}$
and $\lambda_\mathrm{probe}$
you could define:
\newcommand{\wavel}[1]{\lambda_{\mathrm{#1}}}
and try:
$\wavel{probe}=\wavel{2}$
to test - the numbers look fine. It looks like you can override this by doing $\wavel{\mathit{i}}$
if you really want - but you're better off not doing that.
Edit thanks to @tohecz: {}
inserted around the subscript as \mathrm{#1}
doesn't provide a group to the subscript without it as I thought it did, and my original is therefore not reliable.
-
1Now, if it was possible to tag answers, I would tag this one with do-not-do-this-please. It would be better to comply with the LaTeX's syntax at least a bit more, and use
\lambda_{\mathrm{#1}}
– yo'Commented Feb 6, 2014 at 10:22 -
@tohecz you mean the extra
{}
around the\mathrm{#1}
? I can add that in, but I'd like to understand why first - does the \mathrm{#1} not already [weak terminology alert] provide a group to the subscripting_
? Or to put it another way: what's wrong with the syntax given that it works?– Chris HCommented Feb 6, 2014 at 10:47 -
No, it does not provide a group. It's actually a token and a group, so if you think of
_
as of a macro with one argument,x_\mathrm{y}
is invalid syntax. You're right that it works, which is bceause of how TeX performs the expansion of_
. It works as long as nobody tweaks_
to behave in a different way; then it will likely stop working.– yo'Commented Feb 6, 2014 at 10:50 -
@tohecz, thanks for the explanation, I've edited it in. looking at my main macro collection I'd usually done it right anyway, just a couple of recent definitions were wrong.– Chris HCommented Feb 6, 2014 at 11:08
What I usually have in my documents in the preamble is the following line
\providecommand{\cind}[1]{_{\textrm{#1}}}
With this command I'm completely flexible with the variable name as well as with the index name and I don't have to define something else in the preamble.
-
While this definition is fine for variable names in subscript positions, it doesn't work if the variable names need to appear, say, on the baseline or in a superscript position.– MicoCommented Feb 25, 2015 at 2:16