彩色部分編號

彩色部分編號

我想為節、小節和子小節著色數位在我的論文文件中。我在該線程末尾的解決方案之前嘗試過:彩色部分編號 但我得到的錯誤是與顏色包有衝突。

我使用的是 Andre Miéde 的背頁範本:https://www.overleaf.com/latex/templates/classic-thesis-style-v4-dot-2-by-andre-miede/dwgtvykzvdtk

請原諒我的天真,我最近才開始學習LaTeX

這是我的程式碼的範例:

\documentclass{scrreprt}

\input{classicthesis-config}

\usepackage{classicthesis} 

   \usepackage[svgnames]{xcolor}
\colorlet{SecnumColor}{teal}

\newcommand*\colorsecnum[2][SecnumColor]{%
  \expandafter\renewcommand\csname#2format\endcsname{%
  \textcolor{#1}{\csname the#2\endcsname}\autodot\enskip
}}
    
    \begin{document}
    
    \section{A section}
    
    Bla
    
    \subsection{A subsection}
    
    Bla.
    
    \end{document}

以及 classicthesis-config 包含的有關切片的內容:

\RequirePackage{titlesec}
  
    \ifthenelse{\boolean{@parts}}{
    \newcommand{\ct@parttext}{\relax} 
    \newcommand{\ctparttext}[1]{\renewcommand{\ct@parttext}{#1 \relax}} 
\titleformat{\part}[display]
    {\normalfont\centering\large}
 {\thispagestyle{empty}\partname~\MakeTextUppercase{\thepart}}{1em}
    {\color{Violet}\spacedallcaps}[\bigskip\normalfont\normalsize\color{Violet}\begin{quote}\ct@parttext\end{quote}]
}{\relax}
\ifthenelse{\boolean{@linedheaders}}
{\titleformat{\chapter}[display]            
    {\relax}{\raggedleft{\color{myheadingscolour}\chapterNumber\thechapter} \\ }{0pt}
  
    {\vspace*{.9\baselineskip}\raggedright\spacedallcaps}[\normalsize\vspace*{.8\baselineskip}\titlerule]
}{ 
\titleformat{\chapter}[display]
    {\relax}{\mbox{}\oldmarginpar{\vspace*{-3\baselineskip}\color{myheadingscolour}\chapterNumber\thechapter}}{0pt}
    {\raggedright\spacedallcaps}[\normalsize\vspace*{.8\baselineskip}\titlerule] 
}

\titleformat{\section}
    {\relax}{\textsc{\MakeTextLowercase{\thesection}}}{1em}{\spacedlowsmallcaps}

\titleformat{\subsection}
    {\relax}{\textsc{\MakeTextLowercase{\thesubsection}}}{1em}{\normalsize\itshape}

\titleformat{\subsubsection}
    {\relax}{\textsc{\MakeTextLowercase{\thesubsubsection}}}{1em}{\normalsize\itshape}        

\titleformat{\paragraph}[runin]
    {\normalfont\normalsize}{\theparagraph}{0pt}{\spacedlowsmallcaps}
    \renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}\spacedlowsmallcaps{#1}}   
\ifthenelse{\boolean{@nochapters}}
    {\relax}
    {\titlespacing*{\chapter}{0pt}{1\baselineskip}{1.2\baselineskip}}
\titlespacing*{\section}{0pt}{1.25\baselineskip}{1\baselineskip} 
\titlespacing*{\subsection}{0pt}{1.25\baselineskip}{1\baselineskip}
\titlespacing*{\paragraph}{0pt}{1\baselineskip}{1\baselineskip}

答案1

該套件classicthesis已作為選項加載xcolordvipsnames因此當您嘗試使用xcolor再次加載時,該選項會發生衝突svgnames。現在,向您提出的問題是:

你真的需要這個svgnames選項嗎?

您的 MWE 使用的顏色teal是 中設定的基礎顏色的一部分xcolor,這意味著如果您只刪除該行,它應該構建得很好

 \usepackage[svgnames]{xcolor}

從你的程式碼。如果您對僅使用基本集 (19) 和dvips命名集 (68) 中的顏色感到滿意,那麼您可以這樣做。

如果你必須使用集合(151)中的命名顏色svg,那麼一個選項就是發出

\PassOptionsToPackage{svgnames}{xcolor}

\usepackage{classicthesis},這樣xcolor就會載入dvipsnamessvgnames作為選項。然而,這有一個巨大的警告,因為svgdvips集在名稱上有很大的重疊,例如,兩者都定義了“Cyan”和“Fuschia”以及“ForestGreen”和“LimeGreen”,但為它們分配了不同的顏色。包的建構方式svg將在發生衝突時使用。該xcolor手冊討論瞭如果您想使用版本,在這種情況下該怎麼做dvips;它需要在您的上下文中進行更多工作,因為您不是xcolor直接加載而是依賴於classicthesis.

相關內容