MHB Using phantom in align environment

  • Thread starter Thread starter Dustinsfl
  • Start date Start date
AI Thread Summary
The discussion focuses on addressing the issue of excessive white space caused by an extra align row in LaTeX formatting. The goal is to maintain the desired spacing while eliminating the unwanted gap. A suggested solution involves using the "aligned" environment instead of "alignat*," which allows for better control over alignment. To achieve the same space for the left side of the top row as another equation, a combination of the "phantom" command and "llap" is recommended. This method effectively aligns the equations without introducing additional white space. However, concerns are raised about alignment accuracy when using the "aligned" environment, with suggestions to consider the "tabbing" environment for more precise control over alignment consistency across different environments.
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/.
 
Back
Top