I'm using the following code but when I want to add \includegraphics{example-image-duck} to argument of section or subsection I got error in this case @Skillmon suggest to add \protect which gives \section{\protect\includegraphics{example-image-duck}} but even though I got error besides I get another error from that code as soon as I use \tableofcontents.



\title{Sections and Chapters}

            \csname the#1\endcsname
    \TitleUnderline{\ \ \ }%


\section{Use this Tools \includegraphics[width=1cm]{example-image-duck} to obtain random points in Geogebra}
\section{Plya's Problem-Solving Cycle}
\subsection{Understand the problem}
\subsection{Devise a Plan}
\subsection{Carry Out the Plan}
\subsection{Look Back}
\section{Second Section}

  {Really long section name that is really long, so long it takes two rows}

  • No need to load graphics if you then load graphicx. – Skillmon May 1 '18 at 11:37
  • \protect\includegraphics works fine for me. But you should delete the old toc. – Ulrike Fischer May 1 '18 at 11:39
  • works fine with \protect\includegraphics[width=1cm]{example-image-duck} – user36296 May 1 '18 at 11:40
  • @UlrikeFischer funny. I used article in my tests (because the first question was using article), and there I get the error ! Argument of \@mkboth has an extra }.. As soon as I use report everything works fine. – Skillmon May 1 '18 at 11:43
  • 2
    @Skillmon you could get the correct line by adding a \mbox around the graphics (to hide it from soul). But with article it will fail for the \section inside \tableofcontents. I would never use soul here -- much too fragile. – Ulrike Fischer May 1 '18 at 11:54

Your Answer

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

Browse other questions tagged or ask your own question.