# How to update the header and TOC for star marked the sections

I am using the following MWE. I want to define a chapter, with different sections (Prologue, paper 1, paper 2). I want the star marked sections to show up in TOC, for which I am using a user defined command.

However, I see that the page header, does not get updated. I want the page header to be the same as the star marked section or subsection. Can you please help?

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{fancyhdr}

\newcommand*{\tocsection}[1]{%
\refstepcounter{section}%

\pagestyle{fancy}
\fancyhf{}

\begin{document}
\tableofcontents

\chapter{Lorem}
\section{Prologue}
lorem ipsum

The name of this chapter is Lorem. It is chapter 1. This chapter has section called: paper 1, paper 2 and paper 3.

\newpage

The title of the paper I is defined as.
\begin{center}
\begin{minipage}{10 cm}
\huge Electrical Properties\\
\end{minipage}
\end{center}

This paper I, has lot of sections : Introduction, Methods, Results etc.

\subsection*{Introduction}
lorem ipsum dolor sit amet

\newpage

The title of the paper II is defined as.
\begin{center}
\begin{minipage}{10 cm}
\huge Optical Properties\\
\end{minipage}
\end{center}

This paper II, also have a lot of sections : Introduction, Methods, Results etc.

\subsection*{Introduction}
lorem ipsum dolor sit amet

\end{document}

• hi @moewe, here is the MWE of the problem. Can you help? – Rouge Dec 3 '18 at 9:38
• Would it not make more sense to have the header read "Paper I" or "Paper II"? – moewe Dec 3 '18 at 9:42
• For reference, the \tocsection came from tex.stackexchange.com/q/453071/35864. The idea was actually that you'd just write \tocsection{Paper I} and \tocsection{Paper II} in your document and not the entire complicated definition \refstepcounter{section}.... – moewe Dec 3 '18 at 9:45

You need also a \sectionmark command if you want to update the headers:

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{fancyhdr}

\newcommand*{\tocsection}[1]{%
\refstepcounter{section}%

\pagestyle{fancy}
\fancyhf{}

\begin{document}
\tableofcontents

\chapter{Lorem}
\section{Prologue}
lorem ipsum

The name of this chapter is Lorem. It is chapter 1. This chapter has section called: paper 1, paper 2 and paper 3.

\newpage

\refstepcounter{section}%
\sectionmark{Paper 1}%

The title of the paper I is defined as.
\begin{center}
\begin{minipage}{10 cm}
\huge Electrical Properties\\
\end{minipage}
\end{center}

This paper I, has lot of sections : Introduction, Methods, Results etc.

\subsection*{Introduction}
lorem ipsum dolor sit amet

\newpage

\refstepcounter{section}%
\sectionmark{Paper 1}%

The title of the paper II is defined as.
\begin{center}
\begin{minipage}{10 cm}
\huge Optical Properties\\
\end{minipage}
\end{center}

This paper II, also have a lot of sections : Introduction, Methods, Results etc.

\subsection*{Introduction}
lorem ipsum dolor sit amet

\end{document}


• May I suggest incorporating \sectionmark into \tocsection and using that instead of the bare definition of the command. (I know the MWE didn't do that, but it was definitely the intention in the linked answer.) – moewe Dec 3 '18 at 14:06
• Thanks a lot @moewe, it works... Just one last question. can you please how can force lower case word in "Paper I" : I want to write a chemical formula eg Gd2O3. 'd' should be lower case – Rouge Dec 3 '18 at 16:34