TransWikia.com

No space anymore between section heading and numbering

TeX - LaTeX Asked by Qiyuan on April 29, 2021

I’m new to LaTeX. I tried to change the color of my chapter and section headings and the easiest way I found was this here with

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

It works fine, but before

chapter{Materials and Methods}
section{Study Site}

created

2 Materials and Methods

2.1 Study Site.

Now it is

2Materials and Methods <- Missing space

2.1 Study Site.

Does someone know how to correct this problem or knows a better way to change the colors of all chapters and sections? If there is more code required let me know.

Thank you all ahead!

My short example:
(I have kept all packages whose purpose is unknown to me)

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}

One Answer

I'm guessing that you are using a documentclass provided by the Technical University of Darmstadt => TUD. As far as I remember, those documentclasses are based on KOMA-script.

Instead of installing those classes, I changed the documentclass to scrreprt.

KOMA-script easily allows to change the color of headings, but doesn't work well with sectsty. You get the whole manual by typing texdoc scrguien on the command line.

That said, I just added two lines to your code and commented out some other lines:

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}

Please adapt the colors, I had to swap TUD-colors to the available colors on my system:

pic of rendered code

Answered by Keks Dose on April 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP