5

I am trying to change the color of the \chapter/\section in the TOC, depending on the "progress" of each.

That means, I basically want to see at the TOC if the chapter is finished, still in progress of writing or unwritten yet. To indicate that progress I want to use different colors.

I searched for the problem and found a solution that I hope to adapt to my special problem: different colors on toc

But the problem of this solution is, that with every new chapter, the counter simple increases, resulting in a color change. But what I am searching for is a way to set the counter for each section specific.

I hope that I can do this with the \setcounter command, but I am not sure where to put each command so that it is different for each \chapter, \section and \subsection.

Incanus
  • 51

1 Answers1

2

The solution, you have found, changes the color of the chapter entries according to their number, as you have already found out yourself, so it can't be applied to your problem.

The way I understand your problem, LaTeX won't be able, to solve it without your gentle help.

You said, you want to use colors in order to visualize the status of each part of your document. For example red would mean, this \chapter wasn't written, orange means, there has been some text added but that part of the document is still in progress, yellow could mean, that the writing process has come to an end, while the proof reading hasn't and green finaly is the color for a finalized version of your text? Is that correct?

In that case, you'll have to define an indicator, which stores the status of your text, as described above. Lets assume, you'll define this in you preamble:

\def\@status{0}
\newcommand{\statusnotstarted}[1]{\def\@status{0}}
\newcommand{\statusstarted}[1]{\def\@status{1}}
\newcommand{\statusproofing}[2]{\def\@status{0}}
\newcommand{\statusfinal}[3]{\def\@status{0}}

Than, the value of \@status could be used to determine the color of your TOC entries. You would have to define the code from the solution you've found here to this

\newcommand*\toccolor{%
    \ifcase\value{\@status}% new variable used here!
         \color{red}%----- 0 --
    \or  \color{orange}%---- 1 --
    \or  \color{yellow}%--- 2 --
    \or  \color{green}%---- 3 --
    \else \color{black}%-- default
    \fi}

The rest of that solution could be copied as presented, no need to change anything else. (Haven't tested it myself, though.)

EDIT: Usage in the document would be:

\statusnotstarted
\chapter{Introduction}
\chapter{Definitions}
\statusstarted
\chapter{Test Environment}
\section{Laboratory}
There habe been tests ...
Jan
  • 5,293
  • The way you understand my problem is correct. Currently i am trying to adapt your solution to the problem. I have to add to each \chapter \section ... the command e.g. \statusnotstarted but this is not working at the moment. – Incanus Jan 03 '17 at 14:02
  • I always geht the "! Missing number, treated as zero." error for each \chapter, \section etc. Can you show me an example usage ? – Incanus Jan 03 '17 at 14:35
  • The current state must be written to the ToC in order to get the correct colour information –  Jan 03 '17 at 18:16