`classicthesis` 中的硬部分标记

`classicthesis` 中的硬部分标记

我正在尝试改编 Thorsten Donig 的回答对于classicthesisarsclassica。考虑这个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}

结果:

在此处输入图片描述

相关内容