Changing section colors: Undefined control sequence. \sectionfont

colorsectstytitlesec

I know there are several questions with answers out there, but none of them worked for me.

Trying to change the color of all sections of my document with the xcolor package creates an error statement: Undefined control sequence. \sectionfont

MWE:

\documentclass[12pt,a4paper, twoside]{article}  
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{titlesec}

\usepackage{xcolor}
    \sectionfont{\color{red}}

\DeclareUnicodeCharacter{202F}{\,}
\usepackage[colorlinks,hidelinks,urlcolor=blue,bookmarks=false,hypertexnames=true]{hyperref} 

\author{Louis Vigneras}
\title{Potential and Future inequalities in the 5G Era}
\begin{document}
    \maketitle
    
    
\end{document}

Anyone knows what’s going on?

Best Answer

The \sectionfont command is provided by the sectsty package, not the titlesec package. To get \sectionfont to work, you should therefore replace the preamble instruction

\usepackage{titlesec}

with

\usepackage{sectsty}