如何计算表格

How to count Tabular

出于某种原因,我需要用乳胶制作许多 table,其中不应该有标题或标签,但它们需要像 Subsection.tableNo 这样编号。我试过使用

\begin{tabular}{ccc}  
...& ... & No.: \arabic{subsection}.\arabic{table}\\hline
.....
\end{tabular}

然而,因为我只使用表格环境,table 计数器不会被设置,所以我总是这样:

... ... 1.0

... ... 1.0

... ... 2.0

... ... 2.0

如何计算表格?谢谢

(还有..抱歉我的英语不好)

您可以使用 etoolbox 使用 \AtBeginEnvironment{<env>}{<stuff>}:

进入环境 <env> 的开头

\documentclass{article}
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{\refstepcounter{table}}

\newcommand{\showtabular}{% Just for this example
  \begin{tabular}{|c|}
    \hline
    \thesection.\thetable \
    \hline
  \end{tabular}}
\begin{document}

\section{First section}
\showtabular
\showtabular

\section{Second section}
\showtabular
\showtabular
\showtabular

\section{Last section}
\showtabular
\showtabular
\showtabular
\showtabular

\end{document}

我上面的步骤(其实步骤可以参考)table counter with every new \begin{tabular}.