3

I'm writing a paper for a journal that contains several regression equations (a first for me). Some of the models have long variables names (between 2-7 characters in length). I'm wondering what the best practice is for formatting such text, both inline and in display mode?

Variables are usually in italic face, but for long names this looks odd. Using \mathrm{} looks good within display equations, but for inline equations and descriptions of variables embedded in text it blurs the line between the two so much that it often isn't immediately clear which are variables. I've also tried using \textsubscript{} for inline variables, but this seems the same as \mathrm{}. Any suggestions are most welcome. I've provided a self-contained example of some of the above:

\documentclass[twocolumn]{article}

\usepackage{amsthm,amsmath,amssymb}
\usepackage{lipsum}
\usepackage[utf8]{inputenc} %unicode support
\usepackage{fixltx2e}

\DeclareMathOperator{\E}{\mathbb{E}}%


\begin{document}

\lipsum[2]
%
\begin{equation}
    \E \biggl[ \frac{M_5KV}{M_2KV} \biggm\vert \mathbf{X} \biggr] = \beta_0 + \beta_1 \biggl[ \frac{M_6}{M_2} \biggr] + \mathbf{Z_1u_1} + \mathbf{Z_2u_2}, 
\end{equation}
%
where $M_5KV / M_2KV$ is the ratio of blah blah and $ \mathbf{Z_iu_i}$ are matrices of random effects. 
%
\begin{equation}
    \E \biggl[ \mathrm{\frac{M_5KV}{M_2KV}} \biggm\vert \mathbf{X} \biggr] = \beta_0 + \beta_1 \biggl[ \mathrm{\frac{M_6}{M_2}} \biggr] + \mathbf{Z_1u_1} + \mathbf{Z_2u_2}, 
\end{equation}
%
where $\mathrm{M_5KV / M_2KV}$ is the ratio of blah blah and $ \mathbf{Z_iu_i}$ are matrices of random effects. Where M\textsubscript{5}KV/M\textsubscript{2}KV is the ratio of blah blah and $ \mathbf{Z_iu_i}$ are matrices of random effects. 

\lipsum[2]
%
\begin{subequations}
\begin{align} 
    \begin{split}
    \E \bigl[ M_5Area \mid \mathbf{X} \bigr] &= \beta_0 + \beta_1 M_2Area + \beta_2 M_6Area \\
        &\quad + \mathbf{Z_1u_1} + \mathbf{Z_2u_2}, \label{eqn:YXM}
     \end{split}  \\
     \begin{split}
    \E \bigl[ M_6Area \mid \mathbf{X} \bigr] &= \beta_0' + \beta_1' M_2Area \\
        &\quad + \mathbf{Z_1u_1} + \mathbf{Z_2u_2}, \label{eqn:MX}
     \end{split}  \\
    \E \bigl[ ab \bigr] &= \frac{1}{n} \sum_{n=1}^{n} \beta_2 \, \beta_1'. 
\end{align}
\end{subequations}
%
where $M_5Area$ is blah blah $M_2Area$ is blah blah blah and $ \mathbf{Z_iu_i}$ are matrices of random effects.
%
\begin{subequations}
\begin{align} 
    \begin{split}
    \E \bigl[ \mathrm{M_5Area} \mid \mathbf{X} \bigr] &= \beta_0 + \beta_1 \mathrm{M_2Area} + \beta_2 \mathrm{M_6Area} \\
        &\quad + \mathbf{Z_1u_1} + \mathbf{Z_2u_2}, \label{eqn:YXM}
     \end{split}  \\
     \begin{split}
    \E \bigl[ \mathrm{M_6Area} \mid \mathbf{X} \bigr] &= \beta_0' + \beta_1' \mathrm{M_2Area} \\
        &\quad + \mathbf{Z_1u_1} + \mathbf{Z_2u_2}, \label{eqn:MX}
     \end{split}  \\
    \E \bigl[ ab \bigr] &= \frac{1}{n} \sum_{n=1}^{n} \beta_2 \, \beta_1'. 
\end{align}
\end{subequations}
%
where $\mathrm{M_5Area}$ is blah blah $\mathrm{M_2Area}$ is blah blah blah blah and $ \mathbf{Z_iu_i}$ are matrices of random effects. Where M\textsubscript{5}Area is blah blah blah M\textsubscript{2}Area is blah blah blah. Solving for area:  $CA = RA(x) + EA(1-x)$. Solving for area:  $\mathrm{CA = RA(x) + EA(1-x)}$.

\lipsum[1-2]


\end{document}
6
  • Maybe you could rename your variables for idenrify in better way your math inline variables from text. For names of operators (like cos or tan) you can use \DeclareMathOperator{\command}{text like name}
    – juanuni
    Commented Jun 5, 2015 at 3:00
  • @juanuni: thanks, unfortunately I have very little leeway in renaming the variables. In my field, they're pretty standard names.
    – Alberto
    Commented Jun 5, 2015 at 3:13
  • If KV is kilovolt, then you definitely want \mathrm{KV} or possibly sciunitx. Commented Jun 5, 2015 at 3:16
  • 1
    @Kormylo: it's not kilovolt. These are variables commonly used in phylogenetics.
    – Alberto
    Commented Jun 5, 2015 at 3:30
  • Do you have freedom at all to chose the style of variables? If exist some (unwritten) rules for this, then obey them. On the end the redactor of journal will decided, how you should write them. To my taste the italic form of variable looks better, they are more easy recognized and made less confusion in text.
    – Zarko
    Commented Jun 5, 2015 at 5:05

2 Answers 2

2

multi-letter identifiers should never be set in math italic which is specifically designed with wide sidebearings to separate the letters to not look like a word but a product of variables.

