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...!




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


I want this text to be up against the section heading


And this is the problematic excerpt from the cls:


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.
    – etiene
    Jul 6 '18 at 10:22
  • Welcome to TeX SX! What is the .cls file really used?
    – Bernard
    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.
    – etiene
    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
    – etiene
    Jul 6 '18 at 11:03

Well, I haven't solved the conflict between the cls file and titlesec, per se - but I have managed to get what I want with the removal of the excerpt quoted above and the addition to the cls file of:

\titleformat{\section}{\normalfont\selectfont\large\color{CambridgeDeepBlue}}{\llap{\hspace* .   {-\mylen}\thesection\hfill}}{0em}{}[]
\titlespacing{\section}{0pt}{1.0ex plus -1ex minus -.2ex}{-\parskip}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.