3

I have a equation that needs to be left aligned within the cases environment. Here's my code so far, which does not work:

\documentclass{article}

\usepackage{amsmath}

\newcommand{\diff}{\mathop{}\!d}
\begin{document}

\begin{equation}\label{eq:algin} 
\begin{aligned}
\begin{cases}
u_i^{k+1}(x)=\arg \min_{u} \Bigg\{
{}& \lambda\sum_{i=1}^{N}\int_{\Omega} r_i(x)u_i(x)\diff x 
+ \frac{\gamma}{2} \sum_{i=1}^{N}\int_{\Omega} \left( u_i(x)-m(x) \right)^2\diff x 
+ \frac{\mu}{2}\int_{\Omega} \left( u_i(x)-m(x) \right)^2\diff x
\Bigg\},
\\
f'(x_{0})=0 \text{ : } z=f(x_{0}) \text{ is de horizontale raaklijn.}
\\
\lim_{x\to x_{0}} f'(x)=\pm\infty \text{ : } x=x_{0} \text{ is de verticale raaklijn.}
\\
g(x_{0}){R}_{0} \text{ : } z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})
  \text{ is de raaklijn.}
\end{cases}
\end{aligned}
\end{equation}

\end{document} 

My wrong output is: enter image description here

I'm trying to get output like this:

enter image description here

This is my expected result

enter image description here

Thanks egreg. I found that when equation is so long (we cut it before), the equation number will automatically locate in bottom. Could we can relocate it in middle? Code

\documentclass{article}

\usepackage{amsmath,mathtools}

\newcommand{\diff}{\mathop{}\!d}
\DeclareMathOperator*{\argmin}{arg\,min}

\begin{document}

\begin{equation}
\begin{dcases}
u_i^{k+1}(x)
\!\begin{multlined}[t]
=\frac{-\lambda r_i(x)+\gamma \bigl( r_i(x)+b_i(x)\bigr)+\gamma \bigl( \alpha-\beta\bigr)}{\theta}\\
 -\frac{\sigma \bigl( -\lambda\int_{i=1}^N r_i(x) \diff x + \sigma\sum_{i=1}^N \bigl( r_i(x)-b_i(x)\bigr) +\gamma N \bigl( 1-r_i(x)\bigr)\bigr)}{\gamma\bigl( \sigma N -1\bigr)},
\end{multlined}
\\[1ex]
f'(x_{0})=0 : z=f(x_{0}) \text{ is de horizontale raaklijn.}
\\[1ex]
\lim_{x\to x_{0}} f'(x)=\pm\infty : x=x_{0} \text{ is de verticale raaklijn.}
\\[1ex]
g(x_{0}){R}_{0} : z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})
  \text{ is de raaklijn.}
\end{dcases}
\end{equation}
This is text
\end{document}

enter image description here

3
  • @macro: I did not use it, Do you tried to use it?
    – Jame
    Nov 9, 2015 at 7:51
  • I've posted an addendum to my answer to address your follow-up query.
    – Mico
    Nov 9, 2015 at 9:04
  • Special case of Align equation left - TeX - LaTeX Stack Exchange . Although it's pointed out to be bad practice, nccmath package can be used to selectively left align equations relative to the margin.
    – user202729
    Apr 19 at 22:34

3 Answers 3

2

I'd suggest using mathtools and its dcases and multlined environments.

I propose two solutions; the first avoids an ambiguity in your formulas, where the same index is used both as a bound and a free variable; the second one is similar to yours.

I removed the unnecessary \left and \right; changed \Bigg into \biggl and \biggr; changed \text{ : } into simple colons; defined \argmin.

\documentclass{article}

\usepackage{amsmath,mathtools}

\newcommand{\diff}{\mathop{}\!d}
\DeclareMathOperator*{\argmin}{arg\,min}

\begin{document}

\begin{equation}
\begin{dcases}
u_j^{k+1}(x)=
  \!\begin{multlined}[t]
  \argmin_{u}
  \biggl\{
  \frac{\mu}{2}\int\limits_{\Omega} (u_j(x)-m(x))^2\diff x \\
  +\sum_{i=1}^{N}\biggl(
     \lambda\int\limits_{\Omega} r_i(x)u_i(x)\diff x 
     + \frac{\gamma}{2}\int\limits_{\Omega} (u_i(x)-m(x))^2\diff x
   \biggr)
  \biggr\},
  \end{multlined}
\\[1ex]
f'(x_{0})=0 : z=f(x_{0}) \text{ is de horizontale raaklijn.}
\\[1ex]
\lim_{x\to x_{0}} f'(x)=\pm\infty : x=x_{0} \text{ is de verticale raaklijn.}
\\[1ex]
g(x_{0}){R}_{0} : z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})
  \text{ is de raaklijn.}
\end{dcases}
\end{equation}

\begin{equation}
\begin{dcases}
\!\begin{aligned}[t]
u_j^{k+1}(x)&=
  \argmin_{u}
  \biggl\{
  \lambda\sum_{i=1}^{N}\int_{\Omega} r_i(x)u_i(x)\diff x \\
  &\quad+ \frac{\gamma}{2} \sum_{i=1}^{N}\int_{\Omega} (u_i(x)-m(x))^2\diff x 
  + \frac{\mu}{2}\int_{\Omega} (u_i(x)-m(x))^2\diff x
  \biggr\},
  \end{aligned}
\\[1ex]
f'(x_{0})=0 : z=f(x_{0}) \text{ is de horizontale raaklijn.}
\\[1ex]
\lim_{x\to x_{0}} f'(x)=\pm\infty : x=x_{0} \text{ is de verticale raaklijn.}
\\[1ex]
g(x_{0}){R}_{0} : z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})
  \text{ is de raaklijn.}
\end{dcases}
\end{equation}

\end{document} 

enter image description here

12
  • Thank you. It worked for me. However, the whole equations stills not left align. It looks like in centering
    – Jame
    Nov 7, 2015 at 12:31
  • @user8430 You should use the fleqn option to amsmath (or to the document class), if you want lft aligned equations. I see no reason for having just one equation left aligned: either all or none.
    – egreg
    Nov 7, 2015 at 13:36
  • How to just align the above equation? Because it is long equation so I would like to align it to left. Could you edit your answer for that work? Note that, other equation still centering
    – Jame
    Nov 7, 2015 at 14:36
  • 1
    @user8430 I don't understand why you'd want that. However, \begin{equation}\hspace{0pt}\begin{dcases}...\end{dcases}\hfill\end{equation} would do.
    – egreg
    Nov 7, 2015 at 14:47
  • Thanks. It worked. I just ask you one more think. How you can change position of equation number (Ex. (1),(2)) from bottom to middle?
    – Jame
    Nov 7, 2015 at 15:05
2

It is best to manually chose where the line break should occur:

enter image description here

Code:

\documentclass{article}

\usepackage{amsmath}

\newcommand{\diff}{\mathop{}\!d}
\begin{document}

\begin{equation}\label{eq:algin} 
\begin{cases}
u_i^{k+1}(x) =\arg \min_{u} \Bigg\{
{} \lambda\sum_{i=1}^{N}\int_{\Omega} r_i(x)u_i(x)\diff x \\
\qquad\qquad + \frac{\gamma}{2} \sum_{i=1}^{N}\int_{\Omega} \left( u_i(x)-m(x) \right)^2\diff x 
+ \frac{\mu}{2}\int_{\Omega} \left( u_i(x)-m(x) \right)^2\diff x
\Bigg\},
\\
f'(x_{0})=0 \text{ : } z=f(x_{0}) \text{ is de horizontale raaklijn.}
\\
\lim_{x\to x_{0}} f'(x)=\pm\infty \text{ : } x=x_{0} \text{ is de verticale raaklijn.}
\\
g(x_{0}){R}_{0} \text{ : } z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})
  \text{ is de raaklijn.}
