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?

David Carlisle
  • 757,742
theHigherGeometer
  • 2,027
  • 2
  • 15
  • 24

1 Answers1

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.

Moriambar
  • 11,466
Werner
  • 603,163