章節標題和編號之間不再有空格

章節標題和編號之間不再有空格

我是乳膠新手。我嘗試更改章節標題的顏色,我發現的最簡單的方法是在這裡與

\usepackage{xcolor}
\usepackage{sectsty}
\chapterfont{\color{blue}}  % sets colour of chapters
\sectionfont{\color{cyan}}  % sets colour of sections

它工作正常,但之前

\chapter{Materials and Methods}
\section{Study Site}

已創建

2。

2.1 研究地點

現在它是

2。 <- 缺少空格

2.1 研究地點

有人知道如何解決這個問題或知道更好的方法來更改所有章節和部分的顏色嗎?如果需要更多代碼,請告訴我。

先謝謝大家了!

我的簡短範例:(我保留了所有我不知道其用途的包裹)

\documentclass[%
english,ngerman,%
BCOR=6mm,cdgeometry=no,%
DIV=13,cdfont=true
]{tudscrreprt}

\usepackage{booktabs}
\usepackage{siunitx}

% Packages for text: 
\usepackage{sectsty} % to change the headings
\usepackage{xcolor}
\chapterfont{\color{TUDblue}}  % sets colour of chapters
\sectionfont{\color{TUDblue2}}  % sets colour of sections

\ifpdftex{
\usepackage[T1]{fontenc}
\usepackage[ngerman=ngerman-x-latest]{hyphsubst}
}{
\usepackage{fontspec}
}
\usepackage[UKenglish]{babel}

% Colors: 
\definecolor{TUDblue}{RGB}{0,48,94}
\definecolor{TUDblue2}{RGB}{0,106,179}

\begin{document}

\tableofcontents % Here is still space

\chapter{Introduction} % Here not anymore
\section{Experimental design}
\subsection{What am I doing?}

\end{document}

答案1

我猜您正在使用達姆施塔特技術大學 => TUD 提供的文檔類別。據我所知,這些文檔類別是基於 KOMA 腳本的。

我沒有安裝這些類,而是將文檔類更改為 scrreprt。

KOMA-script 可以輕鬆更改標題的顏色,但與 sectsty 搭配得不好。您可以透過texdoc scrguien在命令列中輸入來取得整本手冊。

也就是說,我只是在程式碼中添加了兩行並註解了其他一些行:

\documentclass[%
english,ngerman,%
BCOR=6mm,cdgeometry=no,%
DIV=13,%cdfont=true
]{scrreprt}

\usepackage{booktabs}
\usepackage{siunitx}

% Packages for text: 
%\usepackage{sectsty} % to change the headings
\usepackage{xcolor}
%\chapterfont{\color{TUDblue}}  % sets colour of chapters
%\sectionfont{\color{TUDblue2}}  % sets colour of sections

\ifpdftex{
\usepackage[T1]{fontenc}
\usepackage[ngerman=ngerman-x-latest]{hyphsubst}
}{
\usepackage{fontspec}
}
\usepackage[UKenglish]{babel}

%%%% Color with KOMAscript in sections

\addtokomafont{chapter}{\color{blue}}
\addtokomafont{section}{\color{cyan}}

% Colors: 
%\definecolor{TUDblue}{RGB}{0,48,94}
%\definecolor{TUDblue2}{RGB}{0,106,179}

\begin{document}

\tableofcontents % Here is still space

\chapter{Introduction} % Here not anymore
\section{Experimental design}
\subsection{What am I doing?}

\end{document}

請調整顏色,我必須將 TUD 顏色交換為系統上可用的顏色:

渲染程式碼的圖片

相關內容