本 MWE 第二章中的第一个表格标记为“表 2.2 关于此处”。章节编号设置不正确,因为 Endfloat 通常只是在整个文档中按顺序对表格进行编号。如何确保第二章中的第一个表格列为“表 2.1 关于此处”?
\documentclass[oneside,12pt]{book}
\usepackage[tablesfirst,notablist]{endfloat}
\usepackage{titletoc}
\renewcommand\theposttable{\arabic{chapter}.\arabic{posttbl}}
\renewcommand\thepostfigure{\arabic{chapter}.\arabic{postfig}}
\begin{document}
\chapter{Data}
\startlist{lot}
\begin{table}
\caption{Data chapter table}
\begin{tabular}{c}
123 \\
\end{tabular}
\end{table}
\printlist{lot}{}{\chapter*{List of tables in Chapter~\thechapter}}
\processdelayedfloats
\chapter{Learning}
\startlist{lot}
\begin{table}
\caption{Learning chapter table}
\begin{tabular}{c}
123 \\
\end{tabular}
\end{table}
\printlist{lot}{}{\chapter*{List of tables in Chapter~\thechapter}}
\processdelayedfloats
\end{document}
答案1
您可以使用chngcntr
包并重置每章的计数器。另请注意,从 2.5 版开始,计数器posttbl
和已被postfigurepostfig
取代。摘自手册:posttable and
\documentclass[oneside,12pt]{book}
\usepackage[tablesfirst,notablist]{endfloat}
\usepackage{titletoc}
\usepackage{chngcntr} %% <-- new
\counterwithin{posttable}{chapter} %% <-- new
\counterwithin{postfigure}{chapter} %% <-- new
\renewcommand\theposttable{\arabic{chapter}.\arabic{posttable}}
\renewcommand\thepostfigure{\arabic{chapter}.\arabic{postfigure}}
\begin{document}
\chapter{Data}
\startlist{lot}
\begin{table}
\caption{Data chapter table}
\begin{tabular}{c}
123 \\
\end{tabular}
\end{table}
\printlist{lot}{}{\chapter*{List of tables in Chapter~\thechapter}}
\processdelayedfloats
\chapter{Learning}
\startlist{lot}
\begin{table}
\caption{Learning chapter table}
\begin{tabular}{c}
123 \\
\end{tabular}
\end{table}
\printlist{lot}{}{\chapter*{List of tables in Chapter~\thechapter}}
\processdelayedfloats
\end{document}