# \sections without numbers, but in ToC and in running heads

I'm doing a book-class doc which is a collection of problems offered through some years.

So each chapter is a year, and it always has two sections: Problems, and Solutions. And I need them to NOT be numbered, BUT added to ToC (without number), and be present in the running head on the odd page.

secnumdepth doesn't do it, because subsections (the problems) are numbered

I've tried using \renewcommand{\thesection}{} but this only makes the numbers disappear, while the space that was between the section number and the header is preserved, so the section titles appear off in the ToC. The same space is present in the running head, and additionally, a full stop appears before the space in the running head.

I've also tried

\newcommand\problems{\section*{\addcontentsline{toc}{section}{Problems}Problems}


which makes for an ok-looking ToC, but doesn't give me the running heads.

I understand that packages like titlesec and titletoc might help me, but I'd rather make it as standalone-ish as possible.

• Welcome to TeX.SE! have you tried \markboth? – cmhughes Apr 21 '13 at 15:35
• Which document class do you use? If you use scrbook you can use \addchap – Marco Daniel Apr 21 '13 at 15:41
• @MarcoDaniel, I use \documentclass{book}. @cmhughes, you did it! \markright with \addcontentsline inserted into \section* does the trick! I somehow got the impression that only fancyhdr could change the running heads, totally forgot about the mark commands. – Alexander Pavlov Apr 21 '13 at 16:45
• ok, that's great :) - I'll flag it for a moderator as we have resolved it in the comments. Note that you can only 'ping' one person per message using the @ symbol :) – cmhughes Apr 21 '13 at 20:14
• @cmhughes Below I proposed a solution that doesn't require any manual intervention and that might be useful for the OP, so I would like to ask you not to flag the question. – Gonzalo Medina Apr 21 '13 at 21:35

No need to use manually issue \markright and \addcontentsline commands after each section. Let LaTeX do all the work for you: redefine \thesection (and \thesubsection) appropriately; for example:

\renewcommand\thesection{}
\renewcommand\thesubsection{\arabic{subsection}}


redefine \l@section to suppress the indentation for entries in the ToC; redefine \section to suppress the indent in the titles, and finally (re)define \sectionmark to give you the desired header:

\documentclass{book}
\usepackage{lipsum}

\renewcommand\thesection{}
\renewcommand\thesubsection{\arabic{subsection}}
\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{0em}{1.5em}}
\renewcommand\section{\@startsection {section}{1}{-1em}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}
\def\sectionmark#1{%
\markright {\MakeUppercase{#1}}}
\makeatother

\begin{document}

\tableofcontents

\chapter{2012}
\section{Problems}
\subsection{First problem}
\lipsum[1-10]

\end{document}