2

I have a couple of equations from Autometrics which I want numbered but for some reason, the equation numbering always goes on the line below the equation. I would want the numbering to be somewhere in the middle of the equation or next to the last line of the equation. Below is the code for one of the equations. Thanks

\documentclass[12pt, varwidth, border=10pt]{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[onehalfspacing]{setspace}
\usepackage{geometry}
\usepackage[final]{graphicx}

\begin{document}

\begin{equation}
  \begin{array}{lcl}
  r_{p,t} & = &
  \begin{array}[t]{r} 
  0.0043
  \\ ^{(0.003)}
  \end{array}
  \ -\!\begin{array}[t]{r}
  0.0068
 \\ ^{(0.0019)}
 \end{array}
 D_{1}
 \ -\!\begin{array}[t]{r}
 0.0053
 \\ ^{(0.0023)}
 \end{array}
 D_{2}
 \ -\!\begin{array}[t]{r}
 0.0036
 \\ ^{(0.0021)}
 \end{array}
  D_{3}
  \ -\!\begin{array}[t]{r}
  0.00026
  \\ ^{(0.0020)}
  \end{array}
  D_{4}
  \ +\!\begin{array}[t]{r}
  0.31
  \\ ^{(0.066)}
  \end{array}
   R_{Mt}
  \\ & &
  \ +\!\begin{array}[t]{r}
 0.026
 \\ ^{(0.0016)}
 \end{array}
 \text{S}_{\text{13-Dec}}
 \ -\!\begin{array}[t]{r}
  0.026
  \\ ^{(0.0030)}
  \end{array}
  \text{S}_{\text{16-Dec}}
  \end{array} 
  \end{equation} 

\end{document}
2
  • please always provide a test example, the equation number is moved down if it does not fit but you have given no indication of the page width or provided a usable test file. Why are you using array here? Jul 11, 2019 at 16:20
  • @ David Carlisle Thanks for pointing this out. I have now provided additional details. I am using an array since this is the format with which the equations are provided by the statistical software I am using. The problem comes when I edit the equations a bit for presentation purposes then the equation numbering goes on the next line below the equation. Jul 11, 2019 at 16:37

2 Answers 2

1

I can suggest a few improvements, one of which is to use \begin{array}[t]{@{}r@{}}. The other is to reduce the distance between the number and the accuracy; finally split is a lot easier.

A macro for easing input is also recommended.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[onehalfspacing]{setspace}
\usepackage{geometry}

\newcommand{\numprec}[2]{%
  \begingroup\renewcommand{\arraystretch}{0.5}%
  \begin{array}[t]{@{}r@{}} #1 \\ \scriptstyle (#2) \end{array}%
  \endgroup
}

\begin{document}

\begin{equation}
\begin{split}
  r_{p,t} &=
  \numprec{0.0043}{0.003}
 -\numprec{0.0068}{0.0019} \, D_{1}
 -\numprec{0.0053}{0.0023} \, D_{2}
 -\numprec{0.0036}{0.0021} \, D_{3}
 -\numprec{0.00026}{0.0020} \, D_{4}
 +\numprec{0.31}{0.066} \, R_{Mt}
\\
 &\qquad
 +\numprec{0.026}{0.0016} \, \mathrm{S}_{\text{13-Dec}}
 -\numprec{0.026}{0.0030} \, \mathrm{S}_{\text{16-Dec}}
\end{split}
\end{equation} 

\end{document}

enter image description here

In case the first row doesn't fit, you can move the last summand to the next line.

If you remove the \qquad, you get

enter image description here

0
0

enter image description here

If you remove the padding from the arrays with @{} you can use normal spacing around =, -, + and then I'd use an AMS multi line display rather than an outer array.

\documentclass{article}

\usepackage{amsmath}
\begin{document}

\begin{multline}
  r_{p,t}  = 
  \begin{array}[t]{@{}r@{}} 
  0.0043
  \\ ^{(0.003)}
  \end{array}
  -\begin{array}[t]{@{}r@{}}
  0.0068
 \\ ^{(0.0019)}
 \end{array}
 D_{1}
 -\begin{array}[t]{@{}r@{}}
 0.0053
 \\ ^{(0.0023)}
 \end{array}
 D_{2}
 -\begin{array}[t]{@{}r@{}}
 0.0036
 \\ ^{(0.0021)}
 \end{array}
  D_{3}
  -\begin{array}[t]{@{}r@{}}
  0.00026
  \\ ^{(0.0020)}
  \end{array}
  D_{4}
  +\begin{array}[t]{@{}r@{}}
  0.31
  \\ ^{(0.066)}
  \end{array}
   R_{Mt}
\\
  +\begin{array}[t]{@{}r@{}}
 0.026
 \\ ^{(0.0016)}
 \end{array}
 \text{S}_{\text{13-Dec}}
 -\begin{array}[t]{@{}r@{}}
  0.026
  \\ ^{(0.0030)}
  \end{array}
  \text{S}_{\text{16-Dec}}
  \end{multline}
\end{document}
2
  • Thanks for this. I am now wondering how I can get the second line of the equation to be aligned to the equal sign in the first line as I would get in an array. Thanks Jul 11, 2019 at 16:55
  • array is not designed for these things, the spacing is all wrong for equations and it sets the terms in text not display style, use \begin{align*} instead of \begin{multilne} if yoy want to specify an alignment and use a singe &= or ={}& (depending where you want the +) @SamsonMukanjari Jul 11, 2019 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.