我需要用分隔符来处理文本runin
,例如,subsection
TOC
square bullet
为此,我尝试过:
\documentclass{book}
\usepackage{xcolor}
\usepackage{hyperref}
\begin{document}
\makeatletter
\definecolor{newmuddydkyellow}{cmyk}{0,0,0,1}
\def\smyellowsquare{\leavevmode\raise.3ex\hbox{\color{newmuddydkyellow}\vrule
width 3pt height 3pt depth0pt}}
\def\subsecsepbullet{\nobreak\ignorespaces\hskip4\p@\ignorespaces\nobreak\smyellowsquare\nobreak\ignorespaces\hskip4\p@\ignorespaces\nobreak}%
\renewcommand\l@subsection[2]{\bgroup%
\def\numberline##1{\relax}%
\raggedright\fontsize{10}{12}\selectfont%
{\it\raggedright#1\ignorespaces\hspace{9\p@}\ignorespaces#2}\subsecsepbullet%
\egroup}
\makeatother
\tableofcontents
\clearpage
\chapter{Chapter Head}
\section{First level head1}
\subsection{Second level head1}
\subsection{Second level head2}
\subsection{Second level head3}
\subsection{Second level head4}
\subsection{Second level head5}
\section{First level head2}
\end{document}
其输出结果如下:
请告知如何满足要求。
答案1
使用包titletoc
\documentclass{book}
\usepackage{xcolor}
%******************************* added <<<<<<
\usepackage{titletoc}
\titlecontents*{subsection}[3.8em]% 3.8em default indent for latex book
{\itshape}{}{}
{\hspace{1.5ex}\thecontentspage}
[\quad\smyellowsquare\quad][]
%*******************************
\makeatletter
\definecolor{newmuddydkyellow}{cmyk}{0,0,0,1}
\def\smyellowsquare{\leavevmode\raise.3ex\hbox{\color{newmuddydkyellow}\vrule
width 3pt height 3pt depth0pt}}
\def\subsecsepbullet{\nobreak\ignorespaces\hskip4\p@\ignorespaces\nobreak\smyellowsquare\nobreak\ignorespaces\hskip4\p@\ignorespaces\nobreak}%
\makeatother
\usepackage{hyperref}
\begin{document}
\tableofcontents
\clearpage
\chapter{Chapter Head}
\section{First level head1}
\subsection{Second level head1}
\subsection{Second level head2}
\subsection{Second level head3}
\subsection{Second level head4}
\subsection{Second level head5}
\section{First level head2}
\end{document}
该命令的星号版本将条目分组到单个段落中。
\titlecontents*{⟨section⟩}[⟨left-margin⟩]
{⟨above-code⟩}{⟨numbered-entry-format⟩}{⟨numberless-entry-format⟩}
{⟨filler-page-format⟩}[⟨separator⟩]