# colored toc and shorttoc?

I want to have colored part and chapter names in my shorttoc and my toc. So I worked out how to get the shorttoc colored, but I do not know how to get the toc also colored the same way? If I add the commands twice (between \makelatter and \makeatother) it does not work. So how can I get both colored the same way?

Here's my code:

\documentclass{book}

\usepackage[pagestyles]{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}

\titleformat{\section}

\titleformat{\subsection}

\titleformat{\subsubsection}

\titleformat{\paragraph}

\usepackage[ngerman]{babel}

\usepackage{xcolor,bookmark}
\usepackage{shorttoc}
\usepackage{tocstyle}
\usetocstyle{allwithdot}

\begin{document}
\frontmatter
\makeatletter
\let\stdl@part\l@part
\renewcommand*{\l@part}[2]{%
\let\stdl@chapter\l@chapter
\renewcommand*{\l@chapter}[2]{%

\makeatother

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\shorttableofcontents{Inhalts\"ubersicht}{1}
\bookmark[page=15,rellevel=1,keeplevel,view={XYZ},color=red]{Inhalts\"ubersicht}
\bookmark[page=17,rellevel=1,keeplevel,view={XYZ},color=red]{Inhaltsverzeichnis}
\tableofcontents
\clearpage
\pagenumbering{arabic}

\mainmatter

\part{test}
\chapter{test}
\section{test1}
\section{test2}
and so on....
and so on.....
\end{document}


Now the shorttoc is colored bot not the toc, but I want both colored.

-
This really isn't a MWE: meta.tex.stackexchange.com/questions/228/… –  StrongBad Sep 5 '12 at 10:27
any hints though? By the way, what is not working? –  Heronimious Sep 5 '12 at 11:49
@Daniel E. Shub maybe you have a solution for me? –  Heronimious Sep 5 '12 at 14:53
@Gerondus I have edited your MWE, namely made it shorter, such that problem you have is still visible. –  Dror Sep 7 '12 at 8:44

In your example, you're modifying \l@part and \l@chapter to add color to the respective ToC entries. But you also load the tocstyle package and choose the allwithdot style, which means that your former modifications won't affect the normal ToC, only the one created by shorttoc (which isn't controlled by tocstyle). Result: The short ToC is colored, but missing dots for parts/chapter entries, while the normal ToC features the dots, but is missing the color. One way to achieve a consistent ToC layout is to simply remove the lines

\usepackage{tocstyle}
\usetocstyle{allwithdot}


from your preamble. The other way (if you want color and dots for part/chapter entries) is to get rid of shorttoc and to use toctsyle's \showtoc command to produce a partial ToC (see p. 10 of the manual for details).

\documentclass{book}

\usepackage{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}
\titleformat{\chapter}[display]
\titleformat{\section}
\titleformat{\subsection}

\usepackage[ngerman]{babel}

\usepackage{xcolor}

\usepackage{tocstyle}
\usetocstyle{allwithdot}

\begin{document}

\newcounter{savedtocdepth}
\setcounter{savedtocdepth}{\value{tocdepth}}
\setcounter{tocdepth}{1}
\chapter*{Inhalts\"ubersicht}
\markboth{\MakeUppercase{Inhalts\"ubersicht}}{\MakeUppercase{Inhalts\"ubersicht}}
\showtoc{toc}
\setcounter{tocdepth}{\value{savedtocdepth}}

\tableofcontents

\part{test}

\chapter{test}

\section{test1}

\subsection{test11}

\end{document}


-