MHB Align Environment Part 2: Narrow the Gap

  • Thread starter Thread starter Dustinsfl
  • Start date Start date
AI Thread Summary
To narrow the gap between the second and third items in the LaTeX equations, using the alignat environment is recommended. This environment allows for precise control over spacing by specifying the number of columns and eliminating unwanted gaps. By incorporating additional spacing commands like \quad, users can further refine the layout. The alignat* feature is particularly favored for its ability to enhance the visual alignment of equations, making them more readable in both forum posts and PDFs.
Dustinsfl
Messages
2,217
Reaction score
5
\begin{align}
\tau = k_1e_0t, & u = \frac{s}{s_0}, & v_1 = \frac{c_1}{e_0}, & v_2 = \frac{c_2}{e_0},\notag\\
a_1 = \frac{k_{-1}}{k_1s_0}, & a_2 = \frac{k_2}{k_1s0}, & a_3 = \frac{k_3}{k_1}, & a_4 = \frac{k_{-3}}{k_1s_0},\notag\\
a_5 = \frac{k_4}{k_1s_0}, & \epsilon = \frac{e_0}{s_0}, & & \notag
\end{align}

How can I narrow the gap between the 2nd and 3rd items? The gap is a lot worse in a pdf compared to on the forum too.
 
Physics news on Phys.org
The standard way is to use two &'s for each column: one before = to align each column on equalities and one between columns. Thus, an environment with n column has 2n - 1 &'s in every line.

\begin{align*}
\tau &= k_1e_0t, & u &= \frac{s}{s_0}, & v_1 &= \frac{c_1}{e_0}, & v_2 &= \frac{c_2}{e_0},\notag\\
a_1 &= \frac{k_{-1}}{k_1s_0}, & a_2 &= \frac{k_2}{k_1s0}, & a_3 &= \frac{k_3}{k_1}, & a_4 &= \frac{k_{-3}}{k_1s_0},\notag\\
a_5 &= \frac{k_4}{k_1s_0}, & \epsilon &= \frac{e_0}{s_0}
\end{align*}

To control the spacing between columns, use the alignat environment, which accepts an argument specifying the number of columns. Then the spacing between columns is eliminated. You can therefore specify spacing explicitly using \quad, etc.

\begin{alignat*}{4}
\tau &= k_1e_0t, & u &= \frac{s}{s_0}, & v_1 &= \frac{c_1}{e_0}, & v_2 &= \frac{c_2}{e_0},\notag\\
a_1 &= \frac{k_{-1}}{k_1s_0}, &\quad a_2 &= \frac{k_2}{k_1s0}, &\quad a_3 &= \frac{k_3}{k_1}, &\quad a_4 &= \frac{k_{-3}}{k_1s_0},\notag\\
a_5 &= \frac{k_4}{k_1s_0}, & \epsilon &= \frac{e_0}{s_0}
\end{alignat*}
 
I like the alignat* feature.
 
Back
Top