I am troubleshooting a conflict between the Springer Nature sn-jnl document class and the standard \tableofcontents
command: If the table of contents (TOC) is entirely contained within a single page (and is not placed on the first page), a complete solution to my problem is given by the accepted answer to a similar question. However, if the TOC spans two pages, this approach only fixes the problem on either the even or odd numbered pages, but NOT both. (And if the TOC spans more than two pages, it doesn't fix the problem at all)
Desired behavior:
The sn-jnl class defines a command \title[optional short title]{article title}
. If a "short title" is specified, the document class should produce a left-aligned header on even-numbered pages containing the page number and the specified "short title". If no "short title" is provided, it should behave the same way but print the full "article title" instead of the "short title".
On odd-numbered pages, it should similarly print a right-aligned header with the page number and the "short title" (or "full title"):
Description of problem:
If a TOC is inserted using \tableofcontents
, then the title in the header will instead be replaced with "CONTENTS" in both the even and the odd-numbered page headers:
If the TOC spans only a single page, then the desired header behavior can be restored by replacing \tableofcontents
with:
\markboth{\leftmark}{\rightmark}
\tableofcontents
\markboth{\leftmark}{\rightmark}
See the accepted answer to a similar question. However, if the TOC spans two pages, then this approach only restores the heading title to either the even pages (if the TOC starts on an even page) or to the odd pages (if the TOC starts on an odd page). Thus, any page whose parity differs from the page on which the TOC begins will still display "CONTENTS" in its header.
MWE:
\documentclass[pdflatex,sn-mathphys]{sn-jnl}
\usepackage{lipsum}
\begin{document}
\title[short title]{Full Title}
\author*[1]{Corresponding Author}
\affil[1]{Institution}
\abstract{\lipsum[4]}
\maketitle
\newpage
\markboth{\leftmark}{\rightmark}
\tableofcontents
\markboth{\leftmark}{\rightmark}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\backmatter
\bmhead{Backmatter}
\begin{appendices}
\section{Appendix}
\end{appendices}
\end{document}
\markboth{\leftmark}{\rightmark}
looks wrong.\leftmark
and\rightmark
aren't meant to be used in\markboth
.\markboth{short title}{short title}
or something similar looks better to me.markboth{\leftmark}{\rightmark}
with\makeatletter \markboth{\s@title}{\s@title} \makeatother
, it will now print the "short title" in the headers. It prints it in an upright font rather than italicized but that shouldn't be difficult to change. I don't think I presently understand\markboth
well enough to write up an informative answer, so you're welcome to turn your comment into an answer and describe how it works.