# Eliminate space after section heading

I have set the spacing after subsubsection to 1sp, but there is still an appreciable space between the heading and the text (approx 1ex). Obviously, I can't set a negative value, and I don't want to manually create a negative space at the start of every subsubsection.

Any suggestions on how to do this? Is there a length variable that I should be setting?

\documentclass[10pt,letterpaper]{article}
\usepackage[letterpaper,margin=0.75in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mdwlist}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{tgpagella}
\pagestyle{empty}

\begin{document}
\setlength{\parskip}{0em}
\setlength{\parindent}{0em}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{1.25ex \@plus1ex \@minus.2ex}%
{-0em}%
{\normalfont\normalsize\bfseries}}
\renewcommand\subsubsection{\@startsection {subsubsection}{3}{\z@ }%
{-1.5ex\@plus -1ex \@minus -.2ex}%
{1sp \@minus 1ex}%
{\normalfont \normalsize \bfseries }}
\makeatother
\subsubsection*{Blah}
This text is 1ex from the heading blah, but I would like it to be hard up
against the heading (but not on the same line)
\end{document}


I need to be able to have some headings which have some space, and some which have none, so I can't use a package which simply affects the whole document.

-
If you want to control manually which ones have headings and which don't, just define different commands; say \subsubsectionA and subsubsectionB. If you want the spacing to be chosen automatically, you need to give us more details. –  Hector Jul 28 '12 at 15:15
@Hector I don't know what you mean. The problem is, and I think this is clear, how to eliminate the 1ex space that remains after setting the vertical spacing to 1sp in the subsubsection command. –  Marcin Jul 28 '12 at 15:16
I don't understand why you don't want to use something like \usepackage[compact]{titlesec} \titlespacing{\subsubsection}{0pt}{*0}{*0} –  Hector Jul 28 '12 at 15:28
@Hector Because I don't want all titles to be compact. –  Marcin Jul 28 '12 at 15:31
I am not sure if something like this is what you want: \renewcommand\subsubsection{\offinterlineskip\@startsection {subsubsection}{3}{\z@ } {-1.5ex\@plus -1ex \@minus -.2ex} {1sp \@minus 1ex} {\normalfont \normalsize \bfseries }} –  Gonzalo Medina Jul 28 '12 at 15:58

I am not sure if this is what you want (or why do you want it), but you can use \nointerlineskip and then annihilate the effect of \lineskip:

\documentclass[10pt,letterpaper]{article}
\usepackage[letterpaper,margin=0.75in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mdwlist}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{tgpagella}
\pagestyle{empty}

\begin{document}
\setlength{\parskip}{0em}
\setlength{\parindent}{0em}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{1.25ex \@plus1ex \@minus.2ex}%
{-0em}%
{\normalfont\normalsize\bfseries}}
\renewcommand\subsubsection{\@startsection {subsubsection}{3}{\z@ }%
{-1.5ex\@plus -1ex \@minus -.2ex}%
{1sp \@minus 0ex\nointerlineskip\vspace{-\lineskip}}%
{\normalfont \normalsize \bfseries }}
\makeatother

\subsubsection*{Blah}
This text is 1ex from the heading blah, but I would like it to be hard up
against the heading (but not on the same line)

\end{document}


An some text of the resulting document zoomed at 400% to see the resulting heading and following text:

On a side note, setting \parskip and \parindent to 0pt might not be a good idea (the l2tabu document contains some details).

-
Awesome, thank you! –  Marcin Jul 28 '12 at 19:31

Including \usepackage{titlesec} (without any package parameters) enables the following command:

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


The final {-\parskip} eliminates the 1ex gap.

Note that this will have no effect if the \subsubsection is renewed in the document - one has to pick one or the other.

-
Found out this works with at least the uppercase option, so will probably work with everything else! –  Nathanael Farley Dec 18 '12 at 8:49