You can use \mathrm or \mathbf or \mathit` according to taste but I'd typically use it around each identifier not the whole expression.

So

\mathbf{Z}_2\mathbf{u}_2}

or

\mathbf{Z}_{\mathbf{2}}\mathbf{u}_{\mathbf{2}}

not

\mathbf{Z_2u_2}

Certainly never

 M_6Area

but

M_{6}\mathit{Area}

Rather than use \mathxxx commands directly of course you can use

\vbl{Area}

and then choose the font as a global setting

\newcommand\vbl{\mathit}

which makes it easy to change to different fonts if you change your mind which is best.

3
  • Thanks David, this is very helpful indeed. Particularly about the Z matrix and u vector. I'm not sure about having the 'Area' part of the 'M_6Area' variable be part of the subscript though. It does look better typographically, but the 6 denotes the 6th part of 'M' and the area is of this 6th segment. I'll think on it.
    – Alberto
    Commented Jun 6, 2015 at 1:12
  • @Alberto Oh sorry I thought that looked odd, I misread your original, I'll edit to put Area back on the baseline, but it should be in \mathsomething that's the main thing. Commented Jun 6, 2015 at 9:08
  • @Alberto fixed:-) Commented Jun 6, 2015 at 9:09
3

Whatever you eventually decide, be careful to define macros for the constructs you use frequently.

For instance, a global macro for expectation is certainly needed, with the ability to specify a size for the brackets. Also a macro for the multiletter variables and one for denoting matrices.

The code \mathbf{Z_1u_1} is wrong in several ways. First, it emboldens also the subscripts, which is probably not wanted as they are numeric indices; second, it hides the fact you have two matrices; third, it violates the recommendation I made at the start.

For the multiletter variables you can choose between upright or italic shape at the very last moment if you do

\newcommand{\vr}[1]{\mathit{#1}} % or \mathrm
\newcommand{\KV}{\vr{KV}}
\newcommand{\Area}{\vr{Area}}

and use \KV and \Area throughout. I similarly defined a macro \mb for matrices and an extended \E command: it doesn't just print the blackboard bold ‘E’, but takes as optional argument a size (\bigg, for instance) and as mandatory argument the material to be in brackets; the conditional is simply denoted by | (if missing there's no problem).

Finally, note the trick in the split environments for better aligning the +.

\documentclass[twocolumn]{article}

\usepackage[utf8]{inputenc} %unicode support
\usepackage{fixltx2e}
\usepackage{amsthm,amsmath,amssymb,mathtools}

\usepackage{lipsum}

\newcommand{\vr}[1]{\mathit{#1}}
\newcommand{\KV}{\vr{KV}}
\newcommand{\Area}{\vr{Area}}

\newcommand{\mb}[1]{\mathbf{#1}}
\DeclarePairedDelimiter{\br}{[}{]}

% see http://tex.stackexchange.com/a/187363/4427
\newcommand{\E}{\operatorname{\mathbb{E}}\expectarg}
\DeclarePairedDelimiterX{\expectarg}[1]{[}{]}{%
  \ifnum\currentgrouptype=16 \else\begingroup\fi
  \activatebar#1
  \ifnum\currentgrouptype=16 \else\endgroup\fi
}
\newcommand{\innermid}{\nonscript\;\delimsize\vert\nonscript\;}
\newcommand{\activatebar}{%
  \begingroup\lccode`\~=`\|
  \lowercase{\endgroup\let~}\innermid 
  \mathcode`|=\string"8000
}

\begin{document}

\lipsum*[2]
\begin{equation}
\E[\bigg]{\frac{M_5KV}{M_2KV} | \mb{X}} = 
  \beta_0 + \beta_1 \br*{\frac{M_6}{M_2}} + \mb{Z}_1\mb{u}_1 + \mb{Z}_2\mb{u}_2, 
\end{equation}
where $M_5\KV / M_2\KV$ is the ratio of blah blah and $\mb{Z}_i\mb{u}_i$ 
are matrices of random effects.
\begin{equation}
\E[\bigg]{\frac{M_5\KV}{M_2\KV} | \mathbf{X}} =
  \beta_0 + \beta_1 \br*{\frac{M_6}{M_2}} + \mb{Z}_1\mb{u}_1 + \mb{Z}_2\mb{u}_2,
\end{equation}
where $M_5\KV / M_2\KV$ is the ratio of blah blah and $\mb{Z}_i\mb{u}_i$ are matrices 
of random effects.

\lipsum*[2]
\begin{subequations}
\begin{align} 
  \begin{split}
  \E{M_5\Area | \mathbf{X}}
     &= \beta_0 + \beta_1 M_2Area \\
     &\hphantom{{}=\beta_0} + \beta_2 M_6Area \\
     &\hphantom{{}=\beta_0} + \mb{Z}_1\mb{u}_1 + \mb{Z}_2\mb{u}_2,
  \end{split}\label{eqn:YXM}
\\
  \begin{split}
  \E{M_6Area | \mathbf{X}}
    &= \beta_0' + \beta_1' M_2Area \\
    &\hphantom{{}=\beta_0'} + \mb{Z}_1\mb{u}_1 + \mb{Z}_2\mb{u}_2,
  \end{split} \label{eqn:MX}
\\
  \E{ab} &= \frac{1}{n} \sum_{n=1}^{n} \beta_2\beta_1'. 
\end{align}
\end{subequations}

\end{document}

enter image description here

If M2Area is a single object, you can define

\newcommand{\M}[2]{M_{#1}\mathit{#2}}

and use \M{2}{Area}. Or decide for a handier syntax.

1
  • thanks so much; these macros will certainly make life easier!
    – Alberto
    Commented Jun 6, 2015 at 1:16

You must log in to answer this question.

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