[Tex/LaTex] Adding words figure and page to list of figures

afterpagefloatsfront-mattersectioning

This also applies to the table of contents and list of tables and is related to Add 'Page' above page numbers in Table of Contents, but when adding the words "Figure" and "Page" to the top of a List of Figures that spans more than one page, the additions are typset differently on the first page than on the second.

Here I use \addtocontents{lof}{{~\ul{Figure}}~\hfill{\ul{Page}}\par} following \listoffigures to make the addition to the first page, and \addtocontents{lof}{\protect\afterpage{{~\ul{Figure}}~\hfill{\ul{Page}}\par}} between figure 2.8 and 2.9 to make the addition to the top of the second page.

I rather like how the first page appears, the spacing looks right. I cannot understand why the second page appears differently. I also understand that \noindentin the place of ~ preceding the word "Figure" in my code may be more appropriate. The question is why the different behavior? How can I do this so that the text appears the same on each page. Any thoughts? Have spent quite a lot of time on this but can't reach a solution.

\documentclass[12pt,letterpaper,oneside]{book}
\usepackage{soul}
\usepackage{afterpage}
\usepackage{mwe}
\usepackage{tikz}
\begin{document}
\frontmatter
\listoffigures
\addtocontents{lof}{{~\ul{Figure}}~\hfill{\ul{Page}}\par}
\mainmatter
\chapter{one}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\chapter{one}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\addtocontents{lof}{\protect\afterpage{{~\ul{Figure}}~\hfill{\ul{Page}}\par}}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\end{document}

Best Answer

Replace the line

\addtocontents{lof}{\protect\afterpage{{~\ul{Figure}}~\hfill{\ul{Page}}\par}}

with

\makeatletter
\addtocontents{lof}{\protect\afterpage{\protect\hbox to \linewidth%
                    {{~\ul{Figure}}~\hfill{\ul{Page}}}\par%
                    \protect\addvspace{10\p@}}}
\makeatother

Note that, since you're using afterpage, you don't need to guess where to put these lines. You can put them just after

\addtocontents{lof}{{~\ul{Figure}}~\hfill{\ul{Page}}\par}

MWE:

\documentclass[12pt,letterpaper,oneside]{book}
\usepackage{soul}
\usepackage{afterpage}
\usepackage{mwe}
\usepackage{tikz}
\begin{document}
\frontmatter
\listoffigures
\addtocontents{lof}{{~\ul{Figure}}~\hfill{\ul{Page}}\par}
\makeatletter
\addtocontents{lof}{\protect\afterpage{\protect\hbox to \linewidth%
                    {{~\ul{Figure}}~\hfill{\ul{Page}}}\par%
                    \protect\addvspace{10\p@}}}
\makeatother
\mainmatter
\chapter{one}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\chapter{one}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{example-image-a}
\caption{dummy figure}
\end{figure}
\end{document} 

Output:

enter image description here

Related Question