即使没有 \caption,Tabularx 也会增加表格编号

即使没有 \caption,Tabularx 也会增加表格编号

我正在使用ltablexthreeparttablex来处理跨 2 或 3 页的长表格。但是,在正文中使用时我tabularx并没有打算编号,但tabularx环境却增加了表格的编号。有什么帮助吗?

\documentclass{article}

\usepackage{booktabs,ltablex,threeparttablex,blindtext}


\begin{document}

\blindtext

\begin{tabularx}{\linewidth}{cc}
Row 1, Col 1 & Row 1, Col 2\\
Row 2, Col 1 & Row 2, Col 2
\end{tabularx}

\begin{table}[h]
  \begin{ThreePartTable}
    \begin{tabularx}{\textwidth}{cc}
\caption{Example}
\label{tab:dummy}\\
\toprule
ex1 & ex2\\
ex3 & ex4\\
\bottomrule
\end{tabularx}%
\begin{tablenotes}\footnotesize
\item[a] note1.
\item[b] note2.
\end{tablenotes}
\end{ThreePartTable}
\end{table}

\end{document} 

答案1

使用新环境进行修复以减少计数器(通过“ltablex”包由 tabularx 环境增加)

\documentclass{article}

\usepackage{ltablex,booktabs,threeparttablex,blindtext,environ}

\NewEnviron{mytabularx}[2]{\begin{tabularx}{#1}{#2}\BODY\end{tabularx}\addtocounter{table}{-1}}

\begin{document}

\blindtext

\begin{mytabularx}{\linewidth}{cc}
Row 1, Col 1 & Row 1, Col 2\\
Row 2, Col 1 & Row 2, Col 2
\end{mytabularx}

\begin{table}
 \caption{Example}\label{tab:dummy}
  \begin{ThreePartTable}
    \begin{mytabularx}{\linewidth}{cc}
\toprule
ex1 & ex2\\
ex3 & ex4\\
\bottomrule
\end{mytabularx}%
\begin{tablenotes}\footnotesize
\item[a] note1.
\item[b] note2.
\end{tablenotes}
\end{ThreePartTable}
\end{table}

\begin{mytabularx}{\linewidth}{cc}
Row 1, Col 1 & Row 1, Col 2\\
Row 2, Col 1 & Row 2, Col 2
\end{mytabularx}

\begin{table}
 \caption{Example}\label{tab:dummy2}
  \begin{ThreePartTable}
    \begin{mytabularx}{\linewidth}{cc}
\toprule
ex1 & ex2\\
ex3 & ex4\\
\bottomrule
\end{mytabularx}%
\begin{tablenotes}\footnotesize
\item[a] note1.
\item[b] note2.
\end{tablenotes}
\end{ThreePartTable}
\end{table}
\end{document} 

输出:

在此处输入图片描述

相关内容