2

A half line skip appears at the very start of pages which start with section; this doesn't apper for pages which starts with paragraphs. How to remove this?

Example

MWE

\documentclass[british, 12pt]{report}
\usepackage[margin=1in,headheight=15pt,showframe]{geometry}

\usepackage{titlesec}
\titleformat{\section}{\sffamily\bfseries}{}{0pt}{}[]
\titlespacing{\section}{0pt}{0pt}{0pt}
\linespread{2}
\begin{document}
\section{Review of Related Literature}
\end{document}
Myrl Hex
  • 135
  • MWE needed to help you. – Karlo Mar 13 '17 at 13:38
  • 1
    @Rmano Right. I've experimented with removal and addition of packages yet that behavior is consistent. – Myrl Hex Mar 13 '17 at 13:40
  • Should I use openup to temporarily mitigate the problem? – Myrl Hex Mar 13 '17 at 14:04
  • Possible duplicate: http://tex.stackexchange.com/questions/79232/remove-spacing-above-section-in-titlesec – Myrl Hex Mar 13 '17 at 14:26
  • 1
    @MyrlHex ooh it is a duplicate except my answer is better than @egreg's:-) that is, the \strut are the problem and just patching to remove them sort of makes the problem go away but also doesn't address the (presumed) issue of why they were added. The version here is a bit more complicated but adds a "safe(er)" strut. – David Carlisle Mar 13 '17 at 14:29
  • @DavidCarlisle Indeed. Is it possible to do your method using patchcmd? I haven't gotten too deep into LaTeX commands yet. – Myrl Hex Mar 13 '17 at 14:31
  • 1
    @MyrlHex better would be if the package got fixed, I'll ping Javier.... – David Carlisle Mar 13 '17 at 14:33
  • I'm listening :-) I'll investigate. – Javier Bezos Mar 13 '17 at 15:17
  • @JavierBezos oh hi I was just writing an email, I won't bother finishing it now:-) perhaps at least a package option to control the strut behaviour might be good (changing the default behaviour might be hard after all this time) – David Carlisle Mar 13 '17 at 15:34

1 Answers1

5

This seems to be a feature of titlesec you see it already for

\documentclass[british, 12pt]{report}
\usepackage[margin=1in,headheight=15pt,showframe]{geometry}
\showoutput
\usepackage{titlesec}
\linespread{2}
\begin{document}
\section{Review of Related Literature}
\end{document}

That is , you only have to load the package, and the behaviour changes, even if you don't use its declarations.

the issue is that the package adds \strut to the section headings and struts get larger when you stretch the baseline. As this is a zero-width rule rather than a vertical space, it isn't dropped at a page break.

probably the package ought to use a special version of \strut that is not expanded by the baselinestretch, that way it gives consistent spacing if accented or other large letters are used, without giving this bad spacing if baseline is stretched.

there are 6 \strut in the package, this fixes two of them.

\documentclass[british, 12pt]{report}
\usepackage[margin=1in,headheight=15pt,showframe]{geometry}
\showoutput
\usepackage{titlesec}

\makeatletter
\def\ttlh@hang#1#2#3#4#5#6#7#8{%
  \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}%
  \setlength\leftskip{#6}%
  \setlength\rightskip{#7}%
  \interlinepenalty\@M
  \ttl@changecentercr
  \ttl@beginlongest
  #1{\ifhmode\ttl@hmode@error\fi
     \ttl@glcmds
     \parindent\z@
     \begingroup
%%%%
\baselineskip\dimexpr\baselineskip/\baselinestretch\relax
\def\baselinestretch{1}%
\let\f@linespread\baselinestretch
\fontsize{\f@size}{\baselineskip}%
\setbox\strutbox\hbox{%
          \vrule\@height.7\baselineskip
                \@depth.3\baselineskip
                \@width\z@}%
%%%%%%%%%%%%%
       \ifttl@label
          \noindent
          \sbox\z@{#2\strut\ttl@calc\hspace{#3}}%
          \hangindent\wd\z@
          \box\z@
       \fi
       #4{#8}%
       \kern\z@\strut\@@par
     \endgroup
     \nobreak\ttl@midlongest#5\@@par}%
  \ttl@endlongest}

\makeatother
\titleformat{\section}{\sffamily\bfseries}{}{0pt}{}[]
\titlespacing{\section}{0pt}{0pt}{0pt}
\linespread{2}
\begin{document}
\section{Review of Related Literature}
\end{document}
David Carlisle
  • 757,742
  • Is there a workaround for this? Setting openup seems to work, but if I understand correctly, it's a TeX primitive? I'm not sure how well it'd work on a larger document either. – Myrl Hex Mar 13 '17 at 14:09
  • @MyrlHex yes I was working on it:-) check answer in a couple of minutes... – David Carlisle Mar 13 '17 at 14:24