2

I am using xelatex and the Memoir class. By default, the empty vertical space before the section heading does not show after a pagebreak. How do I modify it if I want it to show instead, even if it is at the top of a new page? I can see in memoir.cls that there is a length named \beforesecskip and a \setbeforesecskip command, but I don't know enough to be able to figure about how to achieve the desired effect. Any help is appreciated.

\documentclass[11pt]{memoir}
\usepackage{showframe}
%%% Book Layout %%%
\setstocksize{7.5in}{5in}
\settrimmedsize{7.5in}{5in}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{6in}{4in}{*}
\setulmargins{0.5in}{*}{*}
\setlrmargins{0.5in}{*}{*}
\setmarginnotes{0pt}{0pt}{0pt}
\checkandfixthelayout
%%% Other Settings %%%
\raggedbottom
\setsecheadstyle{\large\centering}

\long\def\sometext{Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo 
consequat. Duis aute irure dolor in reprehenderit in voluptate 
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur 
sint occaecat cupidatat non proident, sunt in culpa qui officia 
deserunt mollit anim id est laborum.}

%%% Document Proper %%%
\begin{document}

\section*{Section 1}

\sometext

\section*{Section 2}

\sometext

\section*{Section 3}

\sometext

\section*{Section 4}

\sometext

\section*{Section 5}

\sometext

\section*{Section 6}

\sometext

\end{document}

As you can see. There is no vertical skip before section 1 and 4 since they are at the top of the page.

4
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – hpesoj626
    Mar 22, 2013 at 7:39
  • 1
    Should the amount of vertical whitespace inserted before the sectioning header -- observe, incidentally, that doing this goes against all rules of good typography; are you maybe attempting to reproduce the look of a document created by a word processing program? -- vary depending on how much vertical whitespace was left at the bottom of the preceding page?
    – Mico
    Mar 22, 2013 at 9:51
  • No, it shouldn't. And I would like it to be adjustable, if possible. The look I am trying to reproduce is that of an actual book. I fully understand this is not good typographic practice. Thanks for the comment.
    – zzjing
    Mar 22, 2013 at 11:05
  • \leavevmode doesn't print anything, but is enough to make latex believe it's not at the top of the page, so ... \leavevmode\section* would do the trick (to some approximation) Mar 22, 2013 at 11:31

1 Answer 1

2

Here's one possibility, redefining some internal macros as defined in memoir.cls (I assumed this behavour was meant only for sections):

\documentclass[11pt]{memoir}
\usepackage{showframe}
%%% Book Layout %%%
\setstocksize{7.5in}{5in}
\settrimmedsize{7.5in}{5in}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{6in}{4in}{*}
\setulmargins{0.5in}{*}{*}
\setlrmargins{0.5in}{*}{*}
\setmarginnotes{0pt}{0pt}{0pt}
\checkandfixthelayout
%%% Other Settings %%%
\raggedbottom
\setsecheadstyle{\large\centering}

\long\def\sometext{Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo 
consequat. Duis aute irure dolor in reprehenderit in voluptate 
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur 
sint occaecat cupidatat non proident, sunt in culpa qui officia 
deserunt mollit anim id est laborum.}
\makeatletter
\newcommand{\@sectstartsection}[6]{%
  \@nameuse{#1block}%
  \ifraggedbottomsection\if@nobreak\else
    \vskip\z@\@plus\bottomsectionskip
    \penalty\z@
    \vskip\z@\@plus -\bottomsectionskip
  \fi\fi
  \def\m@msecn@me{#1}%
  \if@noskipsec \leavevmode \fi
  \par
  \@tempskipa #4\relax
  \@afterindenttrue
  \ifdim \@tempskipa <\z@
    \@tempskipa -\@tempskipa \@afterindentfalse
  \fi
  \if@nobreak
    \everypar{}%
  \else
    \addpenalty\@secpenalty\vspace*{\@tempskipa}% NEW: original with \addvspace
    \addvspace{-\parskip}% <--- added 2011/03/02
  \fi
  \@ifstar
    {\@ssect{#3}{#4}{#5}{#6}}%
    {\@trplargoom{\M@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
\renewcommand{\section}{%
  \sechook%
  \@sectstartsection{section}{1}%  level 1
      {\secindent}%            heading indent
      {\beforesecskip}%        skip before the heading
      {\aftersecskip}%         skip after the heading
      {\normalfont\secheadstyle}} % font
\makeatother
%\setlength\beforesecskip{2cm}
%%% Document Proper %%%
\begin{document}

\section*{Section 1}

\sometext

\section*{Section 2}

\sometext

\section*{Section 3}

Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo 
consequat. Duis aute irure dolor in reprehenderit in voluptate 
velit esse.

\section*{Section 4}

\sometext

\section*{Section 5}

\sometext

\section*{Section 6}

\sometext

\end{document}

enter image description here

Right now I have to leave, but I'll add an explanation as soon as I can (the important modification was signaled in my example with %NEW: original...)

2
  • Is a similar solution possible using the book class (see tex.stackexchange.com/questions/201725/…)? Sep 17, 2014 at 20:30
  • Can anyone explain how it works, please? Is it possible to modify to retain space after table or figure floats but not at the top of the page (and also for subsections and so on)?
    – Leonid
    Jul 24, 2016 at 15:53

You must log in to answer this question.

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