![Pie de página de encabezado elegante para páginas flotantes](https://rvso.com/image/286962/Pie%20de%20p%C3%A1gina%20de%20encabezado%20elegante%20para%20p%C3%A1ginas%20flotantes.png)
Estoy intentando mantener el número de página en las páginas flotantes usando fancyhdr
. Está es mi configuración actual:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
% with this we ensure that the chapter and section
% headings are in lowercase.
%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\iffloatpage{}{\thesection.\ #1}}}
\fancyhf{} % delete current setting for header and footer
\fancyhead[LE,RO]{\iffloatpage{}{\textbf{Page \thepage\ of \pageref{LastPage}}}}
\fancyhead[LO]{\iffloatpage{}{\textbf\rightmark}}
\fancyhead[RE]{\iffloatpage{}{\textbf\leftmark}}
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.5pt}}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headsep}{10pt}
\iffloatpage{\cfoot{\textbf{Page \thepage\ of \pageref{LastPage}}}}{}
\addtolength{\headheight}{\baselineskip} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
\begin{document}
\begin{figure}
\includegraphics{demo}
\end{figure}
\end{document}
Lamentablemente la línea que pensé que haría lo que quería ( \iffloatpage{\cfoot{\textbf{Page \thepage\ of \pageref{LastPage}}}}{}
) no hace nada. ¿Qué estoy haciendo mal?
Respuesta1
Lo necesitas al revés:
\fancyfoot[C]{\iffloatpage{\textbf{Page \thepage\ of \pageref{LastPage}}}{}}
El código:
\documentclass[twoside]{article}
\usepackage[demo]{graphicx}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
% with this we ensure that the chapter and section
% headings are in lowercase.
%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\iffloatpage{}{\thesection.\ #1}}}
\fancyhf{} % delete current setting for header and footer
\fancyhead[LE,RO]{\iffloatpage{}{\textbf{Page \thepage\ of \pageref{LastPage}}}}
\fancyhead[LO]{\iffloatpage{}{\textbf\rightmark}}
\fancyhead[RE]{\iffloatpage{}{\textbf\leftmark}}
\fancyfoot[C]{\iffloatpage{\textbf{Page \thepage\ of \pageref{LastPage}}}{}}
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.5pt}}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\headsep}{10pt}
\addtolength{\headheight}{\baselineskip} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
\begin{document}
\begin{figure}
\includegraphics{demo}
\end{figure}
\end{document}
Agregué la twoside
opción de clase; de lo contrario, E
y O
no tendrán utilidad.