如何修改目录以使其与此类似。对齐是临时的,但应该类似。我该怎么做?
答案1
一个选项是使用TikZ
:
\documentclass{article}
\usepackage{tikz}
\definecolor{myblue}{RGB}{0,162,232}
\setcounter{secnumdepth}{0}
\renewcommand\contentsname{\textcolor{myblue}{\itshape\large Whats inside...}}\makeatletter
\makeatletter
\renewcommand\tableofcontents{%
{\centering\contentsname\par\bigskip}
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
\@starttoc{toc}%
}
\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\addvspace{1.0em \@plus\p@}%
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip\hfill
\begin{tikzpicture}
\node[
fill=myblue,
text width=\dimexpr.65\linewidth-8pt\relax,
rounded corners=3pt,
text height=3ex,
text depth=1.8ex
] (secen)
{\parbox{2.6em}{\mbox{}}%
\parbox{\dimexpr\linewidth-8pt-2.6em\relax}{%
\raggedright\normalfont\itshape\textcolor{white}{#1}}%
};
\node[circle,fill=white,inner sep=5pt] at ([xshift=18pt]secen.west) {};
\end{tikzpicture}\hfill\null\par
\endgroup
\fi}
\makeatother
\begin{document}
\tableofcontents
\section{A title for the first section}
\section{A title for the second section}
\section{A title for the third section; it will span several lines}
\end{document}
使用诸如titlesec
and/or之类的包titletoc
,可以减少代码行数。