2

When I use unnumbered sections, my titleps headers seem to inherit the section name and numbering from the previous section:

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{titleps}
\newpagestyle{fancy}{
    \headrule
    \sethead{}{\itshape\sectiontitle}{}
    \setfoot{}{\thepage}{}
}
\pagestyle{fancy}

\usepackage{lipsum}

\begin{document}

\section{First section}
\lipsum[1-4]
\clearpage

\section{Second section}
\lipsum[5-8]
\clearpage

\section*{Unnumbered section}
\lipsum[9-12]

\end{document}

In the example, the first two sections get the proper headers, but the third section gets the same header as the second. This also seems to happen to my bibliography (I'm using biblatex). How can I get the name of starred sections and bibliographies in the header?

  • 2
    You can set \sectionmark{Unnumbered section} after that \section* command. – Arash Esbati May 19 '15 at 22:48
2

The entire titlesec module discourages the use of starred version of sectional units. As such, their usage seems may cause unexpected/unwanted results anyway. In this case, however, you're better off issuing a manual \sectionmark{<title>} to update the display in the headers. The process can be automated with the help of xparse:

enter image description here

\documentclass{article}

\usepackage{titleps,xparse}
\newpagestyle{fancy}{
    \headrule
    \sethead{}{\itshape\sectiontitle}{}
    \setfoot{}{\thepage}{}
}
\pagestyle{fancy}
\let\oldsection\section
\makeatletter
\RenewDocumentCommand{\section}{s o m}{%
  \IfBooleanTF{#1}
    {{% \section*
      \oldsection*{#3}% \section*[.]{..}
      \sectionmark{#3}%
    }}{% \section
      \IfNoValueTF{#2}
        {\oldsection{#3}}% \section{..}
        {\oldsection[#2]{#3}}% \section[.]{..}
    }%
}
\makeatother
\usepackage{lipsum}

\begin{document}

\section{Numbered section}
\lipsum[1-3]
\clearpage

\section*{Unnumbered section}
\lipsum[4-6]

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.