3

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?

7
  • Have you tried using \chapter*{Chapter title}?
    – Werner
    Commented May 12, 2014 at 23:38
  • @Werner First thing I tried, but this also excludes it from the table of contents which I did not want Commented May 12, 2014 at 23:40
  • Are you saying that the chapter number does not change?
    – Sigur
    Commented May 12, 2014 at 23:47
  • @Sigur At the start of every chapter in the main body, theres a big line of text saying "Chapter 4" for example. Commented May 12, 2014 at 23:52
  • 6
    The typical solution here is to use \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.
    – Werner
    Commented May 12, 2014 at 23:52

2 Answers 2

4

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:

enter image description here

and the first page of the first chapter is:

enter image description here

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.

4

The following addition using xparse forces chapters to be seen as a starred chapter:

enter image description here

\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>}.

2
  • 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .