Using phantom in align environment

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

Discussion Overview

The discussion revolves around formatting issues in LaTeX, specifically regarding the use of the align and aligned environments to manage spacing and alignment in mathematical expressions. Participants explore how to maintain consistent spacing while minimizing unwanted white space in their equations.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks to eliminate extra white space caused by an additional row in the align environment while keeping the spacing consistent with a previous align section.
  • Another participant suggests using the aligned environment instead of alignat* to achieve better spacing and alignment.
  • A later reply proposes using the phantom command to maintain the same space for the left side of the top row as another expression, while also aligning it closer to the equals sign.
  • One participant notes that while the suggested changes remove white space, they do not align correctly with the previous align environment.
  • Another participant introduces the tabbing environment as a potential solution for more precise control over alignment, referencing external resources for further exploration.

Areas of Agreement / Disagreement

Participants express differing opinions on the best approach to manage spacing and alignment, with no consensus reached on a single solution. Multiple methods are proposed, each with its own advantages and drawbacks.

Contextual Notes

Some participants mention limitations in alignment consistency when switching between environments, indicating that the solutions may depend on specific formatting needs and the context of the equations.

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