2

I have the following code (don't mind about the lyrics: they are included just for comparison between text and math mode):

  \documentclass{article}
  \usepackage{amsmath}
  \usepackage{bm}
  \begin{document}
  I think about closing the door/And lately I think of it more/I'm living well out of my time/I feel like I'm losing my mind$\ |\ $I should be at the table round/A servant of the crown/The keeper of the sign/To sparkle and to shine

  \newlength{\supal}
  \settowidth{\supal}{$h_{(p+1,r,s-1)}$,}
  \begin{alignat*}{2}
  \uparrow=&
  \begin{cases}
  h_{(2,1,n-1)},&\ \text{if}\ n>2\,;\\
  \makebox[\supal][l]{$\bm2$,}&\ \text{if}\ n=2\,.
  \end{cases} &\downarrow=&
  \begin{cases}
  h_{(1,2,n)},&\ \text{if}\ n>2\,;\\
  \makebox[\supal][l]{$\bm1$,}&\ \text{if}\ n=2\,.
  \end{cases}\\[3mm]
  \uparrow\hspace{-1mm}\mbox{\tiny$\circ$}\,\bm j=&\,\pmb\uparrow\!\bm j\ ; & \downarrow\hspace{-1mm}\mbox{\tiny$\circ$}\,\bm j=&\,\pmb\downarrow\!\bm j\,.\\[3mm]
  \uparrow\hspace{-1mm}\mbox{\tiny$\circ$}\,h_{(p,r,s)}=&
  \begin{cases}
  h_{(p+1,r,s)},&\ \text{if}\ p+s-r<n\,;\\
  h_{(p+1,r,s-1)},&\ \text{if}\ p+s-r=n\ \text{and}\ s-r>1\,;\\
  \bm n,&\ \text{otherwise}\,.
  \end{cases} & & \\[3mm]
  \downarrow\hspace{-1mm}\mbox{\tiny$\circ$}\,h_{(p,r,s)}=&
  \begin{cases}
  h_{(p-1,r,s)},&\ \text{if}\ p>1\,;\\
  h_{(1,r+1,s)},&\ \text{if}\ p=1\ \text{and}\ s-r>1\,;\\
  \makebox[\supal][l]{$\bm1$,}&\ \text{otherwise}\,.
  \end{cases} & &
  \end{alignat*}
  \end{document}

The output is

enter image description here

The first cases environment with 3 clauses (third line in the alignat environment) has excessive width, which forces the second column to be far too right, even out of the margins (as the auxiliary lyrics shows). This occurs even though alignat environment places no spacing between columns.

I would like to know if there is a way to impose negative spacing between columns in the alignat environment; of course, in typical cases this would cause the corresponding (adjacent) columns to overlap, but not in my example.

  • if i had just one or two "too long" lines in the left-hand column, i would choose a line of a length that i like, and wrap (the right-hand side) of all longer lines in \mathrlap{...}, which will make latex ignore their length. requires mathtools. – barbara beeton May 29 '16 at 1:00
2

You can place the content you want to reduce the width of inside a box of fixed width that suits your needs.

Below I've created a similar mock-up to your scenario and placed the long content - a very long condition that is very long - inside a zero-width box that is left-aligned. This allows the upper-right cases to now be left-aligned to otherwise3:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
  a &= \begin{cases}
    b, \text{if $c = d$} \\
    e, \text{otherwise1}
  \end{cases} &
  f &= \begin{cases}
    g, \text{if $h = i$} \\
    j, \text{otherwise2}
  \end{cases} \\
  k &= \begin{cases}
    l, \makebox[0pt][l]{a very long condition that is very long} \\
    m, \text{otherwise3}
  \end{cases}
\end{alignat*}

\end{document}
  • Thank you very much. Although this does not address the general problem (genuine negative space between columns), it is a very clever solution. – Matemáticos Chibchas May 28 '16 at 6:14
  • @MatemáticosChibchas: You'd have to place negative space for a number of instances. In my approach you address the problem area and everything else takes care of itself. – Werner May 28 '16 at 16:12

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.