多个表格环境中的表格编号错误

多个表格环境中的表格编号错误

当表中有多个longtabu环境时,表的编号会错误。请参阅下面的 MWE。

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{tabu}
\usepackage{longtable}
\begin{document}


\begin{table}
\centering
\caption{An interesting table}
\subcaption*{Panel A: Some stuff}
\begin{longtabu}{XXX}
First name & Last name  & Product \\
Bubba & Gump & Shrimp \\
Steve & Jobs & Happiness \\
\end{longtabu}
\bigskip
\subcaption*{Panel B: Other stuff}
\begin{longtabu}{XX}
School & State \\
Harvard & MA \\
Yale & CT \\
Brown & RI \\
\end{longtabu}
\end{table}


\begin{longtabu}{ll}

    Longtable & Longtable \\
    Longtable & Longtable \\
    Longtable & Longtable \\
    Longtable & Longtable \\
    Longtable & Longtable \\
    \caption{This is a caption}
\end{longtabu}

\end{document}

在此处输入图片描述

答案1

正如 Ulrike Fischer 所说评论中提到,在环境longtabu内部使用table是没有意义的。

如果您使用tabularx或简单的tabular代替,则longtabu表格编号正确,对于longtabu代码中的第二个,我已使用longtable并将相应的标题放在开头,以便它显示在上方longtable

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{longtable}
\begin{document}

\begin{table}
\centering
\caption{An interesting table using tabularx}
\begin{subtable}{\textwidth}
\subcaption*{Panel A: Some stuff}
\begin{tabularx}{\textwidth}{XXX}
First name & Last name  & Product \\
Bubba & Gump & Shrimp \\
Steve & Jobs & Happiness \\
\end{tabularx}
\end{subtable}
\bigskip

\begin{subtable}{\textwidth}
\subcaption*{Panel B: Other stuff}
\begin{tabularx}{\textwidth}{XX}
School & State \\
Harvard & MA \\
Yale & CT \\
Brown & RI \\
\end{tabularx}
\end{subtable}
\end{table}


\begin{longtable}{ll}
\caption{This is a caption of a longtable}\\
\endhead
    Longtable & Longtable \\
    Longtable & Longtable \\
    Longtable & Longtable \\
    Longtable & Longtable \\
    Longtable & Longtable \\
\end{longtable}



\begin{table}[htbp]
\caption{An interesting table using tabular}
\begin{subtable}{\textwidth}
\centering
\subcaption*{Panel A: Some stuff}
\begin{tabular}{lll}
First name & Last name  & Product \\
Bubba & Gump & Shrimp \\
Steve & Jobs & Happiness \\
\end{tabular}
\end{subtable}
\bigskip

\begin{subtable}{\textwidth}
\centering
\subcaption*{Panel B: Other stuff}
\begin{tabular}{ll}
School & State \\
Harvard & MA \\
Yale & CT \\
Brown & RI \\
\end{tabular}
\end{subtable}
\end{table}


\end{document}

在此处输入图片描述

相关内容