在一个大章里面添加子目录通常使用的是minitoc宏包来实现,那么如何实现下面的子目录样式呢?就是把minitoc的内容放在一个盒子里,这样看起来整个章节设计也非常高大上了。
代码实现如下:
- \documentclass{book}
- \usepackage[explicit]{titlesec}
- \usepackage{lmodern}
- \usepackage{titletoc}
- \usepackage[many]{tcolorbox}
- \newcommand\chapnumfont{\fontsize{50}{60}\selectfont}
- \newcommand\chapnamefont{\huge}
- \newcommand\chaptitlefont{\LARGE}
- \makeatletter
- \titleformat{\chapter}
- {\startcontents\bfseries\sffamily}
- {}
- {0pt}
- {}
- [{%
- \filleft{\chapnamefont\@chapapp}\\
- \begin{minipage}[b]{.75\textwidth}
- \begin{tcolorbox}[
- width=\linewidth,
- enhanced,
- top=10pt,
- nobeforeafter,
- outer arc=0pt,
- arc=0pt,
- boxrule=0.6pt,
- colback=white,
- overlay={
- \node[anchor=west,fill=white,inner xsep=6pt]
- at ([xshift=10pt]frame.north west)
- {Sommaire};
- }
- ]
- \printcontents{}{1}{}
- \end{tcolorbox}%
- \end{minipage}%
- \begin{minipage}[b]{.25\textwidth}
- \filleft
- \chapnumfont\thechapter
- \end{minipage}\\[10pt]
- {\chaptitlefont#1}
- }%
- ]
- \titleformat{name=\chapter,numberless}
- {\startcontents\bfseries\sffamily\filleft}
- {}
- {0pt}
- {\chaptitlefont#1}
- \makeatother
- \begin{document}
- \tableofcontents
- \chapter{Test chapter one}
- \section{Test section one one}
- \section{Test section one two}
- \section{Test section one three}
- \chapter{Test chapter two}
- \section{Test section two one}
- \section{Test section two two}
- \section{Test section two three}
- \section{Test section two four}
- \section{Test section two five}
- \end{document}
选自:http://tex.stackexchange.com/questions/194225/boxed-minitoc-with-each-chapter/194233


雷达卡







京公网安备 11010802022788号







