Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{\chapter}[display]{\color{headercolor}\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

\titleformat{\section}
{\color{headercolor}\normalfont\Large\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}
{\color{headercolor}\normalfont\Large\bfseries}{\thesubsection}{1em}{}

\titleformat{\subsubsection}
{\color{headercolor}\normalfont\large\bfseries}{\thesubsubsection}{1em}{}

\titleformat{\paragraph}
{\color{headercolor}\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}

\usepackage[ngerman]{babel}
\usepackage[hidelinks]{hyperref}

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

\definecolor{headercolor}{rgb}{0.6941,0.6745,0.4863}

\begin{document}
\frontmatter
\makeatletter
\let\stdl@part\l@part
\renewcommand*{\l@part}[2]{%
  \stdl@part{\textcolor{headercolor}{#1}}{\textcolor{headercolor}{#2}}}
\let\stdl@chapter\l@chapter
\renewcommand*{\l@chapter}[2]{%
  \stdl@chapter{\textcolor{headercolor}{#1}}{\textcolor{headercolor}{#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.

share|improve this question
    
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

1 Answer 1

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]
    {\color{headercolor}\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat{\section}
    {\color{headercolor}\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
    {\color{headercolor}\normalfont\Large\bfseries}{\thesubsection}{1em}{}

\usepackage[ngerman]{babel}

\usepackage{xcolor}
\definecolor{headercolor}{rgb}{0.6941,0.6745,0.4863}

\usepackage{tocstyle}
\usetocstyle{allwithdot} 
\settocstylefeature[-1]{entryhook}{\color{headercolor}\bfseries\large}
\settocstylefeature[0]{entryhook}{\color{headercolor}\bfseries}

\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}

enter image description here

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.