1

I'm trying to generate a toc whith different icon/img aligned to the left of author + chapter block in the TOC.

Here the code snippet MWE, the image1.png is given bottom of the post :

 \documentclass[10pt,twoside]{memoir}
\usepackage{blindtext}
\usepackage{polyglossia}
\setdefaultlanguage{french}

\renewcommand{\thesection}{\arabic{section}}
\setcounter{secnumdepth}{3} % Subsection mit Zähler (1.1) versehen

\renewcommand{\chaptermark}[1]{ \markboth{#1}{}  } 
\renewcommand{\sectionmark}[1]{ \markright{#1}{} } 

\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\settocdepth{chapter}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}

\makeatletter
\DeclareRobustCommand\authortoctext[1]{%
{\addvspace{10pt}\nopagebreak\leftskip0em\relax
\rightskip \@tocrmarg\relax
\noindent\itshape#1\par\addvspace{-7pt}}}
\makeatother
\newcommand\authortoc[1]{%
  \gdef\chapterauthor{#1}%
  \addtocontents{toc}{\authortoctext{#1}}}

\usepackage{graphicx}
\usepackage{todonotes}
\newcommand*{\img}[1]{%
    \raisebox{-.3\baselineskip}{%
        \includegraphics[
        height=30pt,
        width=30pt,
        ]{#1}%
    }%
}

\begin{document}
\tableofcontents* 
\authortoc{G. Blabla, A. Blabla}
\chapter{\protect\img{image-1.png}This an entry for chapter}
\authortoc{F. Blabla, U. Blabla, M.Blabla,F. Blabla, U. Blabla, M.Blabla,F. Blabla, U. Blabla, M.Blabla}
\chapter{\protect\img{image-1.png}This is a very long long long long long long long long long long long long long long long long long long second entry for chapter}
\end{document}

TOC example

I'm not very happy with that, i want something like that :

enter image description here

The image1-png icon :

icon

4
+50

You could add the image to your \authortoctext command:

\documentclass[10pt,twoside]{memoir}
\usepackage{blindtext}
\usepackage{polyglossia}
\setdefaultlanguage{french}

\renewcommand{\thesection}{\arabic{section}}
\setcounter{secnumdepth}{3} % Subsection mit Zähler (1.1) versehen

\renewcommand{\chaptermark}[1]{ \markboth{#1}{}  }
\renewcommand{\sectionmark}[1]{ \markright{#1}{} }

\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\settocdepth{chapter}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}

\makeatletter
\DeclareRobustCommand\authortoctext[2]{%
{\addvspace{10pt}\nopagebreak\leftskip0em\relax
\rightskip \@tocrmarg\relax
\noindent\imageintoc{#2}\itshape#1\par\addvspace{-7pt}}}

\DeclareRobustCommand\imageintoc[1]{%
 {\makebox[0pt][r]{%
  \raisebox{\dimexpr-\height+\ht\strutbox}[0pt][0pt]{%
   \includegraphics[height=30pt]{#1}}\hspace{10pt}}}}

\makeatother
\newcommand\authortoc[2]{%
  \gdef\chapterauthor{#1}%
  \addtocontents{toc}{\authortoctext{#1}{#2}}}

\usepackage{graphicx}
\usepackage{todonotes}
\newcommand*{\img}[1]{%
    \raisebox{-.3\baselineskip}{%
        \includegraphics[
        height=30pt,
        width=30pt,
        ]{#1}%
    }%
}

\begin{document}
\tableofcontents*
\authortoc{G. Blabla, A. Blabla}{example-image-a}
\chapter[Entry for toc]{\protect\img{example-image}This an entry for chapter}
\authortoc{F. Blabla, U. Blabla, M.Blabla,F. Blabla, U. Blabla, M.Blabla,F. Blabla, U. Blabla, M.Blabla}{example-image-b}
\chapter[This is a very long long long long long long long long long long long long long long long long long long second entry for chapter]
      {\protect\img{example-image}This is a very long long long long long long long long long long long long long long long long long long second entry for chapter}
\end{document}

enter image description here

| improve this answer | |
  • Thanks, but also i'm interested by changing this image A between the different entries in the toc using \img{...} :) – reyman64 Oct 9 '17 at 6:52
  • You can add an argument to pass the name of the image. – Ulrike Fischer Oct 9 '17 at 6:57
  • I try to add argument like that without success, i'm not sure how can i pass the image parameter, could you please update your answer, and after that i accept it ? : \noindent\imageintoc#1\itshape#1\par\addvspace{-7pt}}} \DeclareRobustCommand\imageintoc[1]{% {\makebox[0pt][r]{% \raisebox{\dimexpr-\height+\ht\strutbox}[0pt][0pt]{% \includegraphics[height=30pt]{#1}}\hspace{10pt}}}} – reyman64 Oct 9 '17 at 7:19
  • You naturally need to add the argument to all your commands to correctly pass it around. I have edited the question with one suggestion how to do it. – Ulrike Fischer Oct 9 '17 at 7:45

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.