I tried to setup a fresh LaTeX template for my thesis. I wanted to display the chapter number and name as well as the section number and name in the header using fancyhdr following the convention . Here is my code:
\documentclass[9pt,twoside,a5paper,openany]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{fancyhdr}
\renewcommand\chaptermark[1]
{%
\markboth
{%
\ifnum \c@secnumdepth > \m@ne
\if@mainmatter
\thechapter . \
\fi
\fi
#1%
}{}%
}
\renewcommand\sectionmark[1]{%
\markright{% <- this would produce a space without the %
\ifnum \c@secnumdepth > \z@
\thesection. \ % <- the spacing in the original definition
\fi
#1}% <- this would produce a space without the %
}
\patchcmd\tableofcontents{\MakeUppercase}{}{}{\ERROR}
\patchcmd\tableofcontents{\MakeUppercase}{}{}{\ERROR}
\pagestyle{fancy}
%\fancyhead{} % clear all header fields
%\fancyfoot{} % clear all footer fields
%\fancyhead[LE]{\leftmark}
%\fancyhead[RO]{\rightmark}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.8pt}
\renewcommand{\footrulewidth}{0.8pt}
\begin{document}
\frontmatter
\chapter*{Dedication}
\lipsum
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\chapter{Test}
\section{Section}
\lipsum[0-200]
\appendix
\chapter{First and only appendix}
\backmatter
\chapter{Bibliography}
\end{document}
However, I get the following errors:
51 - Missing number, treated as zero. \chapter{Test}
51 - Missing = inserted for \ifnum. \chapter{Test}
51 - Missing number, treated as zero. \chapter{Test}
51 - Undefined control sequence. \chapter{Test}
Does anyone have a clue what causes the issue?
Thanks in advance!
\makeatletterand\makeatotherare missing. They are needed, because your definitions use macro names with@. – cabohah Sep 05 '23 at 13:14