Using phantom in align environment

  • MHB
  • Thread starter Dustinsfl
  • Start date
In summary, using the aligned environment rather than alignat* can help to remove unwanted white space while maintaining proper alignment within the align environment. Additionally, using the tabbing environment can provide more control over alignment, particularly when interrupted by text in-between environments.
  • #1
Dustinsfl
2,281
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
  • #2
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:
  • #3
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.
 
  • #4
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/.
 
  • #5


If you need to keep the spacing of the previous align environment but want to remove the extra white space, you can use the \vphantom command instead of \phantom. This will create an invisible vertical space that will maintain the spacing without adding any visible elements. Alternatively, you can use \smash to remove the vertical space altogether, but this may affect the alignment of your equations. It is important to note that using \phantom or \vphantom may also affect the spacing of your equations if they contain elements such as fractions or exponents, so it is important to test and adjust accordingly.
 

FAQ: Using phantom in align environment

What is a "phantom" in the align environment?

A "phantom" is a command used in the align environment in LaTeX that creates an invisible element without any width or height. It is typically used to align equations or text in the same column as other elements without affecting the layout.

How do I use a phantom in the align environment?

To use a phantom in the align environment, you can use the command \phantom{content}, where "content" is the text or equation you want to create a phantom of. This will create an invisible element that takes up the same space as the content.

Can I use a phantom in the align environment to align multiple equations?

Yes, you can use multiple phantoms in the align environment to align multiple equations or text in the same column. Just make sure to use the same number of phantoms in each line to maintain the alignment.

Is it possible to change the size or style of a phantom in the align environment?

Yes, you can change the size and style of a phantom in the align environment by using the commands \hphantom{content} for a horizontal phantom and \vphantom{content} for a vertical phantom. You can also add formatting commands within the curly braces to change the style of the phantom.

What other environments can I use a phantom in besides the align environment?

You can use a phantom in various other environments in LaTeX, such as equation, gather, and alignat. It can also be used in regular text to create invisible spaces or to align text in tables.

Similar threads

Back
Top