4

I'm trying to do some sort of global alignment for my equations and didn't succeed to find anything online. More precisely, my cases environment inside my aligned and equation* has its own & alignment-symbols that I want to be working with other ones inside aligned. Hopefully this MWE (using amsmath) makes it understandable:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{aligned}
                    & \left| f_{(x)} \right| &\overset{!}{\leq} &L \left| x - y \right| &                      \\
    \Leftrightarrow & \left| x - y \right|   &\leq              &L \left| x - y \right| &                      \\
    \Leftrightarrow & \begin{cases}
                      x - y                  &\leq              &L (x - y)              &\text{ for } x \geq y \\
                      y - x                  &\leq              &L (y - x)              &\text{ for } x > y    \\
                      \end{cases}                                                                              \\
\end{aligned}
\end{equation*}

\end{document}

How do I align every part over each other like the &s in the code above?

Thank you for any hints. I'm also happy for feedback on my code-style :)

Extra question: Why do I get an "Extra alignment tab has been changed to \cr." and an "underfull hbox" at the very end?

Similar questions not answering mine:

6
  • It's not quite a MWE. A MWE is to be typeset "out of the box", so it must have \documentclass{}, the necessary packages, \begin{document} and so on… Dec 16, 2017 at 14:00
  • @FranckPastor done, thanks for pointing out!
    – 4ster
    Dec 16, 2017 at 14:54
  • 1
    The cases environment defines a box of its own IIRC, so I can't see how it can be managed this way. By the way, this environment doesn't accept more than one ampersand per line, so your code can't be typeset as it is. Dec 16, 2017 at 15:20
  • Methinks you are trying too align too much. Is that really necessary? Dec 16, 2017 at 16:02
  • @FranckPastor, again, thank you. That will probably mean that I'm dropping the use of cases then and have to go for doing it by myself...
    – 4ster
    Dec 16, 2017 at 17:53

2 Answers 2

4

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{alignedat}{3}
                    && | f_{(x)}| &\overset{!}{\leq} L | x - y | &                      \\
    &{\Leftrightarrow} & | x - y | &\leq          L | x - y | &                      \\
    &\smash{\raisebox{-8pt}{$\Leftrightarrow\biggl\{$}}
                    &  x - y    &\leq   L (x - y)   &\text{ for } x \geq y \\
                     &&y - x     &\leq   L (y - x)   &\text{ for } x > y                          
\end{alignedat}
\end{equation*}

\end{document}
4
  • Wow this just looks perfect as imagined. After reading about alignedat and learning about cases only supporting one ampersand, I guess doing it all manually is the only option. However, and don't get me wrong on this, I really don't like raisebox and biggl\{ instead of dynamical parantheses like \left\{. I guess nesting two multline boxes will be the way to go...
    – 4ster
    Dec 16, 2017 at 18:00
  • 1
    @4ster it's almost always better to choose the size than use left/right eg uses such as \left| x - y \right| should be avoided. Dec 16, 2017 at 18:03
  • that's interesting to hear. I thought keeping everything variable (e.g. allowing to change the documents font size) was a good measure to take - 8pt in your code didn't seem to comply with that approach. Now I guess I need a good guide for LaTeX-style to change my approach. With your experience, can you recommend something where I can get a deeper understanding of this?
    – 4ster
    Dec 16, 2017 at 18:48
  • 1
    @4ster see tex.stackexchange.com/q/173717/1090 Dec 16, 2017 at 19:23
2

With some gentle persuasion applied to bigdelim:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array,bigdelim}
\usepackage{etoolbox}

\newcommand{\Nleq}{\overset{!}{\leq}}

\makeatletter
\newcommand{\reducedelim}{%
  \patchcmd{\@ldelim}{\multirow@dima}{0.75\multirow@dima}{}{}%
}
\makeatother

\begin{document}

\begin{equation*}
\renewcommand{\arraystretch}{1.5}
\setlength{\arraycolsep}{0pt}
\begin{array}{ l r >{{}}c<{{}} l @{\qquad} l }
   & \lvert f_{(x)} \rvert &\Nleq& L \lvert x - y \rvert \\
\Leftrightarrow
   & \lvert x - y \rvert  &\leq&  L \lvert x - y \rvert \\
\reducedelim\ldelim\lbrace{2}{*}[$\Leftrightarrow$\qquad]
   & x - y                 &\leq&  L (x - y) &\text{for $x \geq y$} \\
   & y - x                 &\leq&  L (y - x) &\text{for $x > y$}
\end{array}
\end{equation*}

\end{document}

enter image description here

On the other hand, the middle inequality is satisfied, for all x and y, if and only if L ≥ 1.

You must log in to answer this question.

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