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 have the following LaTeX document being compiled in TeXstudio 2.3 on Windows 7 (mode is PdfLatex + PdfViewer):

\documentclass[a4paper,12pt]{report}

% Modified \part and \chapter from report.cls
\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \Huge \bfseries #2\par}%
    \@endpart}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}\makeatother
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\renewcommand{\thesection}{\arabic{section}}% Remove \thechapter from \thesection}
\makeatother
\begin{document}
    \tableofcontents
    \part{Part One}
    \chapter[Chapter Other One]{Chapter One}
    \section{Section First}
    \subsection{Subsection X}
    Djigurda is here.
    \subsection{Castles with Penguins}
    Castles with penguins here.
\end{document}​

Problem is, \chapter command produces 2 lines in resulting PDF:

Example

So how do I turn off numbered headings? I want only Chapter One to appear.

share|improve this question
    
What about Chapter One's Chapter 1? Also, do you want \part to show up in the ToC? –  Werner Sep 7 '12 at 21:19
    
@Werner same for chapters — named only. And I want them both in ToC –  constantius Sep 7 '12 at 21:27

1 Answer 1

up vote 8 down vote accepted

Here's a set of redefinitions of sectional units in report.cls. It removes the number of \part and \chapter to be printed in the ToC, as well as the main report body. However, the counters are still incremented in order to reset other slave counters, as is necessary.

enter image description here

\documentclass[a4paper,12pt]{report}
%\usepackage[T2A]{fontenc}% http://ctan.org/pkg/fontenc
%\usepackage[utf8]{inputenc}% http://ctan.org/pkg/inputenc
%\usepackage[english]{babel}% http://ctan.org/pkg/babel

% Modified \part and \chapter from report.cls
\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \Huge \bfseries #2\par}%
    \@endpart}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\renewcommand{\thesection}{\arabic{section}}% Remove \thechapter from \thesection}
\makeatother
\begin{document}
    \tableofcontents
    \part{Part One}
    \chapter[Chapter Other One]{Chapter One}
    \section{Section First}
    \subsection{Subsection X}
    Djigurda is here.
    \subsection{Castles with Penguins}
    Castles with penguins here.
\end{document}​

The affected macros are

  • \@part (removed printing Part \thepart and including \thepart in the ToC);
  • \@chapter (removed printing \thechapter in the ToC);
  • \@makechapterhead (removed printing Chapter \thechapter in the chapter heading); and
  • \thesection (removed printing \thechapter as part of the counter).
share|improve this answer
    
Thank you! Somehow it made to work only \part (\chapter still gives both numbered and named headings) –  constantius Sep 12 '12 at 23:13
    
@Constantius: And you included (copy-and-paste) the redefinition of both \@chapter and \@makechapterhead? If this is the case, what other packages do you include that could affect the sectioning commands? titlesec or perhaps sectsty? –  Werner Sep 12 '12 at 23:17
    
in fact, I tried bare example you provided — works for \part, but not for \chapter (there is no packages included at all) –  constantius Sep 12 '12 at 23:21
    
@Constantius: ToC entries are accumulated over at least two compile runs. If you did that and still get numbered chapters in the ToC with my MWE, then I don't know what to say... Perhaps include the exact code and exact output as part of your original question (via an edit). –  Werner Sep 12 '12 at 23:29
    
ToC is okay, problem is in document itself. Will edit the question now –  constantius Sep 12 '12 at 23:40

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.