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.

Are you aware of tentatives to customize the table of contents with TikZ? I am thinking of fancy graphical objects (coloured ovals, squares, rectangles...) coming with "chapter" or the numbering, for instance. That could obviously involve the titletoc package.

Edit 1: below is a try. Maybe the pfgpicture environment is more relevant for the TOC.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage{titletoc}
\contentsmargin{0cm}
\titlecontents{chapter}[0pc]
{\addvspace{30pt}%
\begin{tikzpicture}%
\draw[help lines,step=.4cm,color=red] (0,0) grid (3.2,1.2);%
\pgftext[left,x=.1cm,y=.6cm]{\Large\sc chapter};%
\fill[fill=white,draw=red] (2.7,.6) circle (0.35cm);%
\pgftext[x=2.7cm,y=.6cm]{\thecontentslabel};%
\end{tikzpicture}\\\color{red}\large\sc\bfseries}%
{}
{}
{\;\titlerule\;\large\bfseries \thecontentspage}%
\titlecontents{section}[2.4pc]
{\addvspace{1pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents*{subsection}[4pc]
{\addvspace{-1pt}\small}
{}
{}
{\ --- \small\thecontentspage}
[ \textbullet\ ][]
\begin{document}
\tableofcontents
\chapter{(title chapter 1)}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\chapter{(title chapter 2)}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\end{document} 

toc tikz 1

EDIT 2: second try but I do not know how to access the title of a chapter with titletoc?

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{kpfonts}
\usepackage[tmargin=2cm,rmargin=3.8cm,lmargin=3.8cm,bmargin=2cm]{geometry}
\usepackage{tikz}
\definecolor{doc}{RGB}{0,60,110}
\usepackage{titletoc}
\contentsmargin{0cm}
\titlecontents{chapter}[0pc]
{\addvspace{30pt}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[fill=doc!30,draw=doc!30] (-4,-.1) rectangle (-1,.5);%
\pgftext[left,x=-3.7cm,y=0.2cm]{\color{white}\Large\sc\bfseries chapter\ \thecontentslabel};%
\end{tikzpicture}\color{doc!40}\large\sc\bfseries}%
{}
{}
{\;\titlerule\;\large\sc\bfseries Page \thecontentspage
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=doc!25,draw=doc!20] (2pt,0) rectangle (6,0.1pt);
\end{tikzpicture}}%
\titlecontents{section}[2.4pc]
{\addvspace{1pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents*{subsection}[4pc]
{\addvspace{-1pt}\small}
{}
{}
{\ --- \small\thecontentspage}
[ \textbullet\ ][]

\makeatletter
\renewcommand{\tableofcontents}{%
\chapter*{%
\vspace*{-20\p@}%
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=15cm,y=0.2cm]{\color{doc!30}\Huge\sc\bfseries \contentsname};%
\draw[fill=doc!30,draw=doc!30] (13,-.75) rectangle (20,1);%
\clip (13,-.75) rectangle (20,1);
\pgftext[right,x=15cm,y=0.2cm]{\color{white}\Huge\sc\bfseries \contentsname};%
\end{tikzpicture}}%
\@starttoc{toc}}
\makeatother
\begin{document}
\tableofcontents
\chapter{Questions of Design}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\chapter{Questions of Drawing}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\chapter{Questions of Technique}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\end{document} 

enter image description here

share|improve this question
    
May be Fancy chapter headings with TikZ provides you some idea. –  Ignasi Jun 3 '11 at 18:46
    
Perhaps Fancy tables with TikZ and More on TikZ tables could help? –  Hendy Jun 3 '11 at 20:08
    
Without \usepackage{kpfonts} (or another complete font family), your examples give warnings: LaTeX Font Warning: Some font shapes were not available, defaults substituted. –  Paul Gaborit Nov 11 '13 at 0:00
    
@PaulGaborit Right, I edited my message to minimize it to the very necessary information but I removed to much. A complete family is back. Thanks –  pluton Nov 11 '13 at 0:12
add comment

1 Answer 1

up vote 6 down vote accepted

Define a macro with an argument (the title) and then apply what I've explained in How to access toc entries with titletoc

share|improve this answer
    
If you have an example, I'd be happy because I just read the user guide but I am not able to adapt. In fine, i'd like to embed the title of a chapter/section of the toc within the \pfgtext command (something like \pfgtext{"title of the chapter"}. Thanks –  pluton Jun 6 '11 at 13:37
    
if you can provide a minimal example where chapter titles can be handled by tikz, that'd be nice. Thanks –  pluton Jun 20 '11 at 13:43
add comment

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.