Graphics, Figures & TablesGraphics in table of contents

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
carl
Posts: 2
Joined: Mon Dec 21, 2009 8:25 am

Graphics in table of contents

Post by carl »

Is there any way to include small images in the table of contents?

I'm trying to do something like below where I have a small icon in the section heading and the same image in the table of contents, but I get a "! Missing \endcsname inserted." error when I try.

MWE
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\tableofcontents
\section{ Section \includegraphics[height=1.25ex]{foo.pdf} Heading}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

joe74
Posts: 15
Joined: Tue Mar 24, 2009 6:17 am

Re: Graphics in table of contents

Post by joe74 »

Hi, Carl.

I tried your MWE and get the same error. I tried to replace the parameter [height=1.25ex] with something like [scale=0.5] and get the same error.

I tried with no parameter at all and get an output PDF, but there are two errors yet. Those errors are "! Argument of \@sect has an extra }.", and "! Paragraph ended before \@sect was complete.". Although, the errors seem not to affect the output PDF.
joe74
http://latexlive.wordpress.com/
TeX Live 2009/TeXmaker
Powered by Debian Squeeze
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Graphics in table of contents

Post by localghost »

The brackets for the optional argument may cause the problem. Group it with an additional pair of curly braces and it should work.

Code: Select all

\section{Section {\includegraphics[height=1.25ex]{foo}} Heading}

Best regards and welcome to the board
Thorsten
carl
Posts: 2
Joined: Mon Dec 21, 2009 8:25 am

Re: Graphics in table of contents

Post by carl »

Thanks for the answers.

I tried the extra curly brackets but it doesn't seem to make any difference.

I tried without the parameter at all and get the same error that joe74 got. I do eventually get an output file, but for me there is no contents line for the section with the image.

Has anyone ever seen putting an image in the table of contents work or am I in uncharted territory here?
Post Reply