5

I'm using the memoir class to typeset a cassette cover with some lyrics in it. I'd like to section headings to be very basic, just with a lineskip above and under them. But it seems that there's more vertical space added above each section heading (see image).

Where does this space come from and how can I control it?

% !tex program = pdflatex
\documentclass[oneside,11pt]{memoir}

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

%% section style
\setsecheadstyle{\raggedright\textsc}
\setbeforesecskip{-1ex}
\setaftersecskip{1ex}

\begin{document}
\setbeforesecskip{0pt} % Tried this, but it doesn't affect the space.

\section*{1. THE FIRST}

\begin{alltt}\normalfont
Unreal City,
Under the brown fog of a winter dawn,
[...] (From The Waste Land by T. S. Eliot)
\end{alltt}
\section*{2. THE FIRST AGAIN}
\begin{alltt}\normalfont
Unreal City,
Under the brown fog of a winter dawn,
[...] (From The Waste Land by T. S. Eliot)
\end{alltt}

\end{document}

enter image description here

EDIT:

Adding:

\usepackage{etoolbox}

and

\AtBeginEnvironment{alltt}{\setlength{\topsep}{0pt}}

Does reduce the space so it looks good, but then I realize that the space under the section heading and the following alltt environment is bigger than the space above (which I marked in the picture). It seems to have to do with the alltt environment, because if the first paragraph is a regular one, the space is the same as above the section heading!

1 Answer 1

6

Something like this?

\documentclass[oneside,11pt]{memoir}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{alltt}
\makeatletter
\makeheadstyles{mysecs}{%
  \renewcommand\thesection{\arabic{section}}%
  \setsecnumformat{\csname the##1\endcsname.\quad}%
  \setbeforesecskip{-1\onelineskip \@minus .01\onelineskip}%
  \setaftersecskip{1\onelineskip \@minus .01\onelineskip}%
  \setsecheadstyle{\normalfont\raggedright\MakeUppercase}%
}
\makeatother
\headstyles{mysecs}

\begin{document}

\section{The First}
This is the start of the section
\begin{alltt}\normalfont
Unreal City,
Under the brown fog of a winter dawn,
[...] (From The Waste Land by T. S. Eliot)
\end{alltt}
Final text
\section{The First Again}
This is a section start
\begin{alltt}\normalfont
Unreal City,
Under the brown fog of a winter dawn,
[...] (From The Waste Land by T. S. Eliot)
\end{alltt}

\end{document}

somewhat compact headings

Note that this may increase the number of bad page breaks you get as it reduces LaTeX's ability to find good break points by greatly reducing the amount of stretchiness in the vertical spacing.

Note that the remaining vertical spacing has nothing to do with the sectioning: the alltt environment add vertical space at the beginning and end. This is independent of Memoir.

6
  • Thanks for your nice answer, and it helped me. But I actually do want the space to be there. Just I want it to be the exact same space as under the section heading -- or rather both of them to be a lineskip ... Sep 3, 2015 at 14:47
  • Added more info in my question, see above. Sep 3, 2015 at 15:37
  • 1
    @PetaspeedBeaver Then just use e.g. -1\onelineskip and 1\onelineskip rather than -0.1 and 0.1.
    – cfr
    Sep 3, 2015 at 19:23
  • 1
    @PetaspeedBeaver See edit. I've made the change to demonstrate the idea. Obviously, if you want a different spacing, just change the values accordingly e.g. -.5\onelineskip and .5\onelineskip or whatever.
    – cfr
    Sep 3, 2015 at 21:38
  • 1
    @PetaspeedBeaver Yes. That seems right. Glue is useful stuff... ;). That's why I included the warning: strictly speaking, you asked for none, but sometimes what sounds good in theory turns out less good in practice ;).
    – cfr
    Sep 5, 2015 at 23:15

You must log in to answer this question.

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