1

I'm writing a book, and I would like to have (relatively?) fine-grained control of what numbers are printed in the TOC.

  1. No numbers printed for chapters, only their names.
  2. Section numbers printed for sections, but not their chapter numbers.
  3. Nothing printed for subsections or below.

I've solved 1 by manually adding chapters to the TOC using \addcontentsline{toc}{chapter}{Chapter Title} and then manually running stepcounter{chapter}. I've solved 3 by using \setcounter{tocdepth}{1}.

But I'm unsure of how to fix 2. Current results look like this:

enter image description here

I would like to remove the chapter numbers from the sections, so that, e.g., it was just 1, 2, 3, 4 in the Introduction rather than 1.1, 1.2 and so on. (The Commentary chapter should work the same way. In the Text chapter, it's irrelevant as there are no sections there.)

I'll mention two other things. First, the code I have already feels like Rube Goldberg contraption. I do one thing to keep chapter headings from printing in the text in order that I can print them in a custom manner. Then I do a different thing to suppress default section printing and control how section headings look in the text. So my MWE may be a bit of a mess: sorry for that. Second, whatever I'm doing already seems to cause hyperref to break. Only subsection links work. I suspect that's because I'm manually adding the chapter names. If anyone has a suggestion for that, I would appreciate it.)

MWE:

\documentclass[11pt,letterpaper,oneside]{book}
\renewcommand\section{\@startsection {section}{1}{\z@}{0ex}{0ex}{\@gobble}}
\usepackage{titlesec}
\usepackage[extramarks]{titleps}
\newcounter{firstLine}
\setcounter{firstLine}{1}
\newmarkset{firstLine}
\newextramark*{firstLine}{firstLine}
\newcommand*\topfirstLine{\topextramarks{firstLine}{\arabic{firstLine}}}
\newcommand*\botfirstLine{\botextramarks{firstLine}{\arabic{firstLine}}}
\titleformat{\section}{\centering\normalfont\itshape}{}{0em}{}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{}{0em}{}
\newpagestyle{toc}{%
 \sethead[]% even-left
   [CONTENTS]% even-center
   []% even-right
   {}% odd-left
   {CONTENTS}% odd-center
   {}% odd-right
 \setfoot{}%left
  {\thepage}%center
  {}%right
}
\newpagestyle{introduction}{%
 \sethead[]% even-left
   [INTRODUCTION: \sectiontitle]% even-center
   []% even-right
   {}% odd-left
   {INTRODUCTION: \sectiontitle}% odd-center
   {}% odd-right
 \setfoot{}%left
  {\thepage}%center
  {}%right
}
\newpagestyle{text}{%
 \sethead[]% even-left
   [ODYSSEY BOOK 1]% even-center
   []% even-right
   {}% odd-left
   {ODYSSEY BOOK 1}% odd-center
   {}% odd-right
 \setfoot{}%left
  {\thepage}%center
  {}%right
}
\newpagestyle{commentary}{%
 \sethead[]% even-left
   [COMMENTARY:~%
    \edef\tempa{\topfirstLine}\edef\tempb{\botfirstLine}%
    \topfirstLine\ifx\tempa\tempb\relax\else--\botfirstLine\fi]% even-center
   []% even-right
   {}% odd-left
   {COMMENTARY:~%
    \edef\tempa{\topfirstLine}\edef\tempb{\botfirstLine}%
    \topfirstLine\ifx\tempa\tempb\relax\else--\botfirstLine\fi}% odd-center
   {}% odd-right
 \setfoot{}%left
  {\thepage}%center
  {}%right
}
\newcommand{\chap}[1]{%
 \addcontentsline{toc}{chapter}{#1}%
 \stepcounter{chapter}%
}
\usepackage{hyperref}
% -]]

% [[- Document-
\begin{document}

\begin{titlepage}
\begin{center}
\huge Homer's \textit{Odyssey} Book 1
\newpage
\end{center}
\end{titlepage}

\pagenumbering{roman}
\pagestyle{toc}
\setcounter{tocdepth}{1} % Don't show subsections in the TOC
\renewcommand\contentsname{} % Don't print a section title for TOC
\tableofcontents
\addtocontents{toc}{% Print a header that conforms to book's overall style
 \centerline{\textbf{\large C\,O\,N\,T\,E\,N\,T\,S}}%
 \bigskip%
 \hrule%
 \bigskip%
}

\pagenumbering{arabic}
\pagestyle{introduction}
\clearpage
\chap{Introduction}
\thispagestyle{empty}
\centerline{\textbf{\large I\,N\,T\,R\,O\,D\,U\,C\,T\,I\,O\,N}}
\bigskip
\hrule
\bigskip

\section{Book 1 in the structure of the Odyssey}

Stuff about structure of the poem here.

\section{Characters}

Stuff about characters goes here.

\section{Homeric Greek}

Lots of information about Homeric Greek goes here.

\section{About The Text}

Notes about the text of the poem.

\pagestyle{text}
\clearpage
\chap{Odyssey Book 1}
\thispagestyle{empty}
\centerline{\textbf{\large O\,D\,Y\,S\,S\,E\,Y\,\ B\,O\,O\,K\ 1}}
\bigskip
\hrule
\bigskip

Text of the poem goes here.

\pagestyle{commentary}

\clearpage
\chap{Commentary}
\thispagestyle{empty}
\centerline{\textbf{\large C\,O\,M\,M\,E\,N\,T\,A\,R\,Y}}
\bigskip
\hrule
\bigskip

\section{1--10 Proem}

Commentary goes here.

\end{document}
9
  • @lockstep I've added those two tags back. Can you explain to me how this question is not about sectioning and chapters? Thanks.
    – Telemachus
    Nov 5, 2014 at 15:26
  • Would you consider using a KOMA-class? Oh, titlesec and titleps. Would require some changes to cleanly use KOMA.
    – Johannes_B
    Nov 5, 2014 at 16:06
  • 'Sectioning' and 'chapters' is about those in the Main Text body, not The ToC.
    – lockstep
    Nov 5, 2014 at 16:36
  • @lockstep Yes, and I used the tags for the following reason: I have problems with my TOC based on my use of sections and chapters in the main text body. So I believe the tags fit (and have put them back again). Can we please not make this a tag-editing battle?
    – Telemachus
    Nov 5, 2014 at 16:48
  • @Johannes_B I suppose I'd rather avoid adding something as big as KOMA if I can avoid it. I'm a little surprised that this isn't easier, really. Glad I didn't miss the obvious though.
    – Telemachus
    Nov 5, 2014 at 16:50

1 Answer 1

0

This turned out to be an easy and simple fix. Just add the following:

\renewcommand\thesection{\arabic{section}}

You can also then remove my earlier kludge to remove the section number from printing in the body of the text:

\renewcommand\section{\@startsection {section}{1}{\z@}{0ex}{0ex}{\@gobble}}

Results:

enter image description here

You must log in to answer this question.

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