长表格前的页面上前一段周围有大量空白,并且标题未显示在表格旁边。 1. 如何去除表格前页面上的随机空白? 2. 如何向此表格添加标题?
该表的写法如下,但较长:
\usepackage{tabularx,booktabs}
\usepackage{makecell}
\begin{document}
\begin{center}
\begin{tabularx}{\linewidth}{ll>{\raggedright}Xr}
\toprule
\textbf{Label 1}& \textbf{Label 2}&\textbf{Label 3}& $N$\\
\midrule
\makecell[lt]{preparatory\\ work} &\makecell[lt]{Adding\\ information}&
Description on several lines. Description on several lines.
Description on several lines. Description on several lines.
& 2
\\
&\makecell[lt]{organizing\\ information}&
New Description on several lines. Description on several lines.
Description on several lines. Description on several lines.
& 3
\\
word &short term&
Description on several lines. Description on several lines.
Description on several lines. Description on several lines.
& 2
\\
\bottomrule
\end{tabularx}
\end{center}
\end{document}
请为没有经验的用户解释。
答案1
您没有提供重现问题的 MWE,因此很难判断问题的原因是什么。考虑到 @Bernard 的评论,您的 MWE 应该是这样的:
\documentclass{article}
\usepackage{booktabs, makecell, tabularx}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table}[ht] % <--- added
\centering % <--- added
\caption{My important table which has caption above of it} % <--- added
\label{tab:mytable} % <--- added
\begin{tabularx}{\linewidth}{ll>{\raggedright}Xr}
\toprule
\textbf{Label 1}& \textbf{Label 2}&\textbf{Label 3}& $N$\\
\midrule
\makecell[lt]{preparatory\\ work} &\makecell[lt]{Adding\\ information}&
Description on several lines. Description on several lines.
Description on several lines. Description on several lines.
& 2
\\
&\makecell[lt]{organizing\\ information}&
New Description on several lines. Description on several lines.
Description on several lines. Description on several lines.
& 3
\\
word &short term&
Description on several lines. Description on several lines.
Description on several lines. Description on several lines.
& 2
\\
\bottomrule
\end{tabularx}
\end{table}
See Table \ref{tab:mytable}. \lipsum[2]
\end{document}
结果如下:
(红线表示文本边框)
可以看到,建议的MWE没有任何不寻常的垂直空白空间。添加table
浮动环境表可以浮动在页面上最合适的位置。