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}%
\addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\rightmark}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\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}\addcontentsline{toc}{section}{\protect\numberline{\thesection}Paper I}\label{Paper I}
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}\addcontentsline{toc}{section}{\protect\numberline{\thesection}Paper II}\label{Paper II}
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}
\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}...
.