I'm using a template from a website, and every time a new chapter starts, 'Chapter 3' for example appears and its quite absurd. How do I edit this feature out of the code?
2 Answers
You are using dmathesis
which is based on the standard report
document class and keeps the standard definitions for formatting chapter headings, so you can use the titlesec
package:
\documentclass{dmathesis}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\bfseries}{}{0pt}{\Huge}
\begin{document}
\tableofcontents
\chapter{Test chapter one}
\chapter[Two]{Test chapter two}
\end{document}
If you don't want to load titlesec
, you can redefine \@makechaptertitle
:
\documentclass{dmathesis}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
% \ifnum \c@secnumdepth >\m@ne
% \huge\bfseries \@chapapp\space \thechapter
% \par\nobreak
% \vskip 20\p@
% \fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\begin{document}
\tableofcontents
\chapter{Test chapter one}
\chapter[Two]{Test chapter two}
\end{document}
In both cases the table of contents is:
and the first page of the first chapter is:
As you can see, the full functionality of \chapter is preserved (you have the optional argument for an eventual different entry in the ToC and headers and also marks are appropriately generated).
Another option would be to patch the command with the help of, for example, etoolbox
.
The following addition using xparse
forces chapters to be seen as a starred chapter:
\documentclass{dmathesis}
\usepackage{xparse}
\let\oldchapter\chapter
\RenewDocumentCommand{\chapter}{s o m}{%
\oldchapter*{#3}%
\IfNoValueTF{#2}
{\addcontentsline{toc}{chapter}{#3}}%
{\addcontentsline{toc}{chapter}{#2}}}
\begin{document}
\tableofcontents
\chapter[A test chapter]{Test chapter}
\end{document}
One advantage is that it still allows for a different ToC entry for each chapter using \chapter[<ToC entry>]{<Body entry>}
.
-
Doesn't this destroy the marking mechanism for (eventual) headers? Commented May 13, 2014 at 2:38
-
@GonzaloMedina: Yes; those definition can be added to the updated
\chapter
command. For example, adding\chaptermark{<*>}
in either of the conditional location will restore the usual chapter marks.– Werner ♦Commented May 13, 2014 at 3:31
\chapter*{Chapter title}
?\chapter*{Chapter title}\addtocontents{toc}{chapter}{Chapter title}
, but this can be automated. Can you please provide us with a minimal working example (MWE) that shows your current setup... it's just easier to see whether this might conflict with a solution rather than giving you something that might not work right away.