1

I am used to use the package titlesec to change the font of my sections. And now I want all my sections to be in blue, I find an easy way to do it with the sectsty package. This is pretty useful because I don't have to change all type individually, but all in one. Unfortunately, there is an incompatibility with titlesec as you can see on the MWE.

\documentclass[12pt]{book}

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage[french]{babel} 
\usepackage{xcolor}

\usepackage{sectsty} 
\usepackage{titlesec}

\titleformat*{\section}{\Large\scshape\bfseries} 
\titleformat*{\subsection}{\large\scshape\bfseries} 

\allsectionsfont{\color{blue}{}}

\begin{document}

\chapter{First Chapter}

\section{First section}

blabla

\section{Second section} \subsection{Subsection}

blabla

\end{document}

The section with \titleformat* are not in blue, and if the \usepackage{titlesec} is before \usepackage{sectsty}, all the sections are in blue, but I lost the change in the font.

It looks normal, the last package called defines the style, but how can I do both at the same time?

0

If you're changing the fonts for each section level, you need to add the \color command to those changes using sectsty. But there is no bold small caps font in Latin Modern, so you need to choose between bold and small caps.

\documentclass[12pt]{book}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage[french]{babel} 
\usepackage{xcolor}
\usepackage{sectsty}
\allsectionsfont{\color{blue}}
\sectionfont{\normalfont\Large\scshape\color{blue}} 
\subsectionfont{\normalfont\large\scshape\color{blue}}
\begin{document}
\tableofcontents
\chapter{First Chapter}
\section{First section}
blabla
\section{Second section} 
\subsection{Subsection}
\section*{Unnumbered section}
\end{document}
  • True, but I have to do that for all the section/chapter... I wanted to do it at once. Also does it work for the table of contents? With the command \allsectionsfont{\color{blue}{}} it does, but can I do it with titlesec? – antoine Jan 16 '18 at 15:15
  • I forgot to tag you, so I don't if you will see my new question! – antoine Jan 16 '18 at 15:22
  • @antoine I've changed to a sectsty solution, which is a bit simpler. But since you're making changes to the fontsize for the different sections you need to add the colour to each. – Alan Munn Jan 16 '18 at 15:26

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.