LaTeX Remove vertical spacing around align* environment in tabularx cell

  • Thread starter Thread starter Wrichik Basu
  • Start date Start date
  • Tags Tags
    Cell Vertical
AI Thread Summary
The discussion revolves around optimizing LaTeX code for a table containing equations in both the Schrödinger and Heisenberg pictures of quantum mechanics. The initial code resulted in excessive vertical spacing around the align* environments, which was addressed by adjusting specific lengths: \abovedisplayskip, \belowdisplayskip, \abovedisplayshortskip, and \belowdisplayshortskip, setting them to 0pt. This adjustment effectively normalized the spacing, leading to a more visually appealing output. The final code reflects these changes, providing a cleaner presentation of the equations within the table.
Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,180
Reaction score
2,717
I have created a table which has some equations in it. The LaTeX code is as follows:

[CODE title="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}[/CODE]

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
The lengths you need to set are
Code:
\abovedisplayskip
\belowdisplayskip
\abovedisplayshortskip
\belowdisplayshortskip
 
  • Like
Likes Wrichik Basu
@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):
[CODE title="LaTeX code" highlight="19-22"]\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}[/CODE]
 

Similar threads

Replies
3
Views
2K
Replies
1
Views
3K
Replies
2
Views
6K
Replies
2
Views
3K
Replies
4
Views
4K
Replies
766
Views
737K
Back
Top