![如何获取页脚中每页内所有图形的数量](https://linux22.com/image/395414/%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96%E9%A1%B5%E8%84%9A%E4%B8%AD%E6%AF%8F%E9%A1%B5%E5%86%85%E6%89%80%E6%9C%89%E5%9B%BE%E5%BD%A2%E7%9A%84%E6%95%B0%E9%87%8F.png)
我有一份包含多个图表和页脚格式的文档。我需要该页脚格式中每页图表的编号,如下所示,
以下代码仅包含部分图形,而不是全部,以免文章太长
\documentclass[12pt]{article}
\usepackage{fancyhdr}
\usepackage[paperheight=17in, paperwidth=11in, left=3cm, right=2cm, top=2cm, bottom=5.5cm, footskip=2cm]{geometry}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
%\usepackage{showframe}
\usepackage{float}
\usepackage[labelfont={bf}]{caption}
\usepackage[caption = false]{subfig}
\usepackage{lastpage}
\usepackage{multirow}
\usepackage{array}
\renewcommand{\figurename}{FOTOGRAFÍA}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[C]{%
\begin{tabular}{|m{6cm}|m{12cm}|m{3.5cm}|}
\hline
\multirow{1}{6cm}{} & \centering \footnotesize\textbf{CONTRATO 086 DE 2015} & \multirow{5}{3.5cm}{\centering\textbf{Page \thepage \hspace{1pt} of \pageref{LastPage}}}\\
\cline{2-2}
\centering\includegraphics[width=5cm]{rotulo/fondo_adap.png} & \centering \footnotesize\textbf{INTERVENTORÍA INTEGRAL A LA EJECUCIÓN DE LAS OBRAS DE URBANISMO DE LA FASE I Y EQUIPAMIENTOS DEL REASENTAMIENTO URBANO DEL MUNICIPIO DE GRAMALOTE} & \\
\hline
\centering\includegraphics[width=5cm]{rotulo/ru.png} & \centering\textbf{INFORME MENSUAL DE INTERVENTORÍA Nº 25} & \footnotesize\centering 27 de marzo a 26 de abril de 2019 \tabularnewline
\hline
\end{tabular}%
}
\begin{document}
\pagestyle{fancy}
% \null
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_1.png}
\caption{Instalación de malla electrosoldada y acero de refuerzo en zona de pozos de inspección y sumideros y fundida de MR-41 en la vía del eje 9 abscisas k0+093 a la k0+185.}
\end{figure}
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_2.png}
\caption{Instalación de malla electrosoldada y fundida de andén en concreto en ambos márgenes abscisas k0+270 a la k0+360 de la vía del eje 9.}
\end{figure}
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_3.png}
\caption{Instalación de base granular y bordillo interno en ambos márgenes de la vía eje 9 abscisas k0+140 a la k0+270.}
\end{figure}
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_4.png}
\caption{Instalación de bordillos en concreto para la vía restringida 3.}
\end{figure}
\vfill
\end{document}
答案1
此解决方案使用\figlabel
生成\label
名为figlist.1
、figlist.2
、... 的 。 \figlist
将包含本页上的图形列表,并由 生成\makefiglist
。需要运行两次才会出现任何内容。
我不确定您想将\figlist
页脚放在什么位置,或者希望如何设置格式,但这应该很容易更改。在最后一个数字前添加“and”并不容易。
\documentclass[12pt]{article}
\usepackage{fancyhdr}
\usepackage[paperheight=17in, paperwidth=11in, left=3cm, right=2cm, top=2cm, bottom=5.5cm, footskip=2cm]{geometry}
\usepackage[draft]{graphicx}% get rid of all the error messages
\usepackage[utf8]{inputenc}
%\usepackage{showframe}
\usepackage{float}
\usepackage[labelfont={bf}]{caption}
\usepackage[caption = false]{subfig}
\usepackage{lastpage}
\usepackage{refcount}% for \getpagerefnumber
\usepackage{multirow}
\usepackage{array}
\renewcommand{\figurename}{FOTOGRAFÍA}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\headrulewidth}{0pt}
\newcounter{figdone}% you need to format \thefigdone the same as \thefigure
\setcounter{figdone}{1}
\newcommand{\figlabel}{\label{figlist.\thefigure}}% must be called after EVERY figure \caption
\newcommand{\figlist}{}% reserve global name
\newcommand{\makefiglist}{\global\let\figlist=\empty
\loop\ifnum\getpagerefnumber{figlist.\thefigdone}=\value{page}% check this page
\ifx\empty\figlist\relax
\xdef\figlist{Fig. \thefigdone}%
\else
\xdef\figlist{\figlist, \thefigdone}%
\fi
\stepcounter{figdone}% check next figure
\repeat}
\fancyfoot[C]{\makefiglist
\begin{tabular}{|m{6cm}|m{12cm}|m{3.5cm}|}
\hline
\multirow{1}{6cm}{} & \centering \footnotesize\textbf{CONTRATO 086 DE 2015} & \multirow{5}{3.5cm}{\centering\textbf{Page \thepage \hspace{1pt} of \pageref{LastPage}}}\\
\cline{2-2}
\centering\includegraphics[width=5cm]{rotulo/fondo_adap.png} & \centering \footnotesize\textbf{INTERVENTORÍA INTEGRAL A LA EJECUCIÓN DE LAS OBRAS DE URBANISMO DE LA FASE I Y EQUIPAMIENTOS DEL REASENTAMIENTO URBANO DEL MUNICIPIO DE GRAMALOTE} & \figlist \\
\hline
\centering\includegraphics[width=5cm]{rotulo/ru.png} & \centering\textbf{INFORME MENSUAL DE INTERVENTORÍA Nº 25} & \footnotesize\centering 27 de marzo a 26 de abril de 2019 \tabularnewline
\hline
\end{tabular}%
}
\begin{document}
\pagestyle{fancy}
% \null
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_1.png}
\caption{Instalación de malla electrosoldada y acero de refuerzo en zona de pozos de inspección y sumideros y fundida de MR-41 en la vía del eje 9 abscisas k0+093 a la k0+185.}\figlabel
\end{figure}
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_2.png}
\caption{Instalación de malla electrosoldada y fundida de andén en concreto en ambos márgenes abscisas k0+270 a la k0+360 de la vía del eje 9.}\figlabel
\end{figure}
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_3.png}
\caption{Instalación de base granular y bordillo interno en ambos márgenes de la vía eje 9 abscisas k0+140 a la k0+270.}\figlabel
\end{figure}
\vfill
\begin{figure}[p]
\centering
\captionsetup{justification=centering, margin=2cm}
\includegraphics[width=16cm]{figuras/fig_4.png}
\caption{Instalación de bordillos en concreto para la vía restringida 3.}\figlabel
\end{figure}
\vfill
\end{document}
答案2
这远非完美,更像是一个概念证明......
也许有人会滥用脚注来保存每页的图表编号。下面是一个简短的例子:
\documentclass{article}
\usepackage{etoolbox}
\AfterEndEnvironment{figure}{\footnotetext{\thefigure}}
\usepackage[para]{footmisc}
\makeatletter
\def\@makefnmark{}
\renewcommand\footnoterule{}
\long\def\makefootnoteparagraph{\unvbox\footins \makehboxofhboxes
\setbox\FN@tempboxa=\hbox{\unhbox\FN@tempboxa \removehboxes}
\hsize\columnwidth
\@parboxrestore
\baselineskip=\footnotebaselineskip
\noindent
\rule{\z@}{\footnotesep}%
Figures \unhbox\FN@tempboxa\par
}
\makeatother
\begin{document}
\begin{figure}[htbp]
\caption{a}
\end{figure}
\begin{figure}[htbp]
\caption{a}
\end{figure}
\begin{figure}[htbp]
\caption{a}
\end{figure}
\newpage
\begin{figure}[htbp]
\caption{a}
\end{figure}
\begin{figure}[htbp]
\caption{a}
\end{figure}
\begin{figure}[htbp]
\caption{a}
\end{figure}
\end{document}