如何使用 tocloft 來變更 TOC 部分字體的顏色

如何使用 tocloft 來變更 TOC 部分字體的顏色

我已經自訂了我的目錄,tocloft用於從chapterdown 到 的所有內容subsection,但我無法弄清楚如何更改部分字體的顏色,如何更新此命令?我已閱讀tocloft文件但找不到任何內容。謝謝你的幫忙!

微量元素:

\documentclass[a4paper, 12pt, twopage]{scrreprt}
\usepackage[titles]{tocloft}
\usepackage{color}
\definecolor{RoyalRed}{RGB}{157,16, 45}
\newcommand{\partfont}{\renewcommand\cftpartfont{\color{RoyalRed}}}

\newenvironment{MainTOC}{\partfont}

\begin{document}
\begin{MainTOC}
\tableofcontents
\end{MainTOC}

\part{first part}
\chapter{First chapter}
\part{second part}
\chapter{second chapter}
\end{document}

答案1

您可以用於\cftpartfont變更部分標題及其編號的字體以及cftpartpagefont變更頁面的字體。

\documentclass{book}
\usepackage{xcolor}

\usepackage{tocloft}
\renewcommand\cftpartfont{\color{olive}}
\renewcommand\cftpartpagefont{\color{olive}}

\begin{document}
  \tableofcontents
  \part{A part}
  \chapter{a chapter}
  \part{another part}
\end{document}

在此輸入影像描述

相關內容