0

I am searching to put a figure/image next to a TOC chapter element.

At the moment I only found a way to put it just under it but not either before the number of the chapter or after the page. \addstufftotoc{\nobreak\protect\includegraphics[height=1\baselineskip]{Image/en.jpg}\par}

TOC element

2
  • Define "next to". To the left of the "6"? before "Machines"? After "MCS"? Aug 27, 2020 at 12:23
  • By next to I mean before the 6 or after the 39 If I can get only after MCS it's fine too
    – Hekmil
    Aug 27, 2020 at 12:35

2 Answers 2

2

Here I use the feature of specifying a separate heading in the toc to add the graphic, via lap, if necessary.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\tableofcontents

\noindent\hrulefill

\section{Normal section}

\section[{\llap{\includegraphics[height=\baselineskip]{example-image}%
  \kern20pt}Left of section number}]{Left of section number}

\section[{Right of title \includegraphics[height=\baselineskip]{example-image}}]%
  {Right of title}

\section[{Right of page  number\hfill\rlap{\kern20pt\includegraphics%
  [height=\baselineskip]{example-image}}}]{Right of page  number}
\end{document}

enter image description here


SUPPLEMENT

In response to comments about the use of \chapter in the book class, and vertical alignment of the image, I provide an additional MWE:

\documentclass[a4paper,openright]{book}
\usepackage{graphicx}
\DeclareRobustCommand\addimg[1]{\llap{\raisebox{-\dp\strutbox}%
  {\includegraphics[height=\baselineskip]{#1} \kern20pt}}}
\begin{document}
\tableofcontents

\noindent\hrulefill

\chapter[\addimg{example-image}Left of section number]{Left of section number}

\chapter[\addimg{example-image}Machines d'audit et processus MCO et MCS]{Machines d'audit et processus MCO et MCS}
\end{document}

enter image description here

5
  • Alright I didn't know we could do such thing ! I'm trying to apply this to my chapter definition but I'm getting an error here : \chapter[{\llap{\includegraphics[height=\baselineskip]{Image/en.jpg} \kern20pt}Machines d'audit et processus MCO et MCS}]{Machines d'audit et processus MCO et MCS} It's saying that \@chapter doens't match its definition, maybe it's not possible using chapter ?
    – Hekmil
    Aug 27, 2020 at 13:01
  • What document class are you using @Hekmil? Aug 27, 2020 at 13:24
  • \documentclass[a4paper,openright]{book}
    – Hekmil
    Aug 27, 2020 at 13:27
  • @Hekmil I can get it to work using \DeclareRobustCommand\addimg[1]{\llap{\includegraphics[height=\baselineskip]{#1} \kern20pt}} as a definition and then \chapter[\addimg{example-image}Machines d'audit et processus MCO et MCS]{Machines d'audit et processus MCO et MCS}. Please let me know if this works for you. Aug 27, 2020 at 13:40
  • @Hekmil To accomplish a vertical shift, try this: \DeclareRobustCommand\addimg[1]{\llap{\raisebox{-\dp\strutbox}{\includegraphics[height=\baselineskip]{#1} \kern20pt}}} Aug 27, 2020 at 13:52
0

I'm coming back here because I didn't notice that the image is showing up on the header where it's used : enter image description here

I would like to remove the image or put it on the side, if it's possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .