9

I have a few aligned lists of coefficients. One set of coefficients has three columns and the other has four. At the moment I display them with two align environments:

\begin{align}
   \gamma_1 &= 8/15 & \gamma_2 &= 5/12   & \gamma_3 &= 3/4 \\
   \zeta_1  &= 0    & \zeta_2  &= -17/60 & \zeta_3  &= -5/12 \\
   \beta_1  &= 4/15 & \beta_2  &= 1/15   & \beta_3  &= 1/6
\end{align}
\begin{align}
   a_0 &= 0 & a_1 &= 8/15 & a_2 &= 2/3 & a_3 &= 1
\end{align}

The alignment and spacing between elements in each row is exactly as I want but there is too much space between the three column coefficients and the four column coefficients. Essentially, I want the alignment to reset at a certain point so that the next line of the align environment has four columns and is centered.

I learned about the aligned environment as I searched for an answer. The question asked there is essentially what I am asking, but the code provided there does not do what I want. I have not successfully been able to produce code to do exactly what I want.

This is the closest I can get:

\begin{align}
   \begin{aligned}
      \gamma_1 &= 8/15 & \gamma_2 &= 5/12   & \gamma_3 &= 3/4 \\
      \zeta_1  &= 0    & \zeta_2  &= -17/60 & \zeta_3  &= -5/12 \\
      \beta_1  &= 4/15 & \beta_2  &= 1/15   & \beta_3  &= 1/6 \\
   \end{aligned} \\
   \begin{aligned}
      a_0 &= 0 & a_1 &= 8/15 & a_2 &= 2/3 & a_3 &= 1
   \end{aligned}
\end{align}

This has two problems:

  1. The coefficients are compressed rather than expanded as they are with two aligns.
  2. Each aligned environment has one equation number. I'd prefer to refer to each set of coefficients (gamma, zeta, beta, and a) directly.

Likely I could manipulate the spacing at the bottom and/or top of the align environment and use my original code, but that's sloppy and I'm confident a simple way to do what I want exists but I'm not aware of it.

Also, the a0 and a3 coefficients are required to be 0 and 1 respectively by definition, so I can leave one out, but I want to include both of them for clarity.

4 Answers 4

3

You can play around with columns to fool the alignment mechanism as:

\begin{align}
   \gamma_1 &= 8/15 &&& \gamma_2&= 5/12         &&& \gamma_3 &= 3/4 &\\
   \zeta_1  &= 0    &&& \zeta_2&= -17/60        &&& \zeta_3  &= -5/12& \\
   \beta_1  &= 4/15 &&& \beta_2&= 1/15          &&& \beta_3  &= 1/6&\\
     a_0 ={}&0      &&& a_1 = 8/15 && a_2 = 2/3 &&&\qquad a_3 = 1
\end{align}

enter image description here

but with all due respect, what you want to do, does not read well. I would have done something like the following

\begin{align}
   \gamma_1 &= 8/15 & \gamma_2&= 5/12  & \gamma_3 &= 3/4 \\
   \zeta_1  &= 0    & \zeta_2&= -17/60 & \zeta_3  &= -5/12 \\
   \beta_1  &= 4/15 & \beta_2&= 1/15   & \beta_3  &= 1/6\\
        a_0 &= 0    & a_1    &= 8/15   & a_2      &= 2/3 \\ \notag
            &       & a_3    &= 1      &          &
\end{align}

enter image description here

You can deliberately put some vertical space between the first three and the last to highlight the grouping effect which is, in my opinion, more important in order to convey the message rather than to be able to command a LaTeX array.

6
  • Now that I actually see the combined alignment, I agree that it does not read well. I'm not a complete fan of your three column solution, but I'll use either that or I'll cut out a0. Thanks! Dec 12, 2011 at 16:40
  • @BenTrettel you can further align the last two rows such that they get the equation number vertically centered. That would emphasize the grouping, but I agree this barely serves the purpose. In my research we usually use the vector notation to circumvent such problems but I don't know your context.
    – percusse
    Dec 12, 2011 at 18:04
  • @percusse -- a format niggle. in the first instance of equation (10) the spacing is bad in the a_0 "cell". if you change that to a_0 ={}&0 the spacing will be fixed. Dec 12, 2011 at 19:07
  • @barbarabeeton Wow, thank you. Actually I am not too fond of this answer anyway since it is kind of hackish and doesn't solve the problem but I will edit in a second. Nevertheless, feel free whenever you feel like editing next time.
    – percusse
    Dec 12, 2011 at 19:13
  • @percusse -- i don't love the appearance either, but the spacing annoyed me more. <g> i thought about editing it directly, but i have no practice in updating images, and didn't want to leave inconsistent input/output, so i went the comment route. the cell in question looks much nicer now. Dec 12, 2011 at 19:43
5

For full control of the alignment you can use the alignat environment.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}   % loads »amsmath«

\begin{document}
  \begin{alignat}{4}
        &          & \gamma_1  &= 8/15\qquad & \gamma_2 &= 5/12         & \gamma_3 &= 3/4 \\
        &          & \zeta_1   &= 0          & \zeta_2  &= -17/60\qquad & \zeta_3  &= -5/12 \\
        &          & \beta_1   &= 4/15       & \beta_2  &= 1/15         & \beta_3  &= 1/6 \\
    a_0 &= 0\qquad & a_1       &= 8/15       & a_2      &= 2/3          & a_3      &= 1
  \end{alignat}
\end{document}

enter image description here

2

Here is one viable alternative to your alignment issue:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align}
   \smash{\begin{array}[t]{*{2}{r@{\;}l@{\qquad}}r@{\;}l}
     \gamma_1 &= 8/15 & \gamma_2 &= 5/12   & \gamma_3 &= 3/4 \\[\jot]
     \zeta_1  &= 0    & \zeta_2  &= -17/60 & \zeta_3  &= -5/12 \\[\jot]
     \beta_1  &= 4/15 & \beta_2  &= 1/15   & \beta_3  &= 1/6 
   \end{array}} \label{gammas} \\ \label{zetas} \\ \label{betas} \\
  \begin{array}[t]{*{3}{r@{\;}l@{\qquad}}r@{\;}l}
    a_0 &= 0 & a_1 &= 8/15 & a_2 &= 2/3 & a_3 &= 1
  \end{array} \label{as}
\end{align}
$\gamma$ is~\eqref{gammas}, $\zeta$ is~\eqref{zetas}, $\beta$ is~\eqref{betas} and $a$ is~\eqref{as}.
\end{document}​

The equation elements are placed inside an array. Proper vertical alignment is assured using \\[\jot], while horizontal adjustment is obtained via \qquad for the column spacing. Modify this to suit your need (to say \quad, or \hspace{<len>} where <len> is any known TeX length unit).

2
  • Thanks. I clarified my problem in the question --- you might want to check that out again. The issue with the spacing between the three and four column parts is resolved by removing the \end{align} and \begin{align} parts in the middle and tweaking the remainder slightly. This is almost what I want --- I just need to figure out how to get the desired spacing between elements in each row. Dec 12, 2011 at 16:35
  • @BenTrettel: Oh, it was not clear at first. I thought your main concern was with the horizontal spacing, not necessarily vertical. I've corrected for both using an array in my updated answer using \qquad between elements.
    – Werner
    Dec 12, 2011 at 16:59
2

A very crude solution is to simply subtract some vertical space.

\begin{align}
   \gamma_1 &= 8/15 & \gamma_2 &= 5/12   & \gamma_3 &= 3/4 \\
   \zeta_1  &= 0    & \zeta_2  &= -17/60 & \zeta_3  &= -5/12 \\
   \beta_1  &= 4/15 & \beta_2  &= 1/15   & \beta_3  &= 1/6
\end{align}
\vspace{-\belowdisplayskip}
\vspace{-\abovedisplayskip}
\vspace{-3\jot}
\begin{align}
   a_0 &= 0 & a_1 &= 8/15 & a_2 &= 2/3 & a_3 &= 1
\end{align}

enter image description here

It's not perfect though. Does anyone know what the separation between lines in align is?

2
  • I thought about trying something like this but I considered this approach to be too crude. I would be interested in knowing what the separation between lines in align is too. Dec 12, 2011 at 16:46
  • After a quick search I found nothing on the space between rows in align. Lots on how to modify it with adding space to \jot though. If we can figure out what it is then it's an easy thing to do.
    – qubyte
    Dec 12, 2011 at 16:49

You must log in to answer this question.

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