我遇到一个问题,即表格标题和下一个元素(例如新章节标题)之间的间距并不直接取决于标题本身的位置。如果我在标题前添加,这个空间似乎会从原始边距中“减去”。在下面的例子中,和和下一个小节\insertTableNotes
之间的间距并不相同。原因是什么?Table 1
Table 2
\documentclass[a4paper]{article}
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\usepackage{geometry}
\geometry{
a4paper,
head=20mm,
left=20mm,
right=10mm,
top=25mm,
bottom=25mm,
foot=8mm
}
\usepackage{booktabs, makecell, multirow, xltabular}
\usepackage[flushleft]{threeparttablex} % to have a dedicated notes section after tables
\usepackage[font=small, margin=0pt]{caption}% table and figure captions
\captionsetup[table]{singlelinecheck=false}
\usepackage[table]{xcolor} % used for table alternatively colors
\usepackage{adjustbox} % it loads graphicx too
\newenvironment{tableenv}[1]{
\def\tablelabel{tab:#1}
\begin{center}
\begin{footnotesize}
% \astroltable
\begin{ThreePartTable}
}{
\end{ThreePartTable}
\setlength{\abovecaptionskip}{0pt}
% \caption{\tablecaption}
\label{\tablelabel}
\end{footnotesize}
\end{center}}
\definecolor{astrol-blue}{HTML}{336699} % Definierung der Farbe gemaess der Astrolfarben
\begin{document}
\section{Caption Spacing}
\setlength{\fboxsep}{0pt} % distance of box border from content
\setlength{\fboxrule}{1pt} % box border thicknes
\adjustboxset{width=\dimexpr\linewidth-\tabcolsep\relax,
valign=c
}
\begin{tableenv}{blabla}
\begin{xltabular}{1.0\textwidth}{p{0.25\textwidth}p{0.2\textwidth}X}
\toprule
\textbf{Parameter} & \textbf{Color} & \textbf{Example} \\ \midrule
\endhead
%\multicolumn{4}{r}{\footnotesize\textit{continue on the next page}}
Color & blue & {\adjustimage{cfbox=blue, width=0.5\linewidth}{example-image-duck}} \\
\bottomrule
\caption{Blabla}
\end{xltabular}
\end{tableenv}
\subsection{A new Subsection}
Some text\dots
\begin{tableenv}{blabla}
\begin{TableNotes}
\item[1] A note\dots
\item[2] And another one\dots
\end{TableNotes}
\begin{xltabular}{1.0\textwidth}{p{0.25\textwidth}p{0.2\textwidth}X}
\toprule
\textbf{Parameter} & \textbf{Color} & \textbf{Example} \\ \midrule
\endhead
%\multicolumn{4}{r}{\footnotesize\textit{continue on the next page}}
Color & blue & {\adjustimage{cfbox=blue, width=0.5\linewidth}{example-image-duck}} \\
\bottomrule
\insertTableNotes\\
\caption{Blabla}
\end{xltabular}
\end{tableenv}
\subsection{A new Subsection}
Some text\dots
\end{document}
更新:
我仍然找不到解决方案,有人遇到过类似的问题吗?
答案1
\begin{center}
当环境被常规布局命令替换时,情况会好得多\centering
。事实上,表格 1 之后的间距是不正确的。