Saturday January 16, 2021
 home | about | contact | Donations

 LaTeX Beautiful, Powerful and Fun Document Tools (but requires a little extra work)

### Adding images to the main TOC

There may be occasions when you want to customize the table of contents - in this minimum working example, it shows how easy it is to add an image to the 'main' table of contents while leaving the short table of contents intact.

\documentclass{book}
\usepackage{graphicx}

\usepackage{shorttoc}
\usepackage{etoolbox}

% bit extra is added - so the sexy image is only added to the
% main toc not the short toc
\newbool{shorttoc}
\makeatletter
\patchcmd{\@startshorttoc}{\bgroup}{\bgroup\booltrue{shorttoc}}{}{}
\makeatother

\newcommand{\tocfig}[2][]{%
\protect\ifbool{shorttoc}{}{
\ifnum\value{chapter}>0 \bigskip\noindent\fi%
\protect\includegraphics[#1]{#2}\par%
}%
}%
}

\begin{document}
\shorttableofcontents{Short Contents}{0}

\tableofcontents
\tocfig[width=\textwidth]{./images/ch1.jpg}
\chapter{Title 1 }
\section{Section for title 1}
\tocfig[width=\textwidth]{./images/ch2.jpg}
\chapter{Title 2 }
\section{Section for title 2}
\end{document}

 Visitor: 9534626 { 229.27.38.75 } Copyright (c) 2002-2020 xbdev.net - All rights reserved. Designated articles, tutorials and software are the property of their respective owners.