Q:

spacing before and after titles

I am making a custom sty file in which I intend to change the spacing before and after sections, subsections and subsubsections.
I use the command \titlespacing{<command>}{<left>}{<before-sep>}{<after-sep>}
 but it doesn't have any effect. May someone help me, please?
My MWE for the sty file is the following
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{body}
\RequirePackage[spanish]{babel}
\RequirePackage{xcolor}
\RequirePackage{titlesec}
\RequirePackage{sectsty}
\RequirePackage{chngcntr}
\RequirePackage{etoolbox}

\definecolor{coolblack}{rgb}{0.0, 0.18, 0.39}
    \definecolor{darkcerulean}{rgb}{0.03, 0.27, 0.49}
\definecolor{blue(ncs)}{rgb}{0.0, 0.53, 0.74}
\sectionfont{\color{darkcerulean}} 
\subsectionfont{\color{blue(ncs)}} 
\subsubsectionfont{\color{blue(ncs)}} 

\titlespacing{\section}{0pt}{2cm}{15cm}
\titlespacing{\subsection}{0pt}{2cm}{5cm}
\titlespacing{\subsubsection}{0pt}{2cm}{5cm}

\renewcommand{\labelitemi}{$\bullet$}
\setlength\parindent{0pt}

And for the test document is as following:
\documentclass[12pt,twoside,titlepage]{article}

\usepackage{body}
\usepackage{lipsum}

\begin{document} 

\section{Título nivel 1}

\lipsum[2]

\subsection{Titulo nivel 2}

\lipsum[2]

\subsubsection{Titulo nivel 3}

\lipsum[2]

\end{document}

Thanks in advance

A:

The titlesec and sectsty packages don't work well together, you could consider just using titlesec with its \titleformat* command instead of using \sectionfont etc. from sectsty:
\titleformat*{\section}{\Large\bfseries\color{darkcerulean}}
\titleformat*{\subsection}{\large\bfseries\color{blue(ncs)}}
\titleformat*{\subsubsection}{\bfseries\color{blue(ncs)}}

does exactly what you want. Alternatively you could try to use both (not recommended) and just change the order of calling them. Call sectsty first and it works.
\titleformat*{\section}{\Large\bfseries\color{darkcerulean}}
\titleformat*{\subsection}{\large\bfseries\color{blue(ncs)}}
\titleformat*{\subsubsection}{\bfseries\color{blue(ncs)}}
\titlespacing{\section}{0pt}{1cm}{.5cm}
\titlespacing{\subsection}{0pt}{1cm}{.4cm}
\titlespacing{\subsubsection}{0pt}{1cm}{.3cm}

produces:

