我正在使用该包memoir
,我需要使用以下规则重新定义目录中的字体:
- 对于章节:全部大写和大胆的
- 对于部分内容:大胆的
- 对于子部分:大胆的和斜体
- 对于 SubSubSections:大胆的和强调
- 对于 SubSubSubSections:没事做
我已成功配置sections
:
\renewcommand{\cftsectionfont}{\bfseries}
subsections
:
\renewcommand{\cftsubsectionfont}{\bfseries\itshape}
但对于chapters
,我没有成功使用\MakeUppercase
:
\renewcommand{\cftchapterfont}{\MakeUppercase\bfseries}
而对于subsubsections
,我没有成功加下划线
\renewcommand{\cftsubsubsectionfont}{\bfseries\underline}
那么,我该如何添加下划线和大写字母呢?
答案1
\MakeUppercase
并且\underline
不是字体声明。要达到想要的结果,你必须付出更多努力,而就我个人而言,我一点也不喜欢这样。
\documentclass{memoir}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@chapapp}
{\cftchapterfont #1}
{\cftchapterfont\MakeUppercase{#1}}
{}{}
\patchcmd{\l@subsubsection}
{#1}
{\ric@subunderline{#1}}
{}{}
\AtBeginDocument{
\ifnum\value{secnumdepth}>\tw@
\def\ric@subunderline#1{\ric@@subunderline#1\@nil}
\def\ric@@subunderline#1#2#3\@nil{#1{#2}\underline{#3}}
\else
\def\ric@subunderline#1{\underline{#1}}
\fi
}
\makeatother
%%% Fonts
\renewcommand{\cftchapterfont}{\bfseries}
\renewcommand{\cftsectionfont}{\bfseries}
\renewcommand{\cftsubsectionfont}{\bfseries\itshape}
\renewcommand{\cftsubsubsectionfont}{\bfseries}
\settocdepth{subsubsection}
\setsecnumdepth{subsubsection}
\begin{document}
\frontmatter
\tableofcontents*
\mainmatter
\chapter{Some title}
\section{Some title}
\subsection{Some title}
\subsubsection{Some title}
\end{document}
答案2
这是为了实现您想要的,同时保持hyperref
兼容性:
\documentclass{memoir}
%%% to check compatibility
\usepackage{hyperref}
%%% re-styling the TOC with etoc:
\usepackage{etoc}
\makeatletter
\let\old@chapter\l@chapter
\let\old@chapternumberline\chapternumberline
\etocsetstyle{chapter}{}{}
{\old@chapter{\old@chapternumberline{\etocnumber}%
\etoclink{\MakeUppercase\etocthename}}{\etocpage}}{}%
\let\old@section\l@section
\etocsetstyle{section}{}{}
{\old@section{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
\let\old@subsection\l@subsection
\etocsetstyle{subsection}{}{}
{\old@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
\let\old@subsubsection\l@subsubsection
\etocsetstyle{subsubsection}{}{}
{\old@subsubsection{\numberline{\etocnumber}\underline{\etocname}}{\etocpage}}{}%
\makeatother
%%% Fonts
\renewcommand{\cftchapterfont}{\bfseries}
\renewcommand{\cftsectionfont}{\bfseries}
\renewcommand{\cftsubsectionfont}{\bfseries\itshape}
\renewcommand{\cftsubsubsectionfont}{\bfseries}
\settocdepth{subsubsection}
\setsecnumdepth{subsubsection}
\begin{document}
\frontmatter
\tableofcontents*
\mainmatter
\chapter{Some title}
\section{Some title}
\subsection{Some title}
\subsubsection{Some title}
\end{document}