I have successfully used TikZ to modify the table of contents of a TeX document, and cannot quite figure out how to achieve the same effect for the list of figures, list of tables, acknowledgements, etc. My (simplified) style file looks like:

% Style file to get green boxes in TOC.


% define color

% ToC title with color box.
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=12cm,y=0.2cm]{\color{uvmgreen}\Huge\bfseries \contentsname};%
\draw[fill=uvmgreen,draw=uvmgreen] (13.5,-.75) rectangle (10,1);%
\clip (15.5,-.75) rectangle (10,1);
\pgftext[right,x=12cm,y=0.2cm]{\color{white}\Huge\bfseries \contentsname};%

and an example report looks like:


% import style file




\chapter{Quantum Harmonic Oscillator}
\section{test section}

\caption{sample caption} \label{fig: first figure}

\section{test section }
\subsection{test subsection}
\section{test section}
\subsection{test subsection}
\subsection{A test subsection with a long title spanning more than one line in the table of contents}
\section{test section}

\chapter{Is it a Riemann Integral?} 
\section{test section}
\subsection{test subsection}
\section{test section with a long title spanning more than one line in the table of contents}
\subsection{test subsection}


I would really like to be able to add a \listoffigures that would use the same green boxes which show up at the top where it says 'List of Figures'. My (unsuccessful) attempt at this was to add the following to the style file:

\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=12cm,y=0.2cm]{\color{uvmgreen}\Huge\bfseries \figurename};%
\draw[fill=uvmgreen,draw=uvmgreen] (15.5,-.75) rectangle (10,1);%
\clip (15.5,-.75) rectangle (10,1);
\pgftext[right,x=12cm,y=0.2cm]{\color{white}\Huge\bfseries \figurename};%

but when I add this, nothing seems to happen. Any suggestions would be much appreciated. Thanks in advance!

  • 1
    Ah! Indeed. Thanks for this (and for pointing out the e-mail address). If you will put that as an answer, I will gladly accept it. – codeAndStuff Oct 14 '13 at 15:36

The \listoffigures macro does not contain a reference to \figurename but to \listfigurename. And \listtablename for the \listoftables.

There are more references to \contentsname and \list*name in the \tableofcontents or the \listof*s macro respectively. These are used for the markings when headings are enabled. These should not be changed.

You could also change \contentsname or \listof* directly, however I advise against it as they could be used somewhere else (e.g. in a heading) which might break everything.

I’d also suggest to introduce a macro, say \tikzHeader that produces your green box to separate content from the TeXnics. I also removed the remember picture key as I don’t see where or why you want to reference anything in your picture (there isn’t anything to reference anyway).

  \draw[fill=uvmgreen,draw=uvmgreen] (13.5cm,-.75cm) rectangle (10cm,1cm);
  \clip (15.5cm,-.75cm) rectangle (10cm,1cm);

I added a \htStrut macro defined as


and \smash the actual text (which means it has no vertical dimensions for \pgftext). (The g in "Figure" will throw the vertical placement off otherwise.) If you have amsmath loaded, you can just use \smash[b]{#1} and drop the \htStrut.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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