1

Hello my dear fellow latex users! I've been trying to fancy my thesis by setting a color to the chapter names and in order to do so, I used the package sectsty, because I am using a template where if I use titlesec everything gets terribly messed up.

The question is: How do I get to separate the chapter name and chapter number. As you can see, it is the only thing that gets messed up here.

\documentclass[11pt,a4paper]{scrreprt}

\usepackage{sectsty}
\usepackage{color}
\definecolor{Verde}{RGB}{99,154,0}
\chapterfont{\color{Verde}}
\sectionfont{\color{Verde}}

\begin{document}

\chapter{Mexican Hat}

Mi casa es tu casa

\section{La cucaracha}

Ya no puede caminar

\end{document}

Though I've been using Latex for a while now, I have never gone too deep to make my own renewcommands and stuff. So I'd love to keep using sectsty, because I wouldn't know how to improve all the template with titlesec.enter image description here

  • Welcome to TeX.se and thanks for providing a minimal document with your question! – Alan Munn Sep 11 at 15:19
3

If all you want is changing the colour of chapters and sections titles, you can use \addtokomafont:

\documentclass[11pt, a4paper]{scrreprt}

\usepackage{xcolor}
\definecolor{Verde}{RGB}{99,154,0}
\addtokomafont{chapter}{\color{Verde}}
\addtokomafont{section}{\color{Verde}}

\begin{document}

\chapter{Mexican Hat}

Mi casa es tu casa

\section{La cucaracha}

Ya no puede caminar

\end{document}{chapter} 

enter image description here

  • +1 I've deleted my answer. There are too many KOMA details to keep track of. :) But you don't need two commands if all sectioning commands are to have the same colour. You could use \addtokomafont{disposition}{...} to do all at once. – Alan Munn Sep 11 at 15:42
  • @AlanMunn: Your answer made me discover the disposition key :o) – Bernard Sep 11 at 15:45
  • It's the most opaquely named key I've ever encountered. :) Worthy of some of the keys used in R packages (if you're familiar with R). – Alan Munn Sep 11 at 15:46
  • For me it's perfectly clear (I'm French), albeit I don't know R. – Bernard Sep 11 at 15:48
  • Thanks a lot! It's very simple and worked perfectly :) – Isaac Sep 11 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.