Cases alignment and displaystyle for all environments

You can do it with dcases from the mathtools package and measuring the largest item, but the final result is much worse than your image, in my opinion:

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

\newlength{\longestcase}
\newcommand{\longcase}[1]{%
  \mathmakebox[\longestcase][l]{#1}%
}

\begin{document}

\settowidth{\longestcase}{%
  $\displaystyle
   \sum_{v\in N(y)\setminus\{x\}} p(v) +
   \sum_{v\in N(x)}p(x)-p(x)-p(y)
  $}
\begin{align*}
(p's_y)(z)
  &=(ps_xs_y)(z)=\\
  &=\begin{dcases}
    \longcase{p'(z)}                                 & z\neq y\\[2ex]
    \sum_{v\in N(y)}p'(v)-p'(z)                      & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                  & z\neq x,y\\[2ex]
    \sum_{v\in N(x)}p(v)-p(x)                        & z=x\\
    \sum_{v\in N(y)\setminus\{x\}}p'(v)+p'(x)-p'(y ) & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                  & z\neq x,y\\[2ex]
    \sum_{v\in N(x)}p(v)-p(x)                        & z=x\\
    \sum_{v\in N(y)\setminus\{x\}} p(v) +
    \sum_{v\in N(x)}p(x)-p(x)-p(y)                   & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                  & z\neq x,y\\[2ex]
    \sum_{v\in N(x)}p(v)-p(x)                        & z=x\\
    \sum_{v\in N(y)\setminus\{x\}} p(v) +
    \sum_{v\in N(x)\setminus\{y\}} p(v) -p(x)        & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                  & z\neq x,y\\[2ex]
    \sum_{v\in N(x)}p(v)-p(x)                        & z=x\\
    \sum_{v\in (N(x)\cup N(y))\setminus\{x,y\}} p(v) & z=y
    \end{dcases}
\end{align*}

\end{document}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

enter image description here

Centering the objects makes it even worse. ;-)

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

\newlength{\longestcase}
\newcommand{\longcase}[1]{%
  \mathmakebox[\longestcase][c]{#1}%
}

\begin{document}

\settowidth{\longestcase}{%
  $\displaystyle
   \sum_{v\in N(y)\setminus\{x\}} p(v) +
   \sum_{v\in N(x)}p(x)-p(x)-p(y)
  $}
\begin{align*}
(p's_y)(z)
  &=(ps_xs_y)(z)=\\
  &=\begin{dcases}
    \longcase{p'(z)}                                            & z\neq y\\[2ex]
    \longcase{\sum_{v\in N(y)}p'(v)-p'(z)}                      & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                             & z\neq x,y\\[2ex]
    \longcase{\sum_{v\in N(x)}p(v)-p(x)}                        & z=x\\
    \longcase{\sum_{v\in N(y)\setminus\{x\}}p'(v)+p'(x)-p'(y)}  & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                             & z\neq x,y\\[2ex]
    \longcase{\sum_{v\in N(x)}p(v)-p(x)}                        & z=x\\
    \longcase{\sum_{v\in N(y)\setminus\{x\}} p(v) +
      \sum_{v\in N(x)}p(x)-p(x)-p(y)}                           & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                             & z\neq x,y\\[2ex]
    \longcase{\sum_{v\in N(x)}p(v)-p(x)}                        & z=x\\
    \longcase{\sum_{v\in N(y)\setminus\{x\}} p(v) +
      \sum_{v\in N(x)\setminus\{y\}} p(v) -p(x)}                & z=y
    \end{dcases}\\
  &=\begin{dcases}
    \longcase{p(z)}                                             & z\neq x,y\\[2ex]
    \longcase{\sum_{v\in N(x)}p(v)-p(x)}                        & z=x\\
    \longcase{\sum_{v\in (N(x)\cup N(y))\setminus\{x,y\}} p(v)} & z=y
    \end{dcases}
\end{align*}
\end{document}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

enter image description here


A variant, using the eqparbox package to measure the widest left side with a system of tags, and less horizontal space with the \smashoperator command from mathtools:

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/amsmath
\usepackage{eqparbox}
\newcommand\eqmathbox[2][]{\eqmakebox[#1]{\ensuremath{\displaystyle#2}}}

\begin{document}

\begin{align*}
  (p's_y)(z) & =(ps_xs_y)(z)= \\
                                                                                                      & =\begin{dcases}
  \eqmathbox[C]{p'(z)} & z\neq y \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(y)}}p'(v)-p'(z)} & z=y
  \end{dcases}\\[1ex]
                                                                                                      & =\begin{dcases}
  \eqmathbox[C]{p(z)} & z\neq x,y \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(x)}}p(v)-p(x)} & z=x \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(y)\setminus\{x\}}}p'(v)+p'(x)-p'(y)} & z=y
  \end{dcases}\\[1ex]
                                                                                                      & =\begin{dcases}
  \eqmathbox[C]{p(z)} & z\neq x,y \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(x)}}p(v)-p(x)} & z=x \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(y)\setminus\{x\}}} p(v) +
  \smashoperator{\sum_{v\in N(x)}}p(x)-p(x)-p(y)} & z=y
  \end{dcases}\\[1ex]
                                                                                                      & =\begin{dcases}
  \eqmathbox[C]{p(z)} & z\neq x,y \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(x)}}p(v)-p(x)} & z=x \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(y)\setminus\{x\}}} p(v) +
  \smashoperator{\sum_{v\in N(x)\setminus\{y\}}} p(v) -p(x)} & z=y
  \end{dcases}\\[1ex]
                                                                                                      & =\begin{dcases}
  \eqmathbox[C]{p(z)} & z\neq x,y \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in N(x)}}p(v)-p(x)} & z=x \\
  \eqmathbox[C]{\smashoperator[r]{\sum_{v\in \left(N(x)\cup N(y)\right)\setminus\{x,y\}}} p(v)} & z=y
  \end{dcases}
\end{align*}

\end{document} 

enter image description here

Tags:

Cases

Align