Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\begin{dmath*}
y_{ic}[n] = \begin{dcases}
                          y_0 + x_0 - x_0 (1 - k_2)^n & k_1 = 0 \\
                          k_5 + \left( y_0 - k_5 \right) (1 - k_1)^n + \begin{dcases}
                                             x_0 k_1 n (1 - k_1)^{n-1} & k_1 \neq 0, k_1 = k_2 \\
                                             x_0 \frac{k_2}{k_1 - k_2} \left[ \begin{split}&(1 - k_2)^n \\ & - (1 - k_1)^n \end{split} \right] & k_1 \neq 0, k_1 \neq k_2
                                                                                             \end{dcases}
                  \end{dcases}
\end{dmath*}

enter image description here

Is there any way I can get the conditions, which come from multiple dcases nesting levels, to appear in a single vertical column? (This would not only look nicer but save a lot of horizontal space, allowing the LHS of the entire equation to fit on the same line instead of wrapping.)


Followup: The solution provided by Harish worked very nicely... and then I noticed that I didn't need a separate case for $k_1 = 0$ (The analysis was different but led to the same result as the others -- I guess that's fairly common with partial fraction expansions).

enter image description here

share|improve this question
2  
I believe it would be clearer with a single three item cases environment. –  egreg Dec 31 '12 at 17:11
1  
Related: How to align nested cases? –  Werner Dec 31 '12 at 17:48
    
@Werner: I already found and tried to apply that approach... but it didn't work correctly since my third row is taller than the minimum. –  Ben Voigt Dec 31 '12 at 18:27
    
IMHO using Iversonians or Characteristic Functions instead of case-based definitions would make this expression clearer. –  Marc van Dongen Jan 1 '13 at 9:02
add comment

3 Answers

up vote 10 down vote accepted

If I were to do this, I would have listened to egreg's comments above. But the following works though coding may be ugly:

\documentclass{article}
\usepackage{mathtools,breqn}
\begin{document}
  \begin{dmath*}
y_{ic}[n] = \begin{dcases}
                          y_0 + x_0 - x_0 (1 - k_2)^n & k_1 = 0 \\
                          k_5 + \left( y_0 - k_5 \right) (1 - k_1)^n + \begin{dcases}
                                             x_0 k_1 n (1 - k_1)^{n-1}  &  \makebox[-11pt][l]{$k_1 \neq 0, k_1 = k_2$}\\
                                             x_0 \frac{k_2}{k_1 - k_2} \left[ \begin{aligned}(1 - k_2)^n \\  - (1 - k_1)^n \end{aligned} \right] & \makebox[-11pt][l]{$k_1 \neq 0, k_1 \neq k_2$}   
                                             \end{dcases}                                         
                  \end{dcases}
\end{dmath*}
\end{document}

enter image description here

share|improve this answer
add comment

I think I would do it in the way that egreg hinted at, and just use one dcases envrionment

screenshot

Note that I have replaced your split environment with an array and used @{}c@{} to remove column space (check your original .log file- you should have got a warning that you weren't allowed to use split in that context).

MWE

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\[
y_{ic}[n] = 
    \begin{dcases}
          y_0 + x_0 - x_0 (1 - k_2)^n & k_1 = 0 \\
          k_5 + \left( y_0 - k_5 \right) (1 - k_1)^n + x_0 k_1 n (1 - k_1)^{n-1} & k_1 \neq 0, k_1 = k_2 \\
          k_5 + \left( y_0 - k_5 \right) (1 - k_1)^n+ x_0 \frac{k_2}{k_1 - k_2} \left[ \begin{array}{@{}c@{}}(1 - k_2)^n \\ - (1 - k_1)^n \end{array} \right] & k_1 \neq 0, k_1 \neq k_2
    \end{dcases}
\]
\end{document}
share|improve this answer
add comment

Here are some more options that you could explore. Note that cases and friends can be easily emulated using an ordinary array:

enter image description here

\documentclass{article}
\begin{document}
\[
  \setbox1=\hbox{$k_1 \neq 0, k_1 = k_2$}
  y_{ic}[n] = \left\{\begin{array}{@{}l@{\quad}l}
    y_0 + x_0 - x_0 (1 - k_2)^n, & \hspace*{\dimexpr-1em-\wd1-\nulldelimiterspace}k_1 = 0 \\[2\jot]
    k_5 + (y_0 - k_5) (1 - k_1)^n + \left\{\begin{array}{@{}l@{\quad}l@{}}
      x_0 k_1 n (1 - k_1)^{n-1}, & k_1 \neq 0, k_1 = k_2 \\[\jot]
      \frac{x_0 k_2}{k_1 - k_2} [(1 - k_2)^n - (1 - k_1)^n], & k_1 \neq 0, k_1 \neq k_2
    \end{array}\right.
  \end{array}\right.
\]

\bigskip

\[
  \setbox1=\hbox{$k_1 \neq 0, k_1 = k_2$}
  y_{ic}[n] = \left\{\begin{array}{@{}l@{\quad}l}
    y_0 + x_0 - x_0 (1 - k_2)^n, & \hspace*{\dimexpr-1em-\wd1-\nulldelimiterspace}k_1 = 0 \\[2\jot]
    k_5 + (y_0 - k_5) (1 - k_1)^n \\ \qquad {} + \left\{\begin{array}{@{}l@{\quad}l@{}}
      x_0 k_1 n (1 - k_1)^{n-1}, & k_1 \neq 0, k_1 = k_2 \\[\jot]
      \frac{x_0 k_2}{k_1 - k_2} [(1 - k_2)^n - (1 - k_1)^n ], & k_1 \neq 0, k_1 \neq k_2
    \end{array}\right.
  \end{array}\right.
\]
\end{document}

The space-correction in the first row consists of 3 parts:

  1. An em skip, stemming from the forced @{\quad} in the separation between the two columns;
  2. \wd1 (or the width of \box1) equal to the width of the condition(s) in row 2 and 3;
  3. \nulldelimiterspace, since using \right. actually inserts a small gap.
share|improve this answer
    
What you've done is make both rows in the subordinate case block the same height... an inline fraction makes that possible but ugly. I'd already tried this with a display-mode fraction, but the braces and conditions didn't line up then. Thanks for the ideas though. –  Ben Voigt Dec 31 '12 at 18:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.