答案1
快速破解,目前还无法真正定制......
重新定义\@seccntformat
,\section
这会在节标题中显示节编号并添加一些更改\addcontentsline
。
\documentclass{book}
\usepackage{xpatch}
\usepackage{tikz}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
\ifstrequal{#1}{section}{%
\shapecircle%
}{%
\csname the#1\endcsname\quad%
}%
}
\xpatchcmd{\@sect}{%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
}{%
\ifstrequal{#1}{section}{%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\shapecircle[0.15]}%
\fi
#7}}{%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
}%
}{}{}
\makeatother
\usepackage[colorlinks,citecolor=blue]{hyperref}
\usetikzlibrary{shadings}
\DeclareRobustCommand{\shapecircle}[1][0.2]{%
\begin{tikzpicture}[scale=#1]
\shade[ball color=red] (0,0) circle(1);
\end{tikzpicture}
}
\begin{document}
\tableofcontents
\chapter{Foo}
\section{Foo}
\section{Bar}
\section{Foobar}
\end{document}