如何将章节前缀放入“表格/图 X 关于此处”中的 Endfloat 标记中?例如,在第 2 章的文本中,如何才能使用“表格 2.1 关于此处”,而不是“表格 1 关于此处”?有没有解决方法?
\documentclass[a4paper,12pt,twoside]{book}
\usepackage{pdflscape}
\usepackage[tablesfirst]{endfloat}
%\usepackage{titletoc}
%\renewcommand{\theposttable}{\Roman{posttbl}}
%\renewcommand{\thepostfigure}{\Roman{postfig}}
%\renewcommand{\thefigure}{\Roman{figure}}
%\renewcommand{\thetable}{\Roman{table}}
% new environment for landscape tables
\newenvironment{ltable}
{\begin{landscape}\begin{table}}
{\end{table}\end{landscape}}
% make it known to endfloat
\DeclareDelayedFloatFlavor{ltable}{table}
\begin{document}
\chapter{This is Chapter 1}
\startlist{lot}
Some text in chapter 1. See my figure \ref{tab:table1}.
\begin{table}
\caption{First Table} \label{tab:table1}
\end{table}
\begin{table}
\caption{Second Table} \label{tab:table2}
\end{table}
\processdelayedfloats
\chapter{This is Chapter 2}
\startlist{lot}
Some text in chapter 2. See my figure \ref{tab:table2}.
\begin{ltable}
\caption{Third Table} \label{tab:table3}
\end{ltable}
\begin{ltable}
\caption{Fourth Table} \label{tab:table4}
\end{ltable}
\begin{figure}
\caption{Fifth Table} \label{fig:table5}
\end{figure}
\processdelayedfloats
\end{document}
如果绝对必要的话,我很乐意修改 Endfloat.sty,但不知道该怎么做。
答案1
您需要重新定义\theposttable
:
\renewcommand\theposttable{\arabic{chapter}.\arabic{posttbl}}
一个例子:
\documentclass[a4paper,12pt,twoside]{book}
\usepackage{pdflscape}
\usepackage[tablesfirst]{endfloat}
\usepackage{titletoc}
\renewcommand{\theposttable}{\arabic{chapter}.\arabic{posttbl}}
% new environment for landscape tables
\newenvironment{ltable}
{\begin{landscape}\begin{table}}
{\end{table}\end{landscape}}
% make it known to endfloat
\DeclareDelayedFloatFlavor{ltable}{table}
\begin{document}
\chapter{This is Chapter 1}
\startlist{lot}
Some text in chapter 1. See my figure \ref{tab:table1}.
\begin{table}
\caption{First Table} \label{tab:table1}
\end{table}
\begin{table}
\caption{Second Table} \label{tab:table2}
\end{table}
\processdelayedfloats
\chapter{This is Chapter 2}
\startlist{lot}
Some text in chapter 2. See my figure \ref{tab:table2}.
\begin{ltable}
\caption{Third Table} \label{tab:table3}
\end{ltable}
\begin{ltable}
\caption{Fourth Table} \label{tab:table4}
\end{ltable}
\begin{figure}
\caption{Fifth Table} \label{fig:table5}
\end{figure}
\processdelayedfloats
\end{document}
另一种选择是重新定义\floatplace
:
\makeatletter
\renewcommand\floatplace[1]{%
\begin{center}
[\csname #1name\endcsname~\thechapter.\csname thepost#1\endcsname\ about here.]
\end{center}}
\makeatother