Remove vertical spacing around align* environment in tabularx cell

In summary, the code provided creates a table with equations in the Schrödinger and Heisenberg pictures. However, there is extra vertical space around the equations which can be removed by setting the lengths \abovedisplayskip, \belowdisplayskip, \abovedisplayshortskip, and \belowdisplayshortskip to 0pt.
  • #1
Wrichik Basu
Science Advisor
Insights Author
Gold Member
2,142
2,718
I have created a table which has some equations in it. The LaTeX code is as follows:

LaTeX code:
\documentclass[a4paper,12pt]{article}

\usepackage{mathtools}
\usepackage{physics}
\usepackage{tabularx}
\usepackage{makecell}

\newcommand{\tev}{\ensuremath{\mathcal{U}}}
\newcommand{\sch}[1]{\ensuremath{#1^\mathrm{(S)}}}
\newcommand{\hei}[1]{\ensuremath{#1^\mathrm{(H)}}}
\newcommand{\Ham}{\ensuremath{\mathcal{H}}}
\newcommand{\bfnt}[1]{{\bfseries #1}}
\newcommand{\ifnt}[1]{{\itshape #1}}

\begin{document}

\begin{center}
        \begin{tabularx}{\linewidth}{|l|X|X|}
            
            \hline
            
            {} & \multicolumn{1}{c|}{\bfnt{Schr\"odinger picture}} & \multicolumn{1}{c|}{\bfnt{Heisenberg picture}} \\
            
            \hline
            
            \textbf{State ket} & \makecell[X]{\vspace{0.2cm} Moving:\\%
            \vbox{%
                \begin{align*}
                \ket{\alpha, t_0; t} &= \tev \ket{\alpha, t_0} \\[0.5em]
                i \hbar \pdv{t} \ket{\alpha, t_0; t} &= \Ham \ket{\alpha, t_0; t}.
                \end{align*}%
            }} & Stationary \\
            
            \hline
            
            \textbf{Observable} & Stationary & \makecell[X]{\vspace{0.3cm} Moving:\\%
            \vbox{%
                \begin{align*}
                \hei{A}(t) &= \tev^\dagger(t) \sch{A} \tev(t) \\[0.7em]
                \dv{\hei{A}}{t} &= \dfrac{1}{i\hbar} \comm{\hei{A}}{\Ham}.
                \end{align*}%
            }} \\
            
            \hline
            
            \textbf{Base ket} & Stationary & \makecell[X]{\vspace{0.3cm} Moving oppositely:\\%
            \vbox{%
                \begin{align*}
                \ket{a', t}_\mathrm{H} &= \tev^\dagger \ket{a'}; \\[0.7em]
                i\hbar\pdv{t} \ket{a', t}_\mathrm{H} &= -\Ham \ket{a', t}_\mathrm{H}.
                \end{align*}%
            }} \\
            
            \hline
        
        \end{tabularx}
    \end{center}

\end{document}

The code renders as shown below:

2022-08-14_16-29-1.png

As you can see, there is a lot of extra vertical space around the align* environments, which I have marked with blue arrows. How can I remove this space?
 
Physics news on Phys.org
  • #2
The lengths you need to set are
Code:
\abovedisplayskip
\belowdisplayskip
\abovedisplayshortskip
\belowdisplayshortskip
 
  • Like
Likes Wrichik Basu
  • #3
@pasmith Thanks. Setting those lengths to 0pt reduced the spacing to what is normal. This is how it looks now:

1660491578041.png

The entire code (for future visitors):
LaTeX code:
\documentclass[a4paper,12pt]{article}

\usepackage{mathtools}
\usepackage{physics}
\usepackage{tabularx}
\usepackage{makecell}

\newcommand{\tev}{\ensuremath{\mathcal{U}}}
\newcommand{\sch}[1]{\ensuremath{#1^\mathrm{(S)}}}
\newcommand{\hei}[1]{\ensuremath{#1^\mathrm{(H)}}}
\newcommand{\Ham}{\ensuremath{\mathcal{H}}}
\newcommand{\bfnt}[1]{{\bfseries #1}}
\newcommand{\ifnt}[1]{{\itshape #1}}

\begin{document}

\bgroup

\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}

\begin{center}
        \begin{tabularx}{\linewidth}{|l|X|X|}
          
            \hline
          
            {} & \multicolumn{1}{c|}{\bfnt{Schr\"odinger picture}} & \multicolumn{1}{c|}{\bfnt{Heisenberg picture}} \\
          
            \hline
          
            \textbf{State ket} & \makecell[X]{\vspace{0.2cm} Moving:\\%
            \vbox{%
                \begin{align*}
                \ket{\alpha, t_0; t} &= \tev \ket{\alpha, t_0} \\[0.5em]
                i \hbar \pdv{t} \ket{\alpha, t_0; t} &= \Ham \ket{\alpha, t_0; t}.
                \end{align*}%
            }} & Stationary \\
          
            \hline
          
            \textbf{Observable} & Stationary & \makecell[X]{\vspace{0.3cm} Moving:\\%
            \vbox{%
                \begin{align*}
                \hei{A}(t) &= \tev^\dagger(t) \sch{A} \tev(t) \\[0.7em]
                \dv{\hei{A}}{t} &= \dfrac{1}{i\hbar} \comm{\hei{A}}{\Ham}.
                \end{align*}%
            }} \\
          
            \hline
          
            \textbf{Base ket} & Stationary & \makecell[X]{\vspace{0.3cm} Moving oppositely:\\%
            \vbox{
                \begin{align*}
                \ket{a', t}_\mathrm{H} &= \tev^\dagger \ket{a'}; \\[0.7em]
                i\hbar\pdv{t} \ket{a', t}_\mathrm{H} &= -\Ham \ket{a', t}_\mathrm{H}.
                \end{align*}
            }} \\
          
            \hline
      
        \end{tabularx}
    \end{center}

\egroup

\end{document}
 

FAQ: Remove vertical spacing around align* environment in tabularx cell

How can I remove the vertical spacing around the align* environment in a tabularx cell?

To remove the vertical spacing around the align* environment in a tabularx cell, you can use the command \setlength{\abovedisplayskip}{0pt} before the align* environment. This will set the spacing above the environment to 0pt, effectively removing it.

What is the purpose of the align* environment in a tabularx cell?

The align* environment is used to align equations in a tabularx cell. It allows for multiple equations to be aligned at specific points, making it easier to present mathematical expressions in a table format.

Can I remove the vertical spacing for just one specific tabularx cell?

Yes, you can use the \setlength command within the specific tabularx cell to remove the vertical spacing. For example, you can use \setlength{\abovedisplayskip}{0pt} at the beginning of the cell and \setlength{\belowdisplayskip}{0pt} at the end to remove both the spacing above and below the align* environment in that cell.

How can I adjust the vertical spacing around the align* environment in a tabularx cell?

You can adjust the vertical spacing around the align* environment by changing the value in the \setlength command. For example, setting \setlength{\abovedisplayskip}{5pt} will add 5pt of space above the align* environment.

Are there any other ways to remove vertical spacing in a tabularx cell?

Yes, you can also use the \vspace command before or after the align* environment to add or remove vertical spacing. Additionally, you can use the \vskip command to add or remove space above or below the align* environment. However, using \setlength is the most common and recommended method for removing vertical spacing in a tabularx cell.

Similar threads

Replies
3
Views
537
Replies
1
Views
2K
Replies
2
Views
5K
Replies
2
Views
2K
Replies
0
Views
2K
Replies
4
Views
4K
Replies
789
Views
732K
Back
Top