![如何在 tabularx 之前添加标题?\captionof{table}{11111}\label{11} 和 \begin{tabularx}{\textwidth} 导致我的缩进问题](https://linux22.com/image/452129/%E5%A6%82%E4%BD%95%E5%9C%A8%20tabularx%20%E4%B9%8B%E5%89%8D%E6%B7%BB%E5%8A%A0%E6%A0%87%E9%A2%98%EF%BC%9F%5Ccaptionof%7Btable%7D%7B11111%7D%5Clabel%7B11%7D%20%E5%92%8C%20%5Cbegin%7Btabularx%7D%7B%5Ctextwidth%7D%20%E5%AF%BC%E8%87%B4%E6%88%91%E7%9A%84%E7%BC%A9%E8%BF%9B%E9%97%AE%E9%A2%98.png)
在此代码(\captionof{table}{111}
)之前缩进是正常的,在此代码之后缩进消失。当我删除它时,缩进是正常的。那么,如何为这个 tabularx 添加标题(caption)?
%\usepackage{indentfirst}%doesn't do anything to solve the problem
%\setlength{\parindent}{2em}%doesn't do anything to solve the problem
\noindent\setlength\tabcolsep{4pt}
\captionof{table}{11111}\label{11}
\begin{tabularx}{\textwidth}{sssbbbs}
\toprule
11 & 111 & 11 & 1111 & 11 & 11 & 11 \\ [0.5ex]
\midrule
111 & 111 & 2020 & 111 & 111 & 111 & 111 \\
111 & 111 & 2020 & 111 & 111 & 111 & 11 \\
\bottomrule
\end{tabularx}
答案1
我明白了!
添加\usepackage{ltablex}%Table package extensions
并删除\captionof{table}{11111}\label{11}
,\caption{111}\label{11}\\
像tabularx
这样添加:
\begin{tabularx}{\textwidth}{sssbbbs}
\caption{111}\label{11}\\
\toprule
11 & 111 & 11 & 1111 & 11 & 11 & 11 \\ [0.5ex]
\midrule
111 & 111 & 2020 & 111 & 111 & 111 & 111 \\
111 & 111 & 2020 & 111 & 111 & 111 & 11 \\
\bottomrule
\end{tabularx}