KOMA TOC:改变转向线颜色

KOMA TOC:改变转向线颜色

是否可以只更改目录线(条目和页码之间的虚线)的颜色?我不确定在 KOMA 中是否可以做到这一点,并且还没有找到如何使用目录线来实现这一点(或者在使用 KOMA 时是否应该这样做)

\documentclass[12pt, ngerman, bibtotoc, headings=standardclasses]

{scrartcl}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearpairofpagestyles
\addtokomafont{disposition}{\normalfont}

\DeclareTOCStyleEntry[beforeskip=.8mm]{default}{section}
\DeclareTOCStyleEntry[beforeskip=.8mm]{default}{subsection}

\DeclareTOCStyleEntries[
entryformat={\small\fontspec{SourceSansPro-SemiBold}}, 
pagenumberformat={\scriptsize\fontspec{Source Sans Pro}}
]{tocline}{section}

    \DeclareTOCStyleEntries[
    entryformat={\small\fontspec{Source Sans Pro}}, 
    pagenumberformat={\scriptsize\fontspec{Source Sans Pro}}
     % linefill=\TOCLineLeaderFill
    ]{tocline}{subsection}
    
    % change the dotsep in TOC
    \makeatletter
    \renewcommand*{\@dotsep}{2.}% default is 4.5
    \makeatother

        \DeclareTOCStyleEntries[
        entryformat={\small\fontspec{Source Sans Pro}}, 
        pagenumberformat={\scriptsize\fontspec{Source Sans Pro}}
        ]{tocline}{subsubsection}


\DeclareTOCStyleEntries[
entryformat={\fontspec{Source Sans Pro}}, 
pagenumberformat={\scriptsize\fontspec{Source Sans Pro}}
]{tocline}{figure, table}

(Lualatex)
\usepackage{fontspec}
\setmainfont{Charter}

\defaultfontfeatures{Ligatures=TeX}
\defaultfontfeatures{Ligatures=TeX}

\newfontfamily\secfont[SizeFeatures={Size=20}]{Charter}
\newfontfamily{\Tables}{Source Sans Pro}
\addtokomafont{pagenumber}{\scriptsize\fontspec{Source Sans Pro}}


\setkomafont{section}{\large\fontspec{Source Sans Pro Bold}}
\setkomafont{subsection}{\fontspec{Source Sans Pro Bold}}
\setkomafont{subsubsection}{\fontspec{Source Sans Pro SemiBold}}

答案1

我删除了示例中与问题无关的几段代码,修复了几个错误,比如(LuaLaTeX)前言中的 错误。然后我将代码扩展为一个实际工作示例。最后,我添加了xcolor包选项来为圆点着色。有关 选项和 命令 的leaderfill={\TOCLineLeaderFill[\textcolor{Magenta}{.}]更多信息,请参阅 KOMA-Script 手册中的第 15.3 节。结果示例如下:leaderfill\TOCLineLeaderFill

\documentclass[12pt,ngerman,
  bibliography=totoc,% option bibtotoc is deprecated and should not be used
                     % any longer!
  headings=standardclasses]{scrartcl}
\usepackage{babel}% Option ngerman above does not make much sense, without
                  % this package.
\usepackage[svgnames]{xcolor}
\addtokomafont{disposition}{\normalfont}

\DeclareTOCStyleEntry[beforeskip=.8mm]{default}{section}
\DeclareTOCStyleEntry[beforeskip=.8mm]{default}{subsection}

\newcommand*{\smallformat}[1]{\small #1}
\newcommand*{\textscriptsize}[1]{{\scriptsize #1}}
\DeclareTOCStyleEntries[
  entryformat=\smallformat,% The manual says: The value should be a command with exactly one argument.
  pagenumberformat=\textscriptsize,% The manual says: The command should expect exactly one argument, the page number.
]{tocline}{section,subsection,subsubsection,figure,table}

\DeclareTOCStyleEntry[
 linefill={\TOCLineLeaderFill[\textcolor{Magenta}{.}]}%
]{tocline}{subsection}
    
% change the dotsep in TOC
\makeatletter
\renewcommand*{\@dotsep}{2.}% default is 4.5
\makeatother

\usepackage{blindtext}
\begin{document}
\tableofcontents
\Blinddocument
\end{document}

正如您在此处看到的:

表格内容快照,其中洋红色圆点为子部分条目

工作。

相关内容