我刚刚注意到 Donald Arseneau 的出色threeparttable
包装在标题前后增加了额外的垂直空间。这可以在下面的 MWE 中看到,我将\abovecaptionskip
和设置\belowcaptionskip
为零以强调增加的空间。
您能帮我找出增加的垂直空间来自哪里以及如何删除它吗?我试图破译包装代码,但遗憾的是这超出了我的技能水平。
\documentclass[12pt]{article}
\usepackage{threeparttable}
\usepackage{tabularx}
\setlength{\abovecaptionskip}{0pt}
\setlength{\belowcaptionskip}{0pt}
\begin{document}
\begin{table}[h]
\caption{Testing testing testing}
\begin{tabularx}{\linewidth}{XXXX}
A1 & B1 & C1 & D1 \\
A2 & B2 & C2 & D2 \\
A3 & B3 & C3 & D3 \\
\end{tabularx}
\end{table}
\clearpage
\begin{table}[h]
% \vskip-\lastskip%\vspace{-.2\baselineskip}
\begin{threeparttable}
\caption{Testing testing testing}
\vskip-\lastskip%\vspace{-.2\baselineskip}
\begin{tabularx}{\linewidth}{XXXX}
A1 & B1 & C1 & D1 \\
A2 & B2 & C2 & D2 \\
A3 & B3 & C3 & D3 \\
\end{tabularx}
\end{threeparttable}
\end{table}
\end{document}
答案1
解决方法是使用以下caption
包:
\documentclass[12pt]{article}
\usepackage{tabularx, threeparttable}
\usepackage[skip=0ex]{caption} %you can select desired value
\begin{document}
\begin{table}[ht]
\caption{Testing testing testing}
\begin{tabularx}{\linewidth}{XXXX}
\hline
A1 & B1 & C1 & D1 \\
A2 & B2 & C2 & D2 \\
A3 & B3 & C3 & D3 \\
\end{tabularx}
\end{table}
\begin{table}[ht]
\begin{threeparttable}
\caption{Testing testing testing}
\begin{tabularx}{\linewidth}{XXXX}
\hline
A1 & B1 & C1 & D1 \\
A2 & B2 & C2 & D2 \\
A3 & B3 & C3 & D3 \\
\end{tabularx}
\end{threeparttable}
\end{table}
\end{document}
答案2
无需附加软件包的修复:将标题放在后面\begin{table}
。
它也适用于投影机。(https://tex.stackexchange.com/a/603137/161015)
\documentclass[12pt]{article}
\usepackage{threeparttable}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\caption{Testing testing testing}
\begin{tabularx}{\linewidth}{XXXX}
A1 & B1 & C1 & D1 \\
A2 & B2 & C2 & D2 \\
A3 & B3 & C3 & D3 \\
\end{tabularx}
\end{table}
\clearpage
\begin{table}[h]
\caption{Testing testing testing}% put the caption here <<<
\begin{threeparttable}
\begin{tabularx}{\linewidth}{XXXX}
A1 & B1 & C1 & D1 \\
A2 & B2 & C2 & D2 \\
A3 & B3 & C3 & D3 \\
\end{tabularx}
\end{threeparttable}
\end{table}
\end{document}