Creating macros that provide shortcuts for frequently used strings is a very good idea. For an entry-level introduction to the uses of the LaTeX \newcommand
directive see, e.g., Chapter 6, "Customizing LaTeX", of the guide The Not So Short Introduction to LATEX2e.
For instance, you could issue the instructions
\newcommand\loghi{\log(\mathrm{H}\textsc{i})}
\newcommand\sfrm{\log(\mathrm{SFR} / \mathrm{M}_{\odot})}
in the preamble and, later on in the body of the text, write something like
bleet bleet $\loghi=\sfrm$ more bleet bleet
As you've already noted in a comment, a complication arises if these macros can also be used in bold surroundings such as sectioning headers. Specifically, given the above definition of \loghi
, LaTeX will try to typeset the letter i
in bold-smallcaps. As you've discovered, if the font family you're using does not feature a bold-smallcaps font, the letter will be set in "ordinary" bold, i.e., as i. Not the desired effect, right?!
What to do? I think you have (at least) two options. The first is to use a font family that does feature a bold-smallcap font. Two such families arenewt xtext
/newtxmath
and newpxtext
/newpxmath
. The former provides a "Times Roman" look, the latter a "Palatino" look. This may (or may not...) be acceptable to you.
Second, you could set up the macro that defines \loghi
in such a way that it won't even try to use a (possibly nonexistent) bold smallcaps glyph. For instance,
\newcommand\loghi{\log(\mathrm{H}\textsc{\mdseries i})}
(note the addition of \mdseries
to the argument of \textsc
) instructs LaTeX to apply \textsc
to a "medium weight" (rather than a "bold weight") version of i
. As long as the medium-weight font features smallcaps glyphs, you'll be guaranteed success.
\def\loghi{\log(\textrm{H}\textsc{i})}
Then in usage,$\loghi$
. Note I left$
out of the\def
, to allow it to be used in conjunction with other math; for example,$\loghi = x$
.\def\rms{root-mean-square}
, its usage in text will usually bethe \rms{} of...
, with the empty braces following, otherwise the succeeding blank gets eaten by the TeX parser.xspace
isn't so sure: tex.stackexchange.com/questions/86565/drawbacks-of-xspace\newcommand
is "safer" than\def
in that, if a macro by that name already exists, it will break the compilation, rather than allowing the original definition to be overwritten by the new\def
(which could cause strange, difficult to debug, errors). Call it typing laziness on my part.