这里有4个表。表1、3和4的标题和标签输出为表1、表2和表3。但是表2是一个长表,它的表标签没有显示。如何按顺序输出它们的表标签和标题?
\begin{table}[h]
\caption{first table}
\label{tab:1}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} |l|c|}
\toprule
some codes
\midrule
some codes
\end{tabular*}
\smallskip
\scriptsize
\end{table}
\\
\begin{longtable}
%\setlength
\setlength\tabcolsep{0pt}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} |l|c|r|}
\caption{second table}\label{tab:2}\\
\toprule
some codes
\midrule
some codes
\bottomrule
\hline
\end{tabular*}
\smallskip
\scriptsize
\end{longtable}
\\
\begin{table}[h]
\begin{center}
\caption{Third table}
\label{tab:3}
\begin{tabular}{|l|c|c|c|c|c|r|} \hline
some codes
\hline
\end{tabular}
\smallskip
\scriptsize
\end{center}
\end{table}
\begin{table}[h]
\begin{center}
\caption{Summary of overall query result}
\label{tab:4}
\begin{tabular}{|l|c|c|r|} \hline
some codes
\end{tabular}
\smallskip
\scriptsize
\end{center}
\end{table}\\
答案1
合并您的代码片段后,纠正使用错误语法,longtable
我获得了预期的正确结果:
如您所见,罪魁祸首是长表的代码。在 中,您不能像在 中一样longtable
包含(或其他表环境。之后应遵循列规范(、或)。请参阅下面的 MWE。tabular
\begin{longtable}
c
l
r
p{...}
MWE 产生的结果表明:
\documentclass{article}
\usepackage{array, booktabs, longtable}
\begin{document}
\begin{table}[ht]
\caption{first table}
\label{tab:1}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} |l|c|}
\toprule
some codes & some codes \\
\bottomrule
\end{tabular*}
\end{table}
\begin{longtable}{|l|c|r|}
\caption{second table}
\label{tab:2}\\
\toprule
some codes & some codes \\
\bottomrule
\end{longtable}
\begin{table}[ht]
\centering
\caption{Third table}
\label{tab:3}
\begin{tabular}{|l|c|c|c|c|c|r|} \hline
1 & 2 & 3 & 4 & 5 & 6 & 7 \\
\hline
\end{tabular}
\end{table}
\begin{table}[ht]
\centering
\caption{Summary of overall query result}
\label{tab:4}
\begin{tabular}{|l|c|c|r|} \hline
1 & 2 & 3 & 4 \\
\hline
\end{tabular}
\end{table}
\end{document}