Page Layoutindicate unfinished chapters in TOC in draft 'book'

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

indicate unfinished chapters in TOC in draft 'book'

Post by maja z »

Hi!

I have to hand in a draft (very unfinished) thesis - \documnetclass{book}

I would like the table of contents to somehow indicate which chapters are unfinished - missing.

Essentially I need some sort of newcommand that behaves like \chapter, but the toc entry is e.g. gray. And that should be the chapter number, the title and the page number entry.

This way I could enter \notyetchapter placemarks where they will go and have the toc exhibit the correct structure indicating what is missing.

Is that possible?

Thanks!

maja.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

indicate unfinished chapters in TOC in draft 'book'

Post by maja z »

OK, left to my own devices I've managed to come up with :

Code: Select all

\let\notyetchapter\chapter
\renewcommand{\notyetchapter}[1]{\chapter{\color{gray}{#1}}}
which makes the chapter title in text and in the ToC gray!

I would still like the rest of the ToC entry to be gray? As in the chapter number and the page number (the dots even?). Can anyone help me with this?

Thanks!

maja.


PS: As a complete newbie I usually resort to heavy googling to find similar code I then try to tweek. But obviously with renewcommand type stuff, if you don't know what the original definitions are and what they refer to you don't know which ones to change? I have no idea where the [1] in the above definition came from or how am I supposed to find out what the argument is for the toc page number e.g.? How do you know what @startsection or l@chapter mean? (just two unknown quantities encountered in my travels). If anyone could point me to a tutorial of some sorts I would be really grateful!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

indicate unfinished chapters in TOC in draft 'book'

Post by gmedina »

Hi,

try this modification to your command:

Code: Select all

\documentclass{book}
\usepackage{xcolor}

\let\notyetchapter\chapter
\renewcommand{\notyetchapter}[1]{%
  \addtocontents{toc}{\color{gray}}
  \color{gray}\chapter{#1}\normalcolor
  \addtocontents{toc}{\color{black}}
}

\begin{document}
\tableofcontents

\chapter{Test chapter}
\notyetchapter{Unfinished test chapter}
\chapter{Another Test chapter}
\notyetchapter{Another unfinished test chapter}

\end{document}
maja z wrote:...If anyone could point me to a tutorial of some sorts I would be really grateful!
I would suggest The LaTeX Companion (2nd Edition) and Guide to LaTeX (4th Edition).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

Re: indicate unfinished chapters in TOC in draft 'book'

Post by maja z »

Thanks gmedina, worked like a charm!

Just curious though, of the three lines:
1. \addtocontents{toc}{\color{gray}}
2. \color{gray}\chapter{#1}\normalcolor
3. \addtocontents{toc}{\color{black}

So you're essentially using 1. and 3. to change the color in the toc and then change it back, so everything in between is gray, yes?

what about 2.? is it the same as
\chapter{\color{gray}{#1}}
What's the difference? (why the normalcolor?)

Thanks for the tips as well (I have a 1st edition Latex companion and use it more as a look-up, but should probably read the whole thing at some point!)

Cheers!

Maja
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

indicate unfinished chapters in TOC in draft 'book'

Post by gmedina »

Hi, Maja
maja z wrote:Thanks gmedina, worked like a charm!..
You're welcome.
maja z wrote:...So you're essentially using 1. and 3. to change the color in the toc and then change it back, so everything in between is gray, yes?..
That's correct.
maja z wrote:...what about 2.? is it the same as
\chapter{\color{gray}{#1}}
What's the difference?..
It's not the same: \color{gray}\chapter{#1} changes the color for both the title itself and the heading (the string "Chapter n" that appears before the title) whilst \chapter{\gray{#1}} will only change the color for the title, but "Chapter n" will still appear black.
maja z wrote:...(why the normalcolor?)
To restore the black color; if you suppress that command from my code, the contents of the chapter will also be typeset in gray color.

In fact, the following code will have the same effect than the one I used before:

Code: Select all

\let\notyetchapter\chapter
\renewcommand{\notyetchapter}[1]{%
  \addtocontents{toc}{\color{gray}}
  \color{gray}\chapter{#1}\normalcolor
  \addtocontents{toc}{\protect\normalcolor}
}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

Re: indicate unfinished chapters in TOC in draft 'book'

Post by maja z »

Thanks againfor taking the time for the explanation!!
m.
Post Reply