Using phantom in align environment

  • Context: MHB 
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on managing white space in LaTeX align environments, specifically addressing the use of the phantom command to control spacing without introducing unwanted gaps. Users suggest replacing the alignat* environment with the aligned environment for better alignment control. The proposed solution involves using \llap to ensure that the left side of the top row aligns correctly with previous rows while maintaining the desired spacing. This approach effectively eliminates excess white space while preserving alignment.

PREREQUISITES
  • Understanding of LaTeX typesetting, specifically the align and aligned environments.
  • Familiarity with the phantom and \llap commands in LaTeX.
  • Basic knowledge of matrix representation in LaTeX.
  • Experience with LaTeX document structure and formatting.
NEXT STEPS
  • Research the differences between alignat* and aligned environments in LaTeX.
  • Learn advanced usage of the phantom command for spacing control in LaTeX.
  • Explore the \llap command and its applications in aligning LaTeX content.
  • Investigate the tabbing environment in LaTeX for enhanced alignment control.
USEFUL FOR

This discussion is beneficial for LaTeX users, mathematicians, and researchers who require precise control over document formatting and alignment, particularly in mathematical typesetting.

Dustinsfl
Messages
2,217
Reaction score
5
The extra align row at the top contributes a lot of white space but I need phantom equal at spacing of a previous align above it. How can I keep the spacing but remove the white space gap?
Code:
\begin{alignat*}{3}
\phantom{\sigma_1:} & \phantom{\begin{bmatrix}
3 - \sigma_1 & -10 & 0\\
-10 & 0 - \sigma_1 & 30\\
0 & 30 & -27 - \sigma_1
\end{bmatrix}} & \phantom{=} &\phantom{\begin{bmatrix}
3 + 47 & -10 & 0\\
-10 & 47 & 30\\
0 & 30 & -27 + 47
\end{bmatrix}}\\
\sigma_3: & \begin{bmatrix}
3 - \sigma_3 & -10 & 0\\
-10 & 0 - \sigma_3 & 30\\
0 & 30 & -27 - \sigma_3
\end{bmatrix} & = & \begin{bmatrix}
3 - 23 & -10 & 0\\
-10 & -23 & 30\\
0 & 30 & -27 - 23
\end{bmatrix}\\
 & & = & \begin{bmatrix}
-20 & -10 & 0\\
-10 & -23 & 30\\
0 & 30 & -50
\end{bmatrix}\\
 & & = & \begin{bmatrix}
-2 & -1 & 0\\
-10 & -23 & 30\\
0 & 3 & -5
\end{bmatrix}\\
 & & = & \begin{bmatrix}
-2 & -1 & 0\\
0 & -18 & 30\\
0 & 3 & -5
\end{bmatrix}\\
 & & = & \begin{bmatrix}
-2 & -1 & 0\\
0 & -3 & 5\\
0 & 3 & -5
\end{bmatrix}\\
 & & = & \begin{bmatrix}
-2 & -1 & 0\\
0 & -3 & 5\\
0 & 0 & 0
\end{bmatrix}\\
\end{alignat*}
 
Physics news on Phys.org
I would use the aligned environment rather than alignat*.
Code:
\begin{aligned}
\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3 \end{bmatrix} 
& = \begin{bmatrix}3 - 23 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -27 - 23\end{bmatrix} \\ 
& = \begin{bmatrix}-20 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -50\end{bmatrix} \\ 
& = \begin{bmatrix}-2 & -1 & 0 \\-10 & -23 & 30 \\0 & 3 & -5\end{bmatrix} \\
& = \begin{bmatrix}-2 & -1 & 0 \\0 & -18 & 30 \\0 & 3 & -5\end{bmatrix} \\
& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 3 & -5\end{bmatrix} \\
& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 0 & 0\end{bmatrix} \\ 
\end{aligned}
That produces $$\begin{aligned}\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3
\end{bmatrix} & = \begin{bmatrix}3 - 23 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -27 - 23\end{bmatrix} \\ & = \begin{bmatrix}-20 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -50\end{bmatrix} \\ & = \begin{bmatrix}-2 & -1 & 0 \\-10 & -23 & 30 \\0 & 3 & -5\end{bmatrix} \\& = \begin{bmatrix}-2 & -1 & 0 \\0 & -18 & 30 \\0 & 3 & -5\end{bmatrix} \\& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 3 & -5\end{bmatrix} \\& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 0 & 0\end{bmatrix} \\ \end{aligned}$$

Edit. If you want the left side of the top row to occupy the same space as $\sigma_1: \begin{bmatrix}3 - \sigma_1 & -10 & 0 \\ -10 & 0 - \sigma_1 & 30\\0 & 30 & -27 - \sigma_1 \end{bmatrix}$ then (in the above code) you can replace
Code:
\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3 \end{bmatrix}
by
Code:
\phantom{\sigma_1: \begin{bmatrix}3 - \sigma_1 & -10 & 0 \\-10 & 0 - \sigma_1 & 30 \\0 & 30 & -27 - \sigma_1 \end{bmatrix}}
 \llap{$\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3 \end{bmatrix}$}
That material will be aligned close to the $=$ sign, without unwanted white space.
 
Last edited:
Opalg said:
I would use the aligned environment rather than alignat*.
Code:
\begin{aligned}
\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3 \end{bmatrix} 
& = \begin{bmatrix}3 - 23 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -27 - 23\end{bmatrix} \\ 
& = \begin{bmatrix}-20 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -50\end{bmatrix} \\ 
& = \begin{bmatrix}-2 & -1 & 0 \\-10 & -23 & 30 \\0 & 3 & -5\end{bmatrix} \\
& = \begin{bmatrix}-2 & -1 & 0 \\0 & -18 & 30 \\0 & 3 & -5\end{bmatrix} \\
& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 3 & -5\end{bmatrix} \\
& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 0 & 0\end{bmatrix} \\ 
\end{aligned}
That produces $$\begin{aligned}\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3
\end{bmatrix} & = \begin{bmatrix}3 - 23 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -27 - 23\end{bmatrix} \\ & = \begin{bmatrix}-20 & -10 & 0 \\-10 & -23 & 30 \\0 & 30 & -50\end{bmatrix} \\ & = \begin{bmatrix}-2 & -1 & 0 \\-10 & -23 & 30 \\0 & 3 & -5\end{bmatrix} \\& = \begin{bmatrix}-2 & -1 & 0 \\0 & -18 & 30 \\0 & 3 & -5\end{bmatrix} \\& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 3 & -5\end{bmatrix} \\& = \begin{bmatrix}-2 & -1 & 0 \\0 & -3 & 5 \\0 & 0 & 0\end{bmatrix} \\ \end{aligned}$$

Edit. If you want the left side of the top row to occupy the same space as $\sigma_1: \begin{bmatrix}3 - \sigma_1 & -10 & 0 \\ -10 & 0 - \sigma_1 & 30\\0 & 30 & -27 - \sigma_1 \end{bmatrix}$ then (in the above code) you can replace
Code:
\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3 \end{bmatrix}
by
Code:
\phantom{\sigma_1: \begin{bmatrix}3 - \sigma_1 & -10 & 0 \\-10 & 0 - \sigma_1 & 30 \\0 & 30 & -27 - \sigma_1 \end{bmatrix}}
 \llap{$\sigma_3: \begin{bmatrix}3 - \sigma_3 & -10 & 0 \\-10 & 0 - \sigma_3 & 30 \\ 0 & 30 & -27 - \sigma_3 \end{bmatrix}$}
That material will be aligned close to the $=$ sign, without unwanted white space.


Thanks it did remove the white space, but it doesn't align correct then with the align environment above it.
 
The tabbing environment provides more direct control over where things align, and you can make them consistent even when interrupted by text in-between environments. See http://www.mathhelpboards.com/f26/possibly-tricky-alignment-problem-1493/. Also see http://www.mathhelpboards.com/f26/align*-environment-inside-tabbing-environment-2150/.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
2K
  • · Replies 21 ·
Replies
21
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
3
Views
2K