I was trying to eliminate the vertical space before and after the title of a section by using the titlesec package and the command \titlespacing*{\section}{0pt}{0pt}{0pt}, but it works only in eliminating the vertical space after the section title. Before the section title there still is a portion of double space. I've searched the database and didn't find a solution.
Asked
Active
Viewed 2.2k times
5
1 Answers
6
Don't switch to \normalsize inside the argument of \section; use titlesecs \titleformat macro instead.
\documentclass[12pt]{extarticle}
\usepackage{setspace}
\onehalfspacing
\usepackage[compact]{titlesec}
\titleformat{\section}{\normalfont\bfseries}{\thesection}{1em}{}
\titlespacing*{\section}{0pt}{*0}{0pt}
\begin{document}
\section*{LOT}
The LOT hypothesis
\section*{The Regress Argument}
RA
\end{document}

lockstep
- 250,273
-
Thank you so much, I just had to add
titleformat{\section}{\normalfont\bfseries}{\thesection}{1em}{}to my preamble and it solved the problem, although I couldn't edit the source code in LyX and the\normalsizesetting is still there. But it works this way. – chimil Jan 08 '12 at 14:20
setspacepackage and\doublespacing? A a minimal working example (MWE) would be helpful. – lockstep Jan 08 '12 at 13:40\usepackage{fontspec} \usepackage{xunicode} \usepackage{xltxtra} \date{} \usepackage[compact]{titlesec} \titlespacing*{\section}{0pt}{*0}{0pt}– chimil Jan 08 '12 at 13:43setspaceappears with\onehalfspacing. But the space before the section title is clearly bigger than the one after. – chimil Jan 08 '12 at 13:47\documentclass[12pt,english]{extarticle} \renewcommand{\familydefault}{\rmdefault} \usepackage[T1]{fontenc} \usepackage{setspace} \onehalfspacing
\makeatletter \usepackage{fontspec} \usepackage{xunicode} \usepackage{xltxtra} \date{} \usepackage[compact]{titlesec} \titlespacing{\section}{0pt}{0}{0pt}
\makeatother
\usepackage{babel} \begin{document}
Name:
\pagebreak{}
\bf 22. Discuss LOT. \rm Intro
\section*{{\normalsize LOT}}
The LOT hypothesis
\section*{{\normalsize The Regress Argument}}
RA
\end{document} `
– chimil Jan 08 '12 at 14:02