0

The chapters in the book I'm working on are all named. However, while I want the names to show up in the TOC, I want the numbers and the numbers only to show up as the chapter headings. (I know that sounds weird, and I'll be happy to explain why if it matters.)

So, for example, the name of chapter I is "De Puero Superstite." I want "De Puero Superstite" to show up in the TOC, but only the number I to show up as the chapter heading. (I've already got it set to Roman numerals.)

Is there a way to do this? If I need to I can use titlesec to redefine the title format, leave the numbers out entirely, and do eg \chapter[De Puero Superstite]{I}, but there's got to be a more elegant way to do it.

Any thoughts?

EDIT: By "Chapter Heading" I mean not the page header—the thing that appears at, for example, the very top of every left page (or every right page, or every page) but the thing that appears once before the text of the chapter begins.

1

It depends on whether you want the ToC entry to appear in the page headers or not. For the ToC entry and page header entries to be the same.

% chapternameprob.tex  SE 544473 no name in division header
%\documentclass{memoir}
\documentclass{book}
\usepackage{lipsum}
\renewcommand{\chaptername}{} % eliminate Chapter in divisional heading
\begin{document}
\tableofcontents
\chapter[toc and header entry]{} % empty divisional title
\lipsum
\end{document}

For them to be different use the memoir class:

% chapternameprob.tex  SE 544473 no name in division header
\documentclass{memoir}
%\documentclass{book}
\usepackage{lipsum}
\renewcommand{\chaptername}{}
\begin{document}
\tableofcontents
\chapter[toc entry][header entry]{}
\lipsum
\end{document}

The memoir class enables you to have different entries in the ToC, the page header, and the main document for all the divisional commands (\chapter ... \subparagraph)

| improve this answer | |
  • Thank you! This works beautifully! – Joel Derfner May 16 at 21:14
0

Try this.

\documentclass{book}
\usepackage{titlesec}
\usepackage{xpatch} % for \xpatchcmd
\usepackage{lipsum} % for \lipsum to produce dummy texts 

\makeatletter
% hide chapter title (e.g., "first title")
\xpatchcmd\ttl@mkchap
  {\ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}}
  {\ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{}}
  {}{\fail}
\makeatother

% hide \chaptername (the word "Chapter" followed by a space)
% based on `texdoc titlesec`, sec. 9.2
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}
  % before: {\chaptername\ \thechapter}
  {\thechapter}
  {20pt}
  {\Huge}

\renewcommand\thechapter{\Roman{chapter}}

\begin{document}
\chapter{first title}
\lipsum

\chapter{second title}
\lipsum
\end{document}

enter image description here enter image description here

| improve this answer | |
  • Hunh. A MWE of your code gives me "1," which I want, followed by "first title," which I don't. Have I missed something? Sorry not to understand. – Joel Derfner May 16 at 0:25
  • @JoelDerfner Do you copy-and-paste my whole example, or just use add the redefinition of \chaptermark into your existing document? – muzimuzhi Z May 16 at 0:46
  • I did a new LaTeX file, copied and pasted just your code into it, and compiled it. It gave me "1 first title." – Joel Derfner May 16 at 0:50
  • @JoelDerfner Which latex distribution and which version of that distribution are you using? Does the compiling results in any errors? The output is ok both on my side (texlive 2020) and on overleaf.com (texlive 2019). – muzimuzhi Z May 16 at 1:00
  • That is really, really weird, because I'm using texlive 2019 on overleaf! I took a screen shot to show you but I can't seem to add it to a comment. (In case it matters, I'm using pdfLaTeX.) – Joel Derfner May 16 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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