4

I've seen these questions, but in my case the equation content is too long to add the text description at the end and it overflows into the margin.

\[
d_i(g_n,\ldots,g_0) =
\begin{cases}
 (d_0g_ng_{n-1},g_{n-2},\ldots,g_0),& \text{if $i=0$;}\\
 (d_ig_n,\ldots,d_1g_{n-i+1},d_0g_{n-i}g_{n-i-1},g_{n-i-2},\ldots,g_0), &\text{if  $i=1,\ldots,n-1$;}\\
 (d_ng_n,\ldots,d_1g_1),& \text{if $i=0$}
 \end{cases}\\
\]

What I'd like is something similar to would be produced by replacing the one overly long line by the two lines

 (d_ig_n,\ldots,d_1g_{n-i+1},d_0g_{n-i}g_{n-i-1},g_{n-i-2},\ldots,g_0), &\\
 & \hspace{-10.5ex}\text{if  $i=1,\ldots,n-1$;}\

...but this is clearly not the way to do it. I'd also prefer not to break the long equation itself onto two lines, only put the text on the next line. Is there some nice way that will end up with the result that the semicolons are aligned automatically without tweaking the horizontal spacing?

5

In direct answer to your question (that is, keep the lengthy equation on one line, and the condition on another with aligned semi-colon), using \phantom and a left overlap can help obtain the appropriate alignment:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\begin{document}
\[
d_i(g_n,\ldots,g_0) =
\begin{cases}
 (d_0g_ng_{n-1},g_{n-2},\ldots,g_0),& \text{if $i=0$;} \\
 (d_ig_n,\ldots,d_1g_{n-i+1},d_0g_{n-i}g_{n-i-1},g_{n-i-2},\ldots,g_0), &\text{if  $i=1,\ldots,n-1$;} \\
 (d_ng_n,\ldots,d_1g_1),& \text{if $i=0$}
 \end{cases}
\]

\[
d_i(g_n,\ldots,g_0) =
\begin{cases}
 (d_0g_ng_{n-1},g_{n-2},\ldots,g_0),& \text{if $i=0$;} \\
 (d_ig_n,\ldots,d_1g_{n-i+1},d_0g_{n-i}g_{n-i-1},g_{n-i-2},\ldots,g_0), \\
   & \phantom{\text{if $i=0$;}}\llap{\text{if  $i=1,\ldots,n-1$;}} \\
 (d_ng_n,\ldots,d_1g_1),& \text{if $i=0$}
 \end{cases}
\]
\end{document}

\phantom{\text{if $i=0$;}} ensures that your far enough "to the right" in terms of conditional construction, while \llap sets a zero-width box that is right-aligned (resulting in a left overlap) to properly align with the semi-colon of the first case.

  • Wow, thanks! That was quick. I knew there should be a sensible way to do it. – David Roberts Jan 25 '13 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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