2

I am currently trying to fulfill the layout requirements of my university, which request vertical spacing of 24pt before and 12pt after section titles. I am using the titlesec package, but every time I try to set the document, I only get problems. In my document, I am using \section, \subsection, \section* and \subsection*, yet it doesn't work. My preamble`s code looks like this:

\documentclass[a4paper,12pt,draft]{article}

\usepackage{ucs}
\usepackage[utf8x]{inputenc} % Eingabekodierung: UTF-8
\usepackage{fixltx2e} % Schickere Ausgabe
\usepackage[T1]{fontenc} % ordentliche Trennung
\usepackage[french,USenglish,UKenglish,ngerman]{babel}
\usepackage{lmodern} % ordentliche Schriften
\usepackage[babel,style=swiss]{csquotes}
\usepackage{extsizes}

\usepackage{graphicx}
\usepackage[top=2.5cm,bottom=3.5cm,left=2.5cm,right=4cm]{geometry}
\usepackage{fancyhdr}
\usepackage{lettrine}

\usepackage{titlesec}
    \titlespacing*{\section}{}{24pt}{12pt}
    \titlespacing{\section*}{}{24pt}{12pt}
    \titlespacing*{\subsection}{}{24pt}{12pt}
    \titlespacing*{\subsection*}{}{24pt}{12pt}

\usepackage[]{acronym}
\usepackage{hyperref}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\fancyhf{}
\rhead{\rightmark}
\lhead{} 
\rfoot{\thepage}

% \pagenumbering{arabic}
8
  • If you need different spacings for numbered and unnumbered sections, titlesec provides the numberless key. Also, beware the * after \titlespacing is there to kill indentation of the first section paragraph.
    – Bernard
    Jun 11, 2016 at 12:13
  • Also n needless to load fixltx2e unless you have an old distribution.
    – Bernard
    Jun 11, 2016 at 12:18
  • Actually I am also wondering, why it is still there, I wanted to implement some lines from a nice template I found from our Institute for Informatics, but erased them later, yet, still they load fixltx2e. Do you have any idea, how to stop that?
    – Patty-B
    Jun 11, 2016 at 12:20
  • 1
    I don't quite follow you. You erased theses lines from a template on your own computer, and finally they're still there?
    – Bernard
    Jun 11, 2016 at 12:43
  • Yes, and I also deleted the log files and so on, yet this warning still shows up.
    – Patty-B
    Jun 11, 2016 at 12:51

1 Answer 1

3

titlespacing does not allow the starred \section* commands as arguments. Instead, a \section* gets the same spacing that you set for a normal, numbered \section. Simply replace your four \titlespacing commands with the two from the code below.


\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}


\usepackage{titlesec}
\titlespacing{\section}{0pt}{24pt}{12pt}
\titlespacing{\subsection}{0pt}{24pt}{12pt}

\usepackage{blindtext}
\begin{document}
\blindtext
\section*{Testsection}
\blindtext
\section{Testsection}
\blindtext
\blinddocument
\end{document}
1
  • I did it, I guess it cannot show, because my reputation is not high enough, yet. :(
    – Patty-B
    Jun 11, 2016 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .