7

I have three equations of different lengths, each having alignments within them (at the '=' and'+') sign. However, I also want to align the three equations at the first '=' of each equation (marked in yellow in the picture below) and also maintain the space between them ,which is produced by the three align environments.

 \documentclass{article}

 \usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}

\begin{document}
\begin{align*}
\frac{\partial F(\phi)}{\partial \beta_1}  &=  \sum_{i: x_i =0} y_i .... \\
&\mathrel{\phantom{=}} + \sum_{i: y_i > 0} 2y_i + ab
\end{align*}
\begin{align*}
\frac{\partial F(\phi)}{\partial \beta_2} &=  \sum_{i: x_i =0} y_i + 2y_{i}^{2} \\
&\mathrel{\phantom{=}} + \sum_{i: y_i > 0} 2y_i + ab + 2x
\end{align*}
\begin{align*}
\frac{\partial F(\phi)}{\partial \beta_3} &=  \sum_{i: x_i =0} y_i + (y+1)^2 - (y-1)^2 \\
&\mathrel{\phantom{=}} + \sum_{i: y_i > 0} 2y_i + ab
\end{align*}
\end{document}

I have tried it by using the alignat command but I did not manage to obtain the result I want . The result at the moment looks like enter image description here

1
  • 3
    you should never have adjacent math displays just use a single align Jan 29 at 17:53

4 Answers 4

8

I think the simplest way to achieve what you want is really to use a single align* environment. Then you can manually add some extra spacing between the three expressions in the optional argument of \\, when switching lines.

\documentclass{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}

\begin{document}
\begin{align*}
\frac{\partial F(\phi)}{\partial \beta_1}  &=  \sum_{i: x_i =0} y_i .... \\
&\mathrel{\phantom{=}} + \sum_{i: y_i > 0} 2y_i + ab \\[4mm]
\frac{\partial F(\phi)}{\partial \beta_2} &=  \sum_{i: x_i =0} y_i + 2y_{i}^{2} \\
&\mathrel{\phantom{=}} + \sum_{i: y_i > 0} 2y_i + ab + 2x \\[4mm]
\frac{\partial F(\phi)}{\partial \beta_3} &=  \sum_{i: x_i =0} y_i + (y+1)^2 - (y-1)^2 \\
&\mathrel{\phantom{=}} + \sum_{i: y_i > 0} 2y_i + ab
\end{align*}
\end{document}
9

In addition to employing a single align* environment, I would also like to recommend that you encase all six \sum terms in \smashoperator "wrappers" to achieve a more compact appearance of the equations. (Basically, the \smashoperator directives let the summation subscript terms protrude to the left and right without this messing up the spacing to the left and right of the \sum symbols.) I would also replace all instances of &\mathrel{\phantom{=}} with either &\quad or &\qquad.

enter image description here

\documentclass{article}
\usepackage{amssymb,amsthm}
\usepackage{mathtools} % 'mathtools' loads 'amsmath' automatically

\begin{document}
\begin{align*}
\frac{\partial F(\phi)}{\partial \beta_1}  
  &=       \smashoperator{\sum_{i: x_i =0}} y_i \dots \\
  &\qquad+ \smashoperator{\sum_{i: y_i > 0}} 2y_i + ab \\[\jot]
\frac{\partial F(\phi)}{\partial \beta_2} 
  &=       \smashoperator{\sum_{i: x_i =0}} y_i + 2y_{i}^{2} \\
  &\qquad+ \smashoperator{\sum_{i: y_i > 0}} 2y_i + ab + 2x \\[\jot]
\frac{\partial F(\phi)}{\partial \beta_3} 
  &=       \smashoperator{\sum_{i: x_i =0}} y_i + (y+1)^2 - (y-1)^2 \\
  &\qquad+ \smashoperator{\sum_{i: y_i > 0}} 2y_i + ab
\end{align*}
\end{document}
6

Based on @Mico's nice answer (+1) but with use of \pdv of derivative package and multlined environment, \smashoperator and \mathrlap of mathtools package:

\documentclass{article}

\usepackage{amssymb, amsthm}
\usepackage{mathtools}  % it load amsmath too
\usepackage{derivative}

\begin{document}
    \begin{align*}
\pdv{F(\phi)}{\beta_1}  
    & = \begin{multlined}[t]
        \smashoperator{\sum_{i:x_i=0}}  \mathrlap{y_i \dots} \\
            + \smashoperator{\sum_{i:y_i>0}}    2y_i + ab
        \end{multlined}     \\[\jot]
%
\pdv{F(\phi)}{\beta_2}
    & = \begin{multlined}[t]
        \smashoperator{\sum_{i:x_i=0}}  \mathrlap{y_i + 2y_{i}^{2}} \\
            + \smashoperator{\sum_{i:y_i>0}}    2y_i + ab + 2x
        \end{multlined}     \\[\jot]
%
\pdv{F(\phi)}{\beta_3}
    & = \begin{multlined}[t]
        \smashoperator{\sum_{i:x_i=0}}  \mathrlap{y_i + (y+1)^2 - (y-1)^2} \\
            + \smashoperator{\sum_{i:y_i>0}}    2y_i + ab
        \end{multlined}
    \end{align*}
\end{document}

enter image description here

4
  • 1
    Nice touch with \pdv, but are you sure about the use of \mathrlap? Use your code in a two-column setup and change \mathrlap{y_i + (y+1)^2 - (y-1)^2} to \mathrlap{y_i + (y+1)^2 - (y-1)^2-(y-2)^2} to see what I mean.
    – Mico
    Jan 30 at 6:30
  • 1
    @Mico, without of \mathrlap{...} the beginning of the second rows in multlineds are not horizontally aligned (in the last multlined is pushed to right). Or did I misunderstood you?
    – Zarko
    Jan 30 at 7:09
  • 1
    In my opinion, the main issue with \mathrlap is that the contents of its argument may well protrude outside the text block, especially if a two-column layout is in use.
    – Mico
    Jan 30 at 8:00
  • 1
    @Mico, you are right, but, did you test my solution without \mathrlap? Using it, it is enabled that the first line of multlined math can protrude to the right without to has influence on the position of the next (second) line.
    – Zarko
    Jan 30 at 8:11
0

Use the IEEEtrantools package. Effortless alignment of multiple and complex equations. Separate multiple eqns with \\ and use \begin{IEEEeqnarray}{} and \end{IEEEeqnarray}. Three alignment choices in the begin bracket.

\documentclass[letterpaper, 10pt]{memoir}  
\usepackage{graphicx}     
\usepackage{amsmath}   
\usepackage[retainorgcmds]{IEEEtrantools} %for aligning eqns with multiple lines  

\begin{document}

\begin{IEEEeqnarray}{rCl}
  
\overline{C_2B} &=& r = \dfrac{\sqrt {9\Phi^{2}+1} }{2}\,tis.\nonumber \\\  

\overline{BX} &=& \mbox{midface of pentagon to a vertex of pentagon} = \dfrac{\Phi}{\sqrt {\Phi^{2}+1} }\,tis. \nonumber \\\

h^{2} &=& \overline {C_{2} B}^{2}-\overline {BX} 
^{2}=\dfrac{9\Phi^{2}+1}{4}-\dfrac{\Phi^{2}}{\Phi^{2}+1}\nonumber \\\ 

&=& \dfrac{(\Phi^{2}+1)(9\Phi^{2}+1)-4\Phi^{2}}{4(\Phi 
^{2}+1)}\nonumber \\\

&=&\dfrac{9\Phi^{4}+6\Phi^{2}+1}{4(\Phi 
^{2}+1)}=\dfrac{(3\Phi^{2}+1)^{2}}{4(\Phi^{2}+1)}\nonumber \\\ 

h &=& \dfrac{3\Phi^{2}+1}{2\sqrt {\Phi^{2}+1} }\,tis=2.327438437\,tis.
  
\end{IEEEeqnarray} 

Looks like this: enter image description here

The same equations with change in the first parameter from {rCl} to {cCl}centers the left side of each equation

\begin{IEEEeqnarray}{cCl} enter image description here

The same equations with change in the first parameter from {lCl} to {lCl} moves the left side of each equation all the way to the left

\begin{IEEEeqnarray}{lCl} enter image description here

This system is very flexible and allows the alignment of eqns pretty much where you want them.

1
  • 3
    Please add MWE with OP equations, which will generate result as OP like to get. Show this result too.
    – Zarko
    Jan 31 at 21:38

You must log in to answer this question.

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