Assume I have finished two sections of my book so far, yet I want to display my preliminary ToC with all parts and chapters (but with no page number) as a preview like this:
I First Part 1
1 First Chapter 3
1.1 First Section .... 3
1.2 Second Section ... 5
1.3 Third Section ....
2 Second Chapter
2.1 First Section ....
2.2 Second Section ...
2.3 Third Section ....
II Second Part
3 Third Chapter
1.1 First Section ....
1.2 Second Section ...
1.3 Third Section ....
4 Fourth Chapter
2.1 First Section ....
2.2 Second Section ...
2.3 Third Section ....
How can I include these pseudo-parts/chapters/sections etc. without having empty parts/chapters/sections in the document.
Best Answer
Note See the
GhostChapters
version at the bottomThe preliminary entries can be added by faking
\addtocontents
and omitting the 2nd argument to the original\contentsline{}
command, thus removing the page number.In lack of a MWE this works for
book
,scrbook
andmemoir
classes so far only.Ghostchapter - version
This version uses the concept of
ghost
chapters (i.e. \parts, \chapters etc.) By using\EnableGhostChapters
at 'any' arbitrary position in the document the following structure commands are disabled, but add an entry toToC
. It works forscrbook
,memoir
down tosubparagraph
, and up tosubsubsection
forbook
class -- I did not figure out why it fails forparagraph
andsubparagraph
for the book class... (weird definition?)The ghost chapters are displayed with
darkgray
color in the ToC.Use
\DisableGhostChapters
to switch back to normal behaviour.The macros
\EnablePagesInToc
and\DisablePagesInToc
enable/disable the display of the page number in the ToCNote: Although I used
\patchcmd
... it's not a patch, it's a hack ;-)It does not work correctly for
\include{}
but with\input{}