色分けされたセクション番号

色分けされたセクション番号

セクション、サブセクション、サブサブセクションに色を付けたい数字私の論文文書で。私はこのスレッドの最後にある解決策を試しました:セクション番号は色分けされています しかし、カラー パッケージとの競合があるというエラーが表示されます。

私はAndre MiédeによるOverleafテンプレートを使用しています: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既にオプションとしてxcolorでロードされているため、で再度ロードしようとするとオプションが競合します。ここで質問があります:dvipsnamesxcolorsvgnames

そのオプションは本当に必要ですかsvgnames?

tealMWEは、の基本セットの一部である色を使用しているxcolorため、行を削除するだけで問題なくビルドできるはずです。

 \usepackage[svgnames]{xcolor}

コードから。基本セット (19) とdvips名前付きセット (68) の色のみを使用することに満足している場合は、これだけで問題ありません。

もし、あんたがしなければならないセット(151)から名前付き色を使用する場合svg、1つのオプションは発行することです

\PassOptionsToPackage{svgnames}{xcolor}

前に\usepackage{classicthesis}を使用すると、 と の両方がオプションとしてxcolorロードされます。ただし、とセットの名前には大きな重複があるという大きな注意点があります。たとえば、 は両方とも「Cyan」と「Fuschia」、および「ForestGreen」と「LimeGreen」を定義しますが、それらに異なる色を割り当てます。パッケージの構築方法により、競合が発生した場合は バージョンが使用されます。マニュアルには、代わりに バージョンを使用する場合の対処方法が説明されています。直接ロードするのではなく に依存しているため、コンテキストでより多くの作業が必要になります。dvipsnamessvgnamessvgdvipssvgxcolordvipsxcolorclassicthesis

関連情報