1

I tried to color che chapter and the section after their restiling.

I re-used two code and mixes them, but i had no positive results.

How solve this problem??

\documentclass[a4paper,12pt,oneside]{book}

\usepackage{xcolor}

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

% ------------------- imposta un nuovo stile per i titoli del capitolo
%Options: Sonny, Lenny, Glenn, Conny, Rejne, Bjarne, Bjornstrup
%\usepackage[Sonny]{fncychap}
\usepackage{titlesec, blindtext, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
% ------------------- imposta un nuovo stile per i titoli del capitolo

\begin{document}

\chapter{prova}
testo di prova

\section{prova sezione}
testo di sezione

\chapter{prova2}
testo di prova 2


\end{document}

closed as unclear what you're asking by Christian Hupfer, Sebastiano, Circumscribe, gusbrs, Troy Dec 31 '18 at 14:54

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I am not a LaTeX specialist, but simply with \section*{\color{blue}Introduction} I get the "Introduction" in blue color. Before doing so, since Texstudio didn´t like your "\chapterfont{\color{blue}}" neither "\sectionfont{\color{blue}}", I closed them. – user376343 Nov 29 '18 at 14:16
  • if i use your code the title of chapter is blue (i known your simple strategy), but the number of each chapter remains black ... – user175696 Nov 29 '18 at 14:33
  • 1
    It will be reasonable to rewrite/complete your question, so the "numbering" of sections became colored (to avoid misunderstanding). – user376343 Nov 29 '18 at 14:38
  • The OP is no user on TeX.SE any longer, the question is abandoned -- I voted for closing – Christian Hupfer Dec 31 '18 at 12:35