附录中的 Setcounter 不起作用

附录中的 Setcounter 不起作用

我希望附录中的所有表格和图片都以 A 开头,并重置表格和图片的计数器。我搜索了这个论坛并找到了实现此目的的示例。但是,当我按照示例操作时,它并没有按照我的意愿执行。特别是,它不会重置计数器(即它只是在文本中的最后一个表格之后继续),并且它将整个文档中的所有表格和图片设置为以“A”开头,而不仅仅是附录中的表格和图片。不确定我是否有太多软件包或需要另一个软件包。我将不胜感激任何帮助。这是我的 MWE:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{url}
\usepackage{morefloats}
\usepackage{setspace}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{listings}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage{subcaption}
\usepackage[nomarkers,nolists]{endfloat}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{sidewaystable}{table}


\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Table 1}
    \begin{tabular}{r}
    \toprule
    test \\
    \bottomrule
    \end{tabular}%
\end{table}




\appendix

\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand*{\thetable}{A\arabic{table}}
\renewcommand*{\thefigure}{A\arabic{figure}}
\input{Appendix.tex}  %\file with the written appendix

\begin{table}[htbp]
  \centering
  \caption{Table 2}
    \begin{tabular}{r}
    \toprule
    test \\
    \bottomrule
    \end{tabular}%
\end{table

\end{document}

答案1

根据你的见解 Jon,这是 endfloat 包,我已经弄清楚了。我已将其设置为在附录中正常处理表格和图形(不使用 endfloat 包)。这是我的解决方案:

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{url}
\usepackage{morefloats}
\usepackage{setspace}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{listings}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage{subcaption}
\usepackage[nomarkers,nolists]{endfloat}
\DeclareDelayedFloatFlavor{sidewaysfigure}{figure}
\DeclareDelayedFloatFlavor{sidewaystable}{table}


\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Table 1}
    \begin{tabular}{r}
    \toprule
    test \\
    \bottomrule
    \end{tabular}%
\end{table}

\makeatletter
\efloat@restorefloats
\makeatother
\appendix

\renewcommand*{\thetable}{A\arabic{table}}
\renewcommand*{\thefigure}{A\arabic{figure}}
\input{Appendix.tex}  % File with Appendix



   \begin{table}[htbp]
  \centering
  \caption{Table 2}
    \begin{tabular}{r}
    \toprule
    test \\
    \bottomrule
    \end{tabular}%
\end{table}

\setcounter{figure}{0} % Start again
\renewcommand\thefigure{\arabic{figure}}
\setcounter{table}{0} % Start again
\renewcommand\thetable{\arabic{table}}

\end{document}

相关内容