0

I tried the solution given in Start a new chapter without heading Which temporally causes @makechapterhead to simply gobble it's text argument.

\makeatletter
\newcommand{\unchapter}[1]{%
  \begingroup
  \let\@makechapterhead\@gobble % make \@makechapterhead do nothing
  \chapter{#1}
  \endgroup
}
\makeatother

\unchapter{test chapter}

However, this prints a NUMBERED "test chapter" in the TOC.

In my book document ... I use \chapter*{test chapter} (which is unnumbered, but is also not printed in toc either) ... in combination with \addcontentsline{toc}{chapter}{test chapter} ... which does make an entry in the TOC for the current chapter.

Is there anyway to modify the solution given above for my particular case? I want an unnumbered entry in the toc, and also no title header on the chapter's starting page - for a single chapter only.

I tried to modify the above solution for my case as follows:

\makeatletter
\newcommand{\unchapter}[1]{%
  \begingroup
  \let\@makechapterhead\@gobble % make \@makechapterhead do nothing
  \chapter*{#1}
  \endgroup
}
\makeatother

\unchapter{test chapter}

But this still causes a chapter title header to be printed on the chapter's starting page.

Recap:. The first solution works (as far as not printing a title on the chapter's starting page - which is what I want) ... but makes the toc entry as a numbered chapter (whereas I need an unnumbered entry for the chapter in the toc).

My attempt to modify the first solution, given as the second solution ... still makes a chapter's start contain a printed header.

9
  • This is not a very elegant solution ... but it does work: \chapter*{\phantom{Chapter Title Here}} \addcontentsline{toc}{chapter}{Chapter Title Here} \vspace{-2in} text of your page still, I am hoping for a more elegant solution than this hack.
    – RichWalt
    Mar 11, 2022 at 18:10
  • What's the problem with \cleardoublepage\addcontentsline{toc}{chapter}{text}?
    – egreg
    Mar 11, 2022 at 18:27
  • I could try that ... but first, let me ask, I have the flag set to FALSE for start chapters on right ... will this mess that up ? I'm trying to reproduce a book exactly, (page for page) and it has some of it's TOC entries starting on the left hand side ... it only uses a level-0 class for toc entries.
    – RichWalt
    Mar 11, 2022 at 18:34
  • \cleardoublepage will not skip to an odd-numbered page if the openany option is in force, which is the default for report, but has to be given to book.
    – egreg
    Mar 11, 2022 at 18:35
  • I'll give it a try ... but I was referring to: \csname @openrightfalse\endcsname %forces chapter to start on left page if next page is on left
    – RichWalt
    Mar 11, 2022 at 18:41

1 Answer 1

1

The solution is already in start chapter with no headings

(1) Second chapter starts without heading

(2) An entry is added to the ToC

(3) Links in ToC works fine.

b

Link of Test unchapter remits to page 5, the starting of the chapter without headings.

e

\documentclass[12pt,a4paper]{book}

\usepackage{hyperref}   

\usepackage{kantlipsum}% only dummy text

\makeatletter
\newcommand{\unchapter}[1]{% FROM https://tex.stackexchange.com/a/624410/161015
    \begingroup
    \let\@makeschapterhead\@gobble % make \@makechapterhead do nothing
    \chapter*{#1}
    \addcontentsline{toc}{chapter}{#1}
    \markboth{#1}{}
    \endgroup
}
\makeatother


\begin{document}
\tableofcontents

\chapter{One}
1. \kant[1]

\unchapter{Test unchapter}
2. \kant[2]

\chapter{Two}

3. \kant[3]     
    
\end{document}
1
  • Works ! Perfect. Thanks.
    – RichWalt
    Mar 12, 2022 at 14:10

You must log in to answer this question.

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