scrrprt 目錄中使用的字體

scrrprt 目錄中使用的字體

在 scrrprt 文件中,我自始至終都使用成比例的舊樣式數字,但我想對目錄中的頁面使用等寬襯裡編號。

我可以使用chapterentrypagenumber頂層的字體,但sectionentrypagenumber僅適用於文章(因為它是頂層)。其餘數字使用哪一種字體?

這是一個簡單的測試文件 - 如何更改黑色數字的字體?

\documentclass{scrreprt}
\usepackage{xcolor}
\setkomafont{chapterentrypagenumber}{\color{red}}
\setkomafont{disposition}{\color{teal}}
\begin{document}
{\color{blue}\tableofcontents}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\end{document}

在此輸入影像描述

還有一個簡單的調試開關可以用於這些事情,只需將正在使用的 komafont 的名稱放入文件中嗎?我試過

\renewcommand{\usekomafont}[2]{(#1:#2)}

但顯然發生了一些我沒有註意到的字體變化: 在此輸入影像描述

答案1

使用 KOMA 套件中的 tocstyle 套件和 pagenumberhook:

\documentclass{scrreprt}
\usepackage{xcolor, tocstyle}
\setkomafont{chapterentrypagenumber}{\color{red}}
\setkomafont{disposition}{\color{teal}}
\settocstylefeature{pagenumberhook}{\sffamily{}}
\begin{document}
{\color{blue}\tableofcontents}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\end{document}

我用作\sffamily字體命令,但也許你想要別的東西。


編輯

這是一個下雨天,我渴望一些彩色的東西,所以我玩了這個,只是為了找出 KOMAscript 能維持哪種程度的廢話:

\documentclass[x11names]{scrreprt}
\usepackage{xcolor, blindtext}
\usepackage{tocstyle}
\usetocstyle{KOMAlike}

\addtokomafont{chapterentrypagenumber}{\color{purple}}
\addtokomafont{chapter}{\color{purple}}

\addtokomafont{chapterentry}{\Large\color{purple}}
%\addtokomafont{disposition}{\color{Snow4}}
\settocstylefeature{entryhook}{\color{Wheat4!70!black}\bfseries}
 \settocstylefeature{pagenumberhook}{\rlap{\color{Wheat1}\hspace{-0.3em}\rule[-0.6ex]{0.6em}{2.5ex}\color{Wheat3}\rule[0.1ex]{0.6em}{2.5ex}}\bfseries\sffamily\color{teal}}

\begin{document}
 \tableofcontents
% \chapter{Chapter}
% \section{Section}
% \subsection{Subsection}

\blinddocument

\blinddocument

\end{document}

你會得到一個如此可愛的目錄: 內容有色

相關內容