\end{cases}
\end{equation}
\end{document} 
3
  • Is it possible to maintain equation tag. Because I am using equation tag through my paper. And the number of equation regards to middle of equation position. And I run your code. It works well but it did not align left without space. For example, let see my image above, the $\{$ similar position with "where"
    – Jame
    Nov 7, 2015 at 3:42
  • @user8430: Yeah, it should just use equation. Have updated solution. Nov 7, 2015 at 4:01
  • Thanks. Please see my updated figure. The equation still not align in left and numbering of equation must be the center. Thanks
    – Jame
    Nov 7, 2015 at 4:48
2

I wouldn't use a cases environment; a left\{ directive at the start and a \right. directive at the end of the equation environment requires much less computing overhead. Inside the \left\{ ... \right. pair, I'd use nested aligned instructions. The contents of aligned environments are automatically typeset in display-math style, which seems appropriate for the long (sub-)equation.

Incidentally, the inner \left( ... \right) directives in your code don't generate larger "fences", as the material they enclose isn't "large". I'd use \bigl( ... \bigr) instead.

(The horizontal line at the top of the following screenshot is there just to illustrate the width of the text block.)

enter image description here

\documentclass{article}
\usepackage[dutch]{babel}
\usepackage{mathtools} % for '\mathclap' macro
\newcommand{\diff}{\mathop{}\!d}

\begin{document}
\hrule  % just to illustrate width of textblock
\begin{equation}\label{eq:algin} 
\left\{
\begin{aligned}
&\begin{aligned}
u_i^{k+1}(x)
&=\arg\min_{u} \Biggl\{
\lambda\sum_{i=1}^{N}\int_{\Omega}\! r_i(x)u_i(x)\diff x \\
&\mkern25mu % select spacing adjustment to suit your page parameters
+ \frac{\gamma}{2} \sum_{i=1}^{N}\int_{\Omega}\! \bigl( u_i(x)-m(x) \bigr)^2\diff x 
+ \frac{\mu}{2}\int_{\Omega}\! \bigl( u_i(x)-m(x) \bigr)^2\diff x
\Biggr\},
\end{aligned}\\
&f'(x_{0})=0 \text{ : $z=f(x_{0})$ is de horizontale raaklijn.}\\
&\lim_{\mathclap{x\to x_{0}}} \ f'(x)=\pm\infty \text{ : $x=x_{0}$ is de verticale raaklijn.}\\
&g(x_{0}){R}_{0} \text{ : $z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})$ is de raaklijn.}
\end{aligned}
\right.
\end{equation}
\end{document}

Addendum to address the OP's follow-up query about how to go about having the equation number be placed at the bottom of the equation: In this case, I would work first and foremost to shorten one or more of the lines in the dcases environment. This may be done, e.g., by rearranging the structure of the multlined environment that governs the first two lines.

While you're at it, you may also want to make sure that the material in the numerators and denominators of the first two lines is typeset in display-style math mode rather than the default text-style math mode.

enter image description here

\documentclass{article}
\usepackage{mathtools}  % for 'dcases' and 'multlined' environments
\newcommand{\diff}{\mathop{}\!d}
% Variant form of \dfrac macro, which places both the numerator
% and the denominator in display math style
\newcommand\ddfrac[2]{\dfrac{\displaystyle#1}{\displaystyle#2}}
\begin{document}

\begin{equation}
\begin{dcases}
\begin{multlined} % let the 'multlined' environment encase both lines fully
u_i^{k+1}(x)
=\ddfrac{-\lambda r_i(x)+\gamma \bigl( r_i(x)+b_i(x)\bigr) +\gamma \bigl( \alpha-\beta\bigr)}{\theta}\\[2ex]
 -\ddfrac{\sigma \biggl[ -\lambda\int_{i=1}^N r_i(x) \diff x + \sigma\sum_{i=1}^N \bigl( r_i(x)-b_i(x)\bigr) +\gamma N \bigl( 1-r_i(x)\bigr)\biggr]}{\gamma\bigl( \sigma N -1\bigr)}\,,
\end{multlined}
\\[1ex]
f'(x_{0})=0 : z=f(x_{0}) \text{ is de horizontale raaklijn,}
\\[1ex]
\lim_{x\to x_{0}} f'(x)=\pm\infty : x=x_{0} \text{ is de verticale raaklijn,}
\\[0.5ex]
g(x_{0}){R}_{0} : z-f(x_{0})=f'(x_{0})\cdot(x-x_{0})
  \text{ is de raaklijn.}
\end{dcases}
\end{equation}
This is text \dots
\end{document}
5
  • Thank, it worked but the cases { stills far left corner. Let see my expected output in question
    – Jame
    Nov 7, 2015 at 9:30
  • I used packet \usepackage[dutch]{babel}, then my proof tag name becomes bewijs instead of Proofs:. For example \begin{proof} This is text of proof \end{proof}
    – Jame
    Nov 7, 2015 at 9:59
  • @user8430 - Using the babel package is definitely optional. I just thought it might be useful, since the text of your posting would appear to be in Dutch. If you'd rather not use the package, that's fine too.
    – Mico
    Nov 7, 2015 at 10:23
  • If we use dutch, We cannot display in English. Right?
    – Jame
    Nov 7, 2015 at 10:37
  • @user8430 - I'm not sure what you're trying to get at. The babel package can be loaded with several language options. If English is, in fact, the main document language (the code snippet you've provided notwithstanding), then by all means load the babel package with the option english.
    – Mico
    Nov 7, 2015 at 10:58

You must log in to answer this question.

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