2

I want to remove the section numbers from the header in memoir. I used the code below, it works, but it remains a troublesome dot that precedes the section name. How to remove it?

\documentclass[a4paper,11pt,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\renewcommand{\thesection}{}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
\makeatletter
\def\@seccntformat#1{\csname #1ignore\expandafter\endcsname\csname the#1\endcsname\quad}
\let\sectionignore\@gobbletwo
\let\latex@numberline\numberline
\def\numberline#1{\if\relax#1\relax\else\latex@numberline{#1}\fi}
\makeatother

\begin{document}

\begin{KeepFromToc}
\tableofcontents
\end{KeepFromToc}

\chapter{First chapter}
\lipsum[1]
\section{First section}
\lipsum[2-4]
\section{Second section}
\lipsum[5-8]

\end{document}
2

I believe you can do it much more simply:

\documentclass[a4paper,11pt,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\setsecnumdepth{chapter}

\begin{document}

\tableofcontents

\chapter{First chapter}
\lipsum[1]
\section{First section}
\lipsum[2-4]
\section{Second section}
\lipsum[5-8]

\end{document}
  • Just remember \maxsecnumdepth{chapter} if \mainmatter gets introduced (it resets secnumdepth) – daleif Sep 5 '16 at 5:51

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.