[Tex/LaTex] Repeating section headers in moderncv

moderncvpage-breakingsectioning

I am trying to prepare my CV using moderncv, and my publication list currently splits pages. I would like the top of the next page to have \refname{} (continued) in the same typeface as the original \refname callout.

The closest I have gotten is with the \afterpage package, but this (a) requires that I know exactly what section is going to be at page breaks, which might change as I add/subtract things from my CV, and (b) does not work well with bibliography as it's a macro that creates a section and thus doesn't appear to like being interrupted. The MWE I provide below comes close to what I want, but problems (a) and (b) above are apparent.

What can I do?

Here's the MWE (and the references for the .bib file are below that):

\documentclass[11pt,letterpaper,sans]{moderncv}


\moderncvstyle{classic}
\moderncvcolor{black}

\usepackage[scale=0.75]{geometry}


\name{John T.}{Doe}
\title{Curriculum vitae}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(555)~555~5890}
\usepackage{afterpage}
\interlinepenalty=10000 



\begin{document}
    \makecvtitle
\section{Education}
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\section{Awards and Honors}
    \cvitem{year}{Award}
    \cvitem{year}{Award}
    \cvitem{year}{Award}
    \cvitem{year}{Award}
    \cvitem{year}{Award}

\section{Teaching Positions}
    \cvitem{year}{course name}
    \cvitem{year}{course name}
    \cvitem{year}{course name}
    \cvitem{year}{course name}
    \cvitem{year}{course name}
    \cvitem{year}{course name}

\renewcommand{\refname}{Publications I Wish I had Written}


\bibliographystyle{unsrt}
\nocite{gore2011}
\nocite{komatsu2011}
\nocite{lister2011}
\nocite{rasmussen2011}
\afterpage{\section{\refname{} (continued)}}

\bibliography{publications}

\end{document}

publications.bib:

@article{komatsu2011,
  title={Seven-year Wilkinson microwave anisotropy probe (WMAP) observations: cosmological interpretation},
  author={Komatsu, Eiichiro and Smith, KM and Dunkley, J and Bennett, CL and Gold, B and Hinshaw, G and Jarosik, N and Larson, D and Nolta, MR and Page, L and others},
  journal={The Astrophysical Journal Supplement Series},
  volume={192},
  number={2},
  pages={18},
  year={2011},
  publisher={IOP Publishing}
}

@article{lister2011,
  title={Hotspots of aberrant epigenomic reprogramming in human induced pluripotent stem cells},
  author={Lister, Ryan and Pelizzola, Mattia and Kida, Yasuyuki S and Hawkins, R David and Nery, Joseph R and Hon, Gary and Antosiewicz-Bourget, Jessica and O’Malley, Ronan and Castanon, Rosa and Klugman, Sarit and others},
  journal={Nature},
  volume={471},
  number={7336},
  pages={68--73},
  year={2011},
  publisher={Nature Publishing Group}
}

@article{gore2011,
  title={Somatic coding mutations in human induced pluripotent stem cells},
  author={Gore, Athurva and Li, Zhe and Fung, Ho-Lim and Young, Jessica E and Agarwal, Suneet and Antosiewicz-Bourget, Jessica and Canto, Isabel and Giorgetti, Alessandra and Israel, Mason A and Kiskinis, Evangelos and others},
  journal={Nature},
  volume={471},
  number={7336},
  pages={63--67},
  year={2011},
  publisher={Nature Publishing Group}
}

@article{rasmussen2011,
  title={Structure of a nanobody-stabilized active state of the [bgr] 2 adrenoceptor},
  author={Rasmussen, S{\o}ren GF and Choi, Hee-Jung and Fung, Juan Jose and Pardon, Els and Casarosa, Paola and Chae, Pil Seok and DeVree, Brian T and Rosenbaum, Daniel M and Thian, Foon Sun and Kobilka, Tong Sun and others},
  journal={Nature},
  volume={469},
  number={7329},
  pages={175--180},
  year={2011},
  publisher={Nature Publishing Group}
}

Best Answer

Still one bug left, but hopefully someone else can figure it out :)

Here is my idea: close the thebibliography environment at the start of every \bibitem to reopen it immediately. This way, LaTeX will print the bibliography head through \bibliographyhead between every bib item.

Then it should be a simple matter of modifying \bibliographyhead to only print something when a new conditional, \ifbibliographyhead, is set to true. We can then set it to true initially, set it to false every time the header is printed, and use \afterpage to set it again to true at the beginning of every page.

Here is the code:

\makeatletter
\let\refname@original\refname
\newif\ifbibliographyhead\bibliographyheadtrue% define a new conidtional and set it to "true" initially
\def\bibliographyhead#1{%
  % print the header only if \ifbibliographyhead is set to "true"
  \ifbibliographyhead%
    \section{#1}%
    \global\bibliographyheadfalse% set the conditional to false after every header printout
    \gdef\refname{\refname@original{} (cont'd)}% update the header title to add " (cont'd)"
  \fi}
\let\bibitem@original\bibitem
\renewcommand{\bibitem}[1]{%
%  \ifbibliographyhead% if you uncomment this line and the following \fi, the "(cont'd)" heading jumps a bib item further (?!)
    \end{thebibliography}%
    \begin{thebibliography}{1}%
%  \fi
  \bibitem@original{#1}}
\makeatother
% at the start of every new page, reset the new conditional to "true"
\afterpage{\global\bibliographyheadtrue}

Unfortunately, somehow the first \bibitem of the new page doesn't show the header, only the second one. I don't understand why --- yet...

Result