![`classicthesis` 中的硬部分标记](https://linux22.com/image/375526/%60classicthesis%60%20%E4%B8%AD%E7%9A%84%E7%A1%AC%E9%83%A8%E5%88%86%E6%A0%87%E8%AE%B0.png)
我正在尝试改编 Thorsten Donig 的回答对于classicthesis
和arsclassica
。考虑这个MWE。
\documentclass[12pt,b5paper,twoside]{book}
\usepackage{classicthesis}
\usepackage{arsclassica}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[inner=2.2cm,outer=1.8cm,bottom=2.7cm,top=2.5cm]{geometry}
\usepackage{lipsum}
\newcommand{\secmark}{}
\newcommand{\marktotoc}[1]{\renewcommand{\secmark}{#1}}
\newenvironment{advanced}{
\renewcommand{\secmark}{$\star$}%
\addtocontents{toc}{\protect\marktotoc{$\star$}}
}
{\addtocontents{toc}{\protect\marktotoc{}}}
\titleformat{\section}{\raggedright}{\makebox[1.5em][l]{\llap{\secmark}\thesection}}{0.5em}{\spacedlowsmallcaps}
\makeatletter\renewcommand{\@tocrmarg}{2.55em plus1fil}\makeatother
\begin{document}
\frontmatter
\tableofcontents
\cleardoublepage
\mainmatter
\chapter{First Chapter}
\lipsum[2]
\section{Easy Section}
\lipsum[2]
\begin{advanced}
\section{Hard Section}
\lipsum[2]
\end{advanced}
\end{document}
到目前为止,我可以让它适用于章节标题,但我不知道如何让标记出现在目录中。我们该怎么做?
答案1
classicthesis
使用包tocloft
。因此您\marktotoc
必须重新定义\cftsecpresnum
:
\documentclass[12pt,b5paper,twoside]{book}
\usepackage{classicthesis}
\usepackage{arsclassica}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[inner=2.2cm,outer=1.8cm,bottom=2.7cm,top=2.5cm]{geometry}
\usepackage{lipsum}
\newcommand{\secmark}{}
\newcommand{\marktotoc}[1]{\renewcommand{\cftsecpresnum}{\llap{#1}}}% <- changed
\newenvironment{advanced}{
\renewcommand{\secmark}{$\star$}%
\addtocontents{toc}{\protect\marktotoc{$\star$}}
}
{\addtocontents{toc}{\protect\marktotoc{}}}
\titleformat{\section}{\raggedright}{\makebox[1.5em][l]{\llap{\secmark}\thesection}}{0.5em}{\spacedlowsmallcaps}
\makeatletter\renewcommand{\@tocrmarg}{2.55em plus1fil}\makeatother
\begin{document}
\frontmatter
\tableofcontents
\cleardoublepage
\mainmatter
\chapter{First Chapter}
\lipsum[2]
\section{Easy Section}
\lipsum[2]
\begin{advanced}
\section{Hard Section}
\lipsum[2]
\end{advanced}
\section{Another Easy Section}
\lipsum[2]
\end{document}
结果: