This is my first post here. I have tried the solution proposed in this site to start chapters in the same page as the previous one ended but I always get an error. I am a TeX newbie and I feel that I'm not capable of finding the answer myself.
I am using the report class and a few other commands and packages to make the titles behave according to my thesis specifications but when I used the clearpage solutions proposed in the other topic I get an error:
Chapter 2. ! Package titlesec /b/c9/cError:/b/c0/c Entered in horizontal mode. See the titlesec package documentation for explanation.
How can I solve this and start chapters right after the previous one ended? I'll do my best to provide a MWE:
\documentclass[11pt,a4paper]{report}
\usepackage{titlesec}
\newcommand{\cchapter}[1]{\chapter[#1]{\centering #1}}
\newcommand{\ssection}[1]{\section[#1]{\centering #1}}
\newcommand{\ssubsection}[1]{\subsection[#1]{\centering #1}}
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter:}{1em}{}
\titlespacing*{\chapter}{0pt}{0pt}{40pt}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
\begin{document}
...
\cchapter{first}
bla bla bla
\cchapter{second}
bla bla bla2
\end{document}
Thanks!