Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Have you tried using \chapter*{Chapter title}? –  Werner May 12 at 23:38
    
@Werner First thing I tried, but this also excludes it from the table of contents which I did not want –  user3448561 May 12 at 23:40
    
Are you saying that the chapter number does not change? –  Sigur May 12 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. –  user3448561 May 12 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 May 12 at 23:52

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer

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

share|improve this answer
    
Doesn't this destroy the marking mechanism for (eventual) headers? –  Gonzalo Medina May 13 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 May 13 at 3:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.