[Tex/LaTex] Reduce gap between section and subsection heading

sectioning

With the code below, I have a very large space between the section 1 heading and subsection 1.1 heading. I've tried to change the \titlespacing options but I still can't reduce this large space.

What adjustments can I make to my code?

\documentclass[twoside,a4paper]{article}

\usepackage{blindtext}

\usepackage{graphicx}

\usepackage[dvipsnames]{xcolor}
\definecolor{verydarkblue}{HTML}{000052}

\XeTeXinputencoding iso-8859-1

\usepackage{geometry}
\geometry{a4paper,total={210mm,297mm},
 left=20mm,right=20mm,top=25mm,bottom=25mm,}

\usepackage{setspace}
\onehalfspacing

\usepackage[compact]{titlesec}
\titlespacing\section{0pt}{0pt}{0pt}
\titlespacing\subsection{0pt}{0pt}{0pt}
\titlespacing\subsubsection{0pt}{0pt}{0pt}

\usepackage{parskip}

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Calibri}

\date{}

\begin{document}

\newpage

\textcolor{verydarkblue}{\section*{\textbf{\textsc{{section 0}}}}}
\blindtext

\textcolor{verydarkblue}{\section{\textbf{\textsc{{section 1}}}}}
\textcolor{verydarkblue}{\subsection{\textit{subsection 1.1}}}
\blindtext

\end{document}

Best Answer

You should use the features of titlesec for setting color and font of titles.

\documentclass[twoside,a4paper]{article}

\usepackage{fontspec}
\usepackage[dvipsnames]{xcolor}
\usepackage[compact]{titlesec}
\usepackage{graphicx}

\usepackage{blindtext}

\setmainfont{TeX Gyre Heros}% I don't own Calibri

\definecolor{verydarkblue}{HTML}{000052}

\titleformat{\section}
  {\color{verydarkblue}\Large\bfseries}
  {\thesection}
  {1em}
  {\scshape}
\titleformat{\subsection}
  {\color{verydarkblue}\normalfont\large\bfseries}
  {\thesubsection}
  {1em}
  {\scshape}
\titleformat{\subsubsection}
  {\color{verydarkblue}\normalfont\normalsize\bfseries}
  {\thesubsubsection}
  {1em}
  {\itshape}

\begin{document}

\section*{section 0}
\blindtext

\section{section 1}
\subsection{subsection 1.1}
\blindtext

\end{document}

enter image description here

Don't load xunicode and xltxtra; avoid using \XeTeXinputencoding for new documents: save them as UTF-8.

Related Question