使用 memoir 将 img/icon 与目录条目左侧对齐

使用 memoir 将 img/icon 与目录条目左侧对齐

我正在尝试生成一个目录,其中不同的图标/图像与目录中的作者 + 章节块左侧对齐。

这里是代码片段 MWE,image1.png 位于帖子底部:

 \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 示例

我对此不太满意,我想要这样的东西:

在此处输入图片描述

图标image1-png

图标

答案1

您可以将图像添加到\authortoctext命令中:

\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}

在此处输入图片描述

相关内容