xetex – Fix Running Head Margin Issue in Springer Nature LaTeX Template for Two Column

pdftexspringernaturetemplatesxetex

I am using the latex template of Springer Nature my problem is Running head is running out of margin when i use two column option(iicol) can anyone have the solution to the problem please help.

\documentclass[pdflatex,sn-mathphys,iicol]{sn-jnl}% Math and Physical Sciences Reference Style

\jyear{2021}%
\usepackage{lipsum}

\theoremstyle{thmstyleone}%
\newtheorem{theorem}{Theorem}%  meant for continuous numbers
\newtheorem{proposition}[theorem]{Proposition}% 

\theoremstyle{thmstyletwo}%
\newtheorem{example}{Example}%
\newtheorem{remark}{Remark}%

\theoremstyle{thmstylethree}%
\newtheorem{definition}{Definition}%

\raggedbottom
%%\unnumbered% uncomment this for unnumbered level heads

\begin{document}

\title[Sample running title of the document Sample running title of the document]{Article Title}


\author*[1,2]{\fnm{First} \sur{Author}}\email{[email protected]}

\author[2,3]{\fnm{Second} \sur{Author}}\email{[email protected]}
\equalcont{These authors contributed equally to this work.}

\author[1,2]{\fnm{Third} \sur{Author}}\email{[email protected]}
\equalcont{These authors contributed equally to this work.}

\affil*[1]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{100190}, \state{State}, \country{Country}}}

\affil[2]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{10587}, \state{State}, \country{Country}}}

\affil[3]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{610101}, \state{State}, \country{Country}}}

%%==================================%%
%% sample for unstructured abstract %%
%%==================================%%

\abstract{The abstract serves both as a general introduction to the topic and as a brief, non-technical summary of the main results and their implications. Authors are advised to check the author instructions for the journal they are submitting to for word limits and if structural elements like subheadings, citations, or equations are permitted.}

\keywords{keyword1, Keyword2, Keyword3, Keyword4}

%%\pacs[JEL Classification]{D8, H51}

%%\pacs[MSC Classification]{35A01, 65L10, 65L12, 65L20, 65L70}

\maketitle

\section{Introduction}\label{sec1}

The Introduction section, of referenced text \cite{bib1} expands on the background of the work (some overlap with the Abstract is acceptable). The introduction should not include subheadings.

Springer Nature does not impose a strict layout as standard however authors are advised to check the individual requirements for the journal they are planning to submit to as there may be journal-level preferences. When preparing your text please also be aware that some stylistic choices are not supported in full text XML (publication version), including coloured font. These will not be replicated in the typeset article if it is accepted. 

\section{Results}\label{sec2}

Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text.

\section{This is an example for first level head---section head}\label{sec3}

\subsection{This is an example for second level head---subsection head}\label{subsec2}

\subsubsection{This is an example for third level head---subsubsection head}\label{subsubsec2}

Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. 

\section{This is an example for first level head---section head}\label{sec3}

\subsection{This is an example for second level head---subsection head}\label{subsec2}

\subsubsection{This is an example for third level head---subsubsection head}\label{subsubsec2}

Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. 
\lipsum[1-50]

\end{document}

Best Answer

The sn-jnl.cls has sloppy programming of the headers. Replace the following parts in that file, and it will work.

\def\ps@headings{%
    \def\@oddfoot{\hfill}%
    \let\@evenfoot\@oddfoot%
      %%\def\@evenhead{{\headerfont\thepage\qquad\rightmark\hfill\includegraphics{springer-nature-logo}}}%
      %%\def\@oddhead{{\headerfont\includegraphics{springer-nature-logo}\hfill\leftmark\qquad\thepage}}%
      \def\@evenhead{%
      \vbox to 0pt{\vspace*{-39pt}%
         \hbox to \hsize{\hfill Springer Nature 2021 \LaTeX\ template\hfill}}\par%%
      \hspace*{-\textwidth}\hbox to \hsize{\headerfont\thepage\qquad\rightmark\hfill}}%
      \def\@oddhead{%
      \vbox to 0pt{\vspace*{-39pt}%
         \hbox to \hsize{\hfill Springer Nature 2021 \LaTeX\ template\hfill}}\par%%
      \hspace*{-\textwidth}\hbox to \hsize{\headerfont\hfill\leftmark\qquad\thepage}}%
      \let\@mkboth\markboth%
      }%

Replace by

\def\ps@headings{%
    \def\@oddfoot{\hfill}%
    \let\@evenfoot\@oddfoot%
      %%\def\@evenhead{{\headerfont\thepage\qquad\rightmark\hfill\includegraphics{springer-nature-logo}}}%
      %%\def\@oddhead{{\headerfont\includegraphics{springer-nature-logo}\hfill\leftmark\qquad\thepage}}%
      \def\@evenhead{%
      \vbox to 0pt{\vspace*{-39pt}%
         \hbox to \textwidth{\hfill Springer Nature 2021 \LaTeX\ template\hfill}}\par%%
      \hspace*{-\textwidth}\hbox to \textwidth{\headerfont\thepage\qquad\rightmark\hfill}}%
      \def\@oddhead{%
      \vbox to 0pt{\vspace*{-39pt}%
         \hbox to \textwidth{\hfill Springer Nature 2021 \LaTeX\ template\hfill}}\par%%
      \hspace*{-\textwidth}\hbox to \textwidth{\headerfont\hfill\leftmark\qquad\thepage}}%
      \let\@mkboth\markboth%
      }%

(all occurrences of \hsize replaced by \textwidth)

And replace

\def\ps@titlepage{%
     %%\def\@oddhead{\vbox{\vskip-36pt\hbox to \textwidth{\hfill\includegraphics{springer-nature-logo}\hspace*{-1pt}}}}%
     %%\let\@oddhead\@empty\let\@evenhead\@empty%
      \def\@oddhead{%
      \vbox to 0pt{\vspace*{-38pt}%
         \hbox to \hsize{\hfill Springer Nature 2021 \LaTeX\ template\hfill}}}%%
     \let\@evenhead\@oddhead%
     \def\@oddfoot{\vbox to 18pt{\vfill\reset@font\rmfamily\hfil\thepage\hfil}}%%
     \def\@evenfoot{}}%

\def\ps@plain{\let\@mkboth\@gobbletwo%
\let\@oddhead\@empty\let\@evenhead\@empty%
\def\@oddfoot{\vbox to 18pt{\vfill\reset@font\rmfamily\hfil\thepage\hfil}}%
\let\@evenfoot\@oddfoot}%

by

\def\ps@titlepage{%
     %%\def\@oddhead{\vbox{\vskip-36pt\hbox to \textwidth{\hfill\includegraphics{springer-nature-logo}\hspace*{-1pt}}}}%
     %%\let\@oddhead\@empty\let\@evenhead\@empty%
      \def\@oddhead{%
      \vbox to 0pt{\vspace*{-38pt}%
         \hbox to \textwidth{\hfill Springer Nature 2021 \LaTeX\ template\hfill}}}%%
     \let\@evenhead\@oddhead%
     \def\@oddfoot{\vbox to 18pt{\vfill\reset@font\rmfamily\hfil\thepage\hfil}}%%
     \def\@evenfoot{}}%

\def\ps@plain{\let\@mkboth\@gobbletwo%
\let\@oddhead\@empty\let\@evenhead\@empty%
\def\@oddfoot{\vbox to 18pt{\vfill\reset@font\rmfamily\hfil\thepage\hfil}}%
\let\@evenfoot\@oddfoot}%

(also \hsize replaced by \textwidth)