# Sections : Suppress numbers but retain title in header

I've found an answer to my question for a Memoir Class (Memoir class: turn off section numbering but still have header), but I can't get it to work for a book.

Basically, I want to suppress the numbering of sections, but I still want to be able to have my section names appear in my headers.

The code below works fine in section 2, but, in section 1, where I suppress the numbering, I also lose the header.

\documentclass[a4paper]{book}

\usepackage{fancyhdr,blindtext}
\pagestyle{fancy}
\fancyfoot{}

\usepackage{blindtext}

\begin{document}

% Global font
\renewcommand{\rmdefault}{ppl}
\fontencoding{T1}
\fontfamily{ppl}
\fontsize{14}{18}
\selectfont

% Start the chapters here:

\chapter{Preface}

\section*{Section 1}

\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\section{Section 2}

\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document}


This is easy with the package titlesec.

\usepackage[pagestyles]{titlesec}


instead of loading fancyhdr.

Then, to have your section without printed numbers, define

\titleformat{\section}{\normalfont\Large\bfseries}{}{0em}{}


and to have the headers like you want,

\newpagestyle{fancy}{
{\textsl{\MakeUppercase{\chaptername\ \thechapter. \ \chaptertitle}}}{}{\thepage}% odd
}
\pagestyle{fancy}


MWE:

\documentclass[a4paper]{book}

\usepackage{blindtext}

\usepackage[pagestyles]{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{}{0em}{}

\newpagestyle{fancy}{
{\textsl{\MakeUppercase{\chaptername\ \thechapter. \ \chaptertitle}}}{}{\thepage}% odd
}
\pagestyle{fancy}

\begin{document}

% Global font
\renewcommand{\rmdefault}{ppl}
\fontencoding{T1}
\fontfamily{ppl}
\fontsize{14}{18}
\selectfont

% Start the chapters here:

\chapter{Preface}

\section{Section 1}

\blindtext
\blindtext

\section{Section 2}

\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document}


Output:

• This is great; thanks very much. I think I'll opt for this particular solution since it allows me to continue to use the standard \section tag, which then makes my text easier to cut and paste into other docs. – James Bejon Jan 4 '15 at 13:14
• @JamesBejon You're welcome. Glad it helped. – karlkoeller Jan 4 '15 at 13:14

You can define a new command

\newcommand\mysection[1]{%
\section*{#1}%
}


Code:

\documentclass[a4paper]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}

\newcommand\mysection[1]{%
\section*{#1}%
}

\usepackage{blindtext}
\begin{document}
\chapter{Preface}
\mysection{Section 1}
\Blindtext[10]
\section{Section 2}
\Blindtext[10]
\end{document}


Or maybe you can use the KOMA-Script class scrbook. There is a command \addsec to get an unnumbered section that appears in the header and in the tableofcontents.

\documentclass[11pt,headsepline,chapterprefix]{scrbook}
\usepackage[pagestyleset=standard]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot[\pagemark]{}

\usepackage{blindtext}
\begin{document}
\chapter{Preface}
\Blindtext[10]
\Blindtext[10]
\end{document}


Or you can simple use

\setcounter{secnumdepth}{0}


if only parts and chapters should be numbered.

\documentclass[a4paper]{book}
\setcounter{secnumdepth}{0}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}

• I thought there were both unnumbered and numbered sections in the document. But if only parts and chapters should be numbered, you can simple use \setcounter{secnumdepth}{0}. – esdd Jan 4 '15 at 17:32