# Problem with titlesec package

I'm helping my girlfriend with her thesis - she wants to eliminate the gap between section headings and the following text. I tried loading the titlesec package, but I get an error if I do:

Error: Entered in horizontal mode.


I've traced the error to the section heading definition in the custom class file we're using. It specifically seems to be the call to #1, but that is pretty crucial...!

MWE:

\documentclass[12pt]{mwe}

\setlength{\parskip}{2ex}

\usepackage{titlesec}
\titlespacing{\section}{0pt}{1.0ex plus -1ex minus -.2ex}{-\parskip}

\begin{document}

\section*{Abstract}
I want this text to be up against the section heading

\end{document}


And this is the problematic excerpt from the cls:

\newcommand{\sect@format}[1]{%
\noindent\protect{%
\@tempdima=\hsize
\parbox{0.99\@tempdima}{%
\smallskip\section@font%
\textcolor{\section@colour}{#1}\smallskip
}%
}%
}%
\sectionfont{\sect@format}


The class file is one I was given for own thesis some time ago, and not something that desperately needs to remain unaltered if there is a better way.

• Just noticed that the cls file contains the following caveat: % We have to do it this way because pdflatex sometimes screws up the colour of text if we do it the sensible way. Jul 6 '18 at 10:22
• Welcome to TeX SX! What is the .cls file really used? Jul 6 '18 at 10:24
• Thanks. It's a Cambridge University Engineering Department one, but not the one that can be found online. Not sure where I can put the whole thing - hence the extract. I've managed to recreate mostly with the titleformat command now - can't get the colour to change though, and haven't found the right option to put the section number in the margin as was done by the above. Jul 6 '18 at 10:55
• You could use, if allowed by your uni to make it public, e.g. pastebin
– nox
Jul 6 '18 at 10:58
• It's not a university affiliated one, AFAIK - pastebin.com/ZGM7Puwi Jul 6 '18 at 11:03

\usepackage{titlesec}