1

I have some long equations and cannot manage to get them to align neatly on the page using align. My code is currently

\documentclass{article}

\usepackage{amsmath, amsthm, amsfonts, amssymb}
\newcommand{\fii}{\varphi}
\newcommand{\eps}{\varepsilon}
\newcommand{\intst}{\int_0^T \int}
\newcommand{\ints}{\int}

\begin{document}
\begin{align}
\begin{split}
\intst w^\eps \cdot (\fii_t - (Q \fii)_x +R^\intercal \fii ) dxdt = \intst (\ints \rho^\eps(x-y) w(t,y) dy) \cdot ( \fii_t(t,x)-(Q\fii)_x(t,x) + (R^\intercal \fii)(t,x) dxdt
              \\
            = \ints(\intst w(t,y) \cdot \big((\rho^\eps(x-y) \fii(t,x))_t - ( Q(t,y)\rho^\eps (x-y) \fii(t,x))_y + R^\intercal(t,y) \rho^\eps(x-y) \fii(t,x) \big) dydt ) dx \\
+ \ints(\intst w(t,y) \cdot (Q(t,y) \rho^\eps(x-y) \fii(t,x))_y-\rho^{\eps}(x-y) w(t,y)\cdot (Q(t,x) \fii(t,x))_x \\ 
 - w(t,y)\cdot(R^\intercal (t,y) \rho^\eps (x-y) \fii(t,x)) +\rho^\eps(x-y)w(t,y)\cdot (R^\intercal (t,x) \fii(t,x)) dydt) dx \\
 = \ints(\intst f(t,y) \rho^\eps(x-y) \fii(t,x) dy dt - \ints w_0(y) \rho^\eps(x-y)\fii(0,x)dy) dx \\
 + \intst (\ints \rho^\eps(x-y) Q_y(y,t) w(y,t) - (\rho^\eps)'(x-y) Q(t,y) w(t,y) - \rho^\eps(x-y)Q_x(t,x) w(t,y) \\
 +\rho^\eps(x-y)(R(t,x)-R(t,y))w(t,y) dy) \cdot \fii(t,x) dxdt \\
 +\intst ( \ints -\rho^\eps(x-y) w(t,y) dy) \cdot Q(t,x) \fii_x(t,x) dxdt \\
=\intst f^\eps(t,x) \cdot \fii (t,x) dx dt - \ints w_0^\eps(x) \cdot \fii(x,0) dx + \intst r^\eps(t,x)\cdot \fii(t,x) dx dt
\end{split}
\end{align}
\end{document}

And the output looks likeenter image description here

I have tried spreading this more neatly accross the pages by adding alignement tabs in different places, but this seems to end up shifting the whole thing to the right! For example, if I write

\intst w^\eps \cdot (\fii_t - (Q \fii)_x +R^\intercal \fii ) dxdt = \intst (\ints \rho^\eps(x-y) w(t,y) dy) \cdot ( \fii_t(t,x)-(Q\fii)_x(t,x) + (R^\intercal \fii)(t,x) dxdt
              \\
             &=\ints(\intst w(t,y) \cdot \big((\rho^\eps(x-y) \fii(t,x))_t - ( Q(t,y)\rho^\eps (x-y) \fii(t,x))_y + R^\intercal(t,y) \rho^\eps(x-y) \fii(t,x) \big) dydt ) dx \\
+ \ints(\intst w(t,y) \cdot (Q(t,y) \rho^\eps(x-y) \fii(t,x))_y-\rho^{\eps}(x-y) w(t,y)\cdot (Q(t,x) \fii(t,x))_x \\ 
 - w(t,y)\cdot(R^\intercal (t,y) \rho^\eps (x-y) \fii(t,x)) +\rho^\eps(x-y)w(t,y)\cdot (R^\intercal (t,x) \fii(t,x)) dydt) dx \\
 &= \ints(\intst f(t,y) \rho^\eps(x-y) \fii(t,x) dy dt - \ints w_0(y) \rho^\eps(x-y)\fii(0,x)dy) dx \\
 &+ \intst (\ints \rho^\eps(x-y) Q_y(y,t) w(y,t) - (\rho^\eps)'(x-y) Q(t,y) w(t,y) - \rho^\eps(x-y)Q_x(t,x) w(t,y) \\
 &+\rho^\eps(x-y)(R(t,x)-R(t,y))w(t,y) dy) \cdot \fii(t,x) dxdt \\
 &+\intst ( \ints -\rho^\eps(x-y) w(t,y) dy) \cdot Q(t,x) \fii_x(t,x) dxdt \\
&=\intst f^\eps(t,x) \cdot \fii (t,x) dx dt - \ints w_0^\eps(x) \cdot \fii(x,0) dx + \intst r^\eps(t,x)\cdot \fii(t,x) dx dt 

then I end up with something like this

enter image description here

Can anyone help me align my equations or explain what I am doing wrong? Many thanks, A.

1

This gives two ways of achieving what you want. I've also made some of the brackets of the appropriate size.

\documentclass{article}

\usepackage{amsmath, amsthm, amsfonts, amssymb}
\newcommand{\fii}{\varphi}
\newcommand{\eps}{\varepsilon}
\newcommand{\intst}{\int_0^T \int}
\newcommand{\ints}{\int}
\usepackage[margin=1in]{geometry}


\begin{document}
\begin{align}
\int_0^T & \int w^\eps \cdot (\fii_t - (Q \fii)_x +R^\intercal \fii ) dxdt\notag\\
& = \intst (\ints \rho^\eps(x-y) w(t,y) dy) \cdot ( \fii_t(t,x)-(Q\fii)_x(t,x) + (R^\intercal \fii)(t,x) dxdt
      \notag        \\
 &           = \ints\Biggl(\intst w(t,y) \cdot \biggl((\rho^\eps(x-y) \fii(t,x))_t - ( Q(t,y)\rho^\eps (x-y) \fii(t,x))_y + R^\intercal(t,y) \rho^\eps(x-y) \fii(t,x) \biggr) dydt \Biggr) dx \notag\\
&+ \ints(\intst w(t,y) \cdot (Q(t,y) \rho^\eps(x-y) \fii(t,x))_y-\rho^{\eps}(x-y) w(t,y)\cdot (Q(t,x) \fii(t,x))_x \notag\\ 
 &- w(t,y)\cdot(R^\intercal (t,y) \rho^\eps (x-y) \fii(t,x)) +\rho^\eps(x-y)w(t,y)\cdot (R^\intercal (t,x) \fii(t,x)) dydt) dx \notag\\
 &= \ints(\intst f(t,y) \rho^\eps(x-y) \fii(t,x) dy dt - \ints w_0(y) \rho^\eps(x-y)\fii(0,x)dy) dx \notag\\
 &+ \intst (\ints \rho^\eps(x-y) Q_y(y,t) w(y,t) - (\rho^\eps)'(x-y) Q(t,y) w(t,y) - \rho^\eps(x-y)Q_x(t,x) w(t,y) \notag\\
 &+\rho^\eps(x-y)(R(t,x)-R(t,y))w(t,y) dy) \cdot \fii(t,x) dxdt \notag\\
& +\intst ( \ints -\rho^\eps(x-y) w(t,y) dy) \cdot Q(t,x) \fii_x(t,x) dxdt \notag\\
&=\intst f^\eps(t,x) \cdot \fii (t,x) dx dt - \ints w_0^\eps(x) \cdot \fii(x,0) dx + \intst r^\eps(t,x)\cdot \fii(t,x) dx dt
\end{align}


\begin{multline}
    \int_0^T   \int w^\eps \cdot (\fii_t - (Q \fii)_x +R^\intercal \fii ) dxdt \\
      = \intst (\ints \rho^\eps(x-y) w(t,y) dy) \cdot ( \fii_t(t,x)-(Q\fii)_x(t,x) + (R^\intercal \fii)(t,x) dxdt
             \\
                = \ints(\intst w(t,y) \cdot \big((\rho^\eps(x-y) \fii(t,x))_t - ( Q(t,y)\rho^\eps (x-y) \fii(t,x))_y + R^\intercal(t,y) \rho^\eps(x-y) \fii(t,x) \big) dydt ) dx  \\
     + \ints(\intst w(t,y) \cdot (Q(t,y) \rho^\eps(x-y) \fii(t,x))_y-\rho^{\eps}(x-y) w(t,y)\cdot (Q(t,x) \fii(t,x))_x  \\ 
     - w(t,y)\cdot(R^\intercal (t,y) \rho^\eps (x-y) \fii(t,x)) +\rho^\eps(x-y)w(t,y)\cdot (R^\intercal (t,x) \fii(t,x)) dydt) dx  \\
     = \ints(\intst f(t,y) \rho^\eps(x-y) \fii(t,x) dy dt - \ints w_0(y) \rho^\eps(x-y)\fii(0,x)dy) dx  \\
     + \intst (\ints \rho^\eps(x-y) Q_y(y,t) w(y,t) - (\rho^\eps)'(x-y) Q(t,y) w(t,y) - \rho^\eps(x-y)Q_x(t,x) w(t,y)  \\
     +\rho^\eps(x-y)(R(t,x)-R(t,y))w(t,y) dy) \cdot \fii(t,x) dxdt  \\
      +\intst ( \ints -\rho^\eps(x-y) w(t,y) dy) \cdot Q(t,x) \fii_x(t,x) dxdt  \\
     =\intst f^\eps(t,x) \cdot \fii (t,x) dx dt - \ints w_0^\eps(x) \cdot \fii(x,0) dx + \intst r^\eps(t,x)\cdot \fii(t,x) dx dt
\end{multline}

\end{document}
  • 1
    Thank-you for this, I like the multline package very much! – Aerinmund Fagelson Feb 25 '17 at 14:58
2

Here is a variant, resting on aligned. I defined a \brparen command, which adds a pair of adjustable parenthesis on each side of its argument, while allowing line breaks inside (code adapted from an example in the documentation of mathtools). I also defined a \dd command for the differential in integrals, with a correct spacing and a roman d:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{mathtools, amsthm, amsfonts, amssymb}
\newcommand{\fii}{\varphi}
\newcommand{\eps}{\varepsilon}
\newcommand{\intst}{\int_0^T\mkern-8mu \int}
\newcommand{\ints}{\int}
    \newcommand\MTkillspecial[1]{% helper macro
    \bgroup
    \catcode`\&=9
    \let\\\relax%
    \scantokens{#1}%
    \egroup
    }
    \DeclarePairedDelimiter\brparen\lparen\rparen
    \reDeclarePairedDelimiterInnerWrapper\brparen{star}{
    \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.}
    #2
    \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}}
\newcommand*{\dd}{\mathop{\kern0pt\mathrm{d}}\!{}}

\begin{document}
\begin{align}
 & \intst w^\eps \cdot (\fii_t - (Q \fii)_x +R^\intercal \fii ) \dd x\dd t \\
 & = \intst\biggl (\ints \rho^\eps(x-y) w(t,y) \dd y\biggr) \cdot ( \fii_t(t,x)-(Q\fii)_x(t,x) + (R^\intercal \fii)(t,x) \dd x\dd t
              \\
 & =\!\begin{aligned}[t] \ints\brparen[\bigg]{\intst w(t,y) \cdot \brparen[\Big]{\bigl(\rho^\eps(x-y) \fii(t,x)\bigr)_t & -\bigl( Q(t,y)\rho^\eps (x-y) \fii(t,x)\bigr)_y\\ & + R^\intercal(t,y) \rho^\eps(x-y) \fii(t,x)}\dd y\dd t} \dd x \end{aligned} \\
 &\phantom{=} + \begin{aligned}[t]\ints\brparen[\bigg]{ \intst & w(t,y) \cdot\bigl (Q(t,y) \rho^\eps(x-y) \fii(t,x)\bigr)_y -\rho^{\eps}(x-y) w(t,y)\cdot\bigl(Q(t,x) \fii(t,x)\bigr)_x \\
{}- {}& w(t,y)\cdot\bigl(R^\intercal (t,y) \rho^\eps (x-y) \fii(t,x)\bigr) +\rho^\eps(x-y)w(t,y)\cdot \bigl(R^\intercal (t,x) \fii(t,x)\bigr) \dd y\dd t} \mathrlap{\dd x} \end{aligned}\\
 & = \ints\brparen[\bigg]{\intst f(t,y) \rho^\eps(x-y) \fii(t,x) \dd y \dd t - \ints w_0(y) \rho^\eps(x-y)\fii(0,x)\dd y} \dd x \\
  & \phantom{=}+ \begin{aligned}[t]\intst\brparen[\bigg]{\ints \rho^\eps(x-y) Q_y(y,t) w(y,t) - (\rho^\eps)'(x-y) Q(t,y) w(t,y) - \rho^\eps(x-y)Q_x(t,x) w(t,y) &\\
  +\rho^\eps(x-y)\bigl(R(t,x)-R(t,y)\bigr)w(t,y) \dd y} \cdot \fii(t,x) \dd x\dd t&\end{aligned} \\
  & \phantom{ = }+\intst\biggl ( \ints -\rho^\eps(x-y) w(t,y) \dd y\biggr) \cdot Q(t,x) \fii_x(t,x) \dd x\dd t \\
 & =\intst f^\eps(t,x) \cdot \fii (t,x) \dd x \dd t - \ints w_0^\eps(x) \cdot \fii(x,0) \dd x + \intst r^\eps(t,x)\cdot \fii(t,x) \dd x \dd t
\end{align}
\end{document} 

enter image description here

  • Thank-you for the detailed code, I like the way you managed to get all of the equals signs lined up! – Aerinmund Fagelson Feb 25 '17 at 15:06

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.