我想在图片列表 (LOF) 的第二页添加“图片列表 - 续”。在此页之后,如何向目录的每一页添加一些文字?,我正在使用\afterpage
命令。除了第二页只有一个图的情况外,这很有效。然后,“图列表 - 续”被放在第二个 LOF 页之后的页面上。下面是重现错误的最小代码。当图数为 46 时,一切都正常。当图数为 45 时,“图列表 - 续”文本被放在第 3 页而不是第 2 页。
\documentclass{article}
\usepackage{graphicx}
\usepackage{afterpage}
% Command to add "List of figures - Continued"
\newcommand{\contheadingadv}[3][0]{%
\afterpage{{\normalfont\centering\uppercase{#2~-~Continued}\\[1em]#3\hfill Page\\[1.5em]}}
}
\begin{document}
% Create list of figures
\listoffigures
\addtocontents{lof}{\contheadingadv[2]{List of figures}{Figure}}
\clearpage
% Loop to create figures
\newcount\loopcount
\loopcount 46 % Works with 46, doesn't work with 45 !!!!!!!!!!
\loop
\begin{figure}[h!]
\centering
\includegraphics[width=3cm]{example-image-a}
\caption{Figure}
\end{figure}
\clearpage
\advance\loopcount-1
\ifnum\loopcount>0
\repeat
\end{document}
答案1
论文中通常会遇到这么长的图表列表。下面的代码片段被全球许多大学在其 .cls 文件中使用。希望这对您有所帮助。
\def\listoffigures{
\clearpage
\typeout{LIST OF FIGURES.}
\def\headmark{\vbox{
\hbox to \textwidth{\large\bfseries\hfil LIST OF FIGURES
(Continued) \hfil}
\vspace{\innerheadskip}
\hbox to \textwidth{\normalsize\bfseries
\underbar{FIGURE}\hfil\underbar{PAGE}}}}
\pagestyle{continued}
\list@of@figs
}
答案2
作为参考,这里有一个使用 MT San 输入的完整最小工作示例:
\documentclass{article}
\usepackage{graphicx}
\makeatletter
% Define list of figures environment (sets up continued heading and calls list@of@figs)
\def\listoffigures{
\clearpage
% Define header for continued pages
\def\headmark{\vbox{
\hbox to \textwidth{\large\bfseries\hfil LIST OF FIGURES (Continued) \hfil}
\vspace{12pt}
\hbox to \textwidth{\normalsize\bfseries\underbar{FIGURE}\hfil\underbar{PAGE}}}}
\pagestyle{continued}
% Header on first page
\thispagestyle{plain}
\hbox to \textwidth{\large\bfseries\hfil LIST OF FIGURES \hfil}
\vspace{12pt}
\hbox to \textwidth{\normalsize\bfseries\underbar{FIGURE}\hfil\underbar{PAGE}}
\vspace{0.3cm}
% List of Figures
\@starttoc{lof}
\clearpage
\pagestyle{plain}
}
% Continued headings
\def\ps@continued{
\def\@oddhead{\headmark}
\let\@evenhead\@oddhead
}
\makeatother
\begin{document}
\listoffigures
\newcount\loopcount
\loopcount 150
\loop
\begin{figure}[h!]
\centering
\includegraphics[width=3cm]{example-image-a}
\caption{Figure}
\end{figure}
\clearpage
\advance\loopcount-1
\ifnum\loopcount>0
\repeat
\end{document}