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}
Graphics, Figures & Tables ⇒ Graphics in table of contents
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: Graphics in table of contents
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.
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
http://latexlive.wordpress.com/
TeX Live 2009/TeXmaker
Powered by Debian Squeeze
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Graphics in table of contents
The brackets for the optional argument may cause the problem. Group it with an additional pair of curly braces and it should work.
Best regards and welcome to the board
Thorsten
Code: Select all
\section{Section {\includegraphics[height=1.25ex]{foo}} Heading}
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Graphics in table of contents
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?
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?