3

So I've got a system of equations. One equation is very long. I want them all aligned, but I want the long equation to split over two lines.

\begin{align}
   \theta &= \theta(t-1) -p \theta(t-1) +p
             \frac{\hat{\psi}'(\theta(t-1))}{\ave{K}} +p \phi_R(0)\nonumber\\
          &\qquad + (1-p)(1-\theta(t-1))\\
   R   &= R(t-1)+I(t-1) 
\end{align}

As it stands, the equation for \theta spans two lines and is numbered on the second line. I'd like the number to be centered (rather like split appears to do). I haven't found a good way to do this.

1
  • Use aligned inside equation.
    – Sigur
    Jan 19, 2016 at 0:17

3 Answers 3

4

split ought to work inside align, but it has some problems; a trick solves the issue:

\documentclass{article}
\usepackage{amsmath,mathtools}

\newcommand{\ave}[1]{\langle #1\rangle}% <--- guess

\begin{document}

\begin{align}
\begin{split}
\mathllap{\theta}
  &= \theta(t-1) -p \theta(t-1) +p
     \frac{\hat{\psi}'(\theta(t-1))}{\ave{K}} +p \phi_R(0)\\
  &\qquad + (1-p)(1-\theta(t-1))\\
\end{split}
\\[1.5ex]
R &= R(t-1)+I(t-1)
\end{align}

\end{document}

Some space is needed to make clearer what the numbers refer to, in my opinion.

enter image description here

2
  • great guess on \ave - nailed it. Can you tell me why mathllap is needed? I see it fixes the alignment, but it's not clear to me how.
    – Joel
    Jan 19, 2016 at 8:31
  • @Joel I'd like to know, too. ;-)
    – egreg
    Jan 19, 2016 at 8:40
1

The trick is to use the aligned environment, which acts as a single line for the purposes of equation numbering, alignment inside other environments, etc. You'll also want to remove the \nonumber:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{aligned}
   \theta &= \theta(t-1) -p \theta(t-1) +p
             \frac{\hat{\psi}'(\theta(t-1))}{K} +p \phi_R(0)\\
          &\qquad + (1-p)(1-\theta(t-1))\\
   R   &= R(t-1)+I(t-1) 
\end{aligned}
\end{equation}
\end{document}

enter image description here

1

it's possible to use aligned within align, as follows:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
 \theta & =
\begin{aligned}[t]
   & \! \theta(t-1) -p \theta(t-1) +p
             \frac{\hat{\psi}'(\theta(t-1))}{K} +p \phi_R(0)\\
          &\qquad + (1-p)(1-\theta(t-1))\\
\end{aligned}\\
   R   &= R(t-1)+I(t-1) 
\end{align}
\end{document}

output of example code

two things to note here:

  • to get the top line of the aligned block even with the left side, it's necessary to specify [t].

  • for reasons lost in the mists of time, an aligned block starts with \,, and this must be reversed with the negative equivalent, \!. (i didn't bother doing that on the second line, since it would probably not be obvious in the presence of the \qquad.)

You must log in to answer this question.

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