How to Remove Extra Space After \section in LaTeX
LaTeX adds generous vertical space before and after \section, \subsection, and other heading commands. While this looks good in books, it can waste space in conference papers, CVs, or compact documents where every line counts. The titlesec package gives you complete control over heading spacing. Bibby AI's section formatting panel lets you visually adjust heading spacing with sliders, providing instant feedback compared to the trial-and-error approach in Overleaf.
Using titlesec to Control Section Spacing
The titlesec package's \titlespacing command lets you set exact spacing before and after any heading level:
\documentclass{article}
\usepackage{titlesec}
% \titlespacing{command}{left margin}{before spacing}{after spacing}
\titlespacing{\section}{0pt}{12pt plus 2pt minus 2pt}{6pt plus 1pt minus 1pt}
\titlespacing{\subsection}{0pt}{8pt plus 2pt minus 2pt}{4pt plus 1pt minus 1pt}
\titlespacing{\subsubsection}{0pt}{6pt plus 1pt minus 1pt}{3pt plus 1pt minus 1pt}
\begin{document}
\section{Compact Section}
This section has reduced space above and below the heading.
\subsection{Compact Subsection}
Subsections are also tighter.
\end{document}Minimal Spacing for Conference Papers
For extremely tight layouts, reduce spacing to near-zero values. Use the starred form \titlespacing* to suppress the paragraph indent after the heading:
\usepackage{titlesec}
% Very compact spacing for conference papers
\titlespacing*{\section}{0pt}{6pt}{2pt}
\titlespacing*{\subsection}{0pt}{4pt}{1pt}
\titlespacing*{\subsubsection}{0pt}{3pt}{1pt}
% You can also change the heading format at the same time
\titleformat{\section}
{\normalfont\bfseries} % format
{\thesection.} % label
{0.5em} % separation between label and title
{} % before-codeDirect LaTeX Length Adjustments (Without titlesec)
If you can't use titlesec (some journal classes conflict with it), you can redefine the section command directly:
% Without titlesec: modify the internal spacing parameters
\makeatletter
\renewcommand\section{%
\@startsection{section}{1}{\z@}%
{-8pt plus -2pt minus -2pt}% space before (negative = no indent after)
{4pt plus 1pt minus 1pt}% space after
{\normalfont\large\bfseries}% heading style
}
\makeatother
% Quick hack: reduce space after all headings
\usepackage{etoolbox}
\patchcmd{\@startsection}
{\@afterheading}
{\vspace{-4pt}\@afterheading}
{}{}💡 Tips
- •Use 'plus' and 'minus' rubber lengths (e.g., 6pt plus 2pt minus 1pt) so LaTeX can adjust spacing to avoid bad page breaks.
- •A negative 'before' value in \@startsection suppresses the paragraph indent after the heading — titlesec's \titlespacing* does this automatically.
- •Some journal and conference classes override heading spacing — check if your class supports its own spacing options before using titlesec.
- •Bibby AI's section formatting lets you drag spacing values visually, showing the effect on your document layout in real time.
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free