Another option, not requiring additional packages would be to use the TeX primitive \parshape
:
\newcommand\section{%
\renewcommand{\@seccntformat}[1]{%
\csname thesection\endcsname\hspace{0.5em}}%
\@startsection {section}{1}{10mm}%
{3.5ex \@plus 1ex \@minus .2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\bfseries\raggedright\parshape 1 0cm \textwidth}}
An example:
\documentclass{book}
\makeatletter
\renewcommand\section{%
\renewcommand{\@seccntformat}[1]{%
\csname thesection\endcsname\hspace{0.5em}}%
\@startsection {section}{1}{10mm}%
{3.5ex \@plus 1ex \@minus .2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\bfseries\raggedright\parshape 1 0cm \textwidth}}
\makeatother
\begin{document}
\chapter{Test Chapter}
\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}
Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.
\end{document}
In scrbook
/scrreport
, the skip before/at the end of a chapter is given by
\renewcommand*{\chapterheadstartvskip}{%
\vspace*{2.3\baselineskip}%
}%
\renewcommand*{\chapterheadendvskip}{%
\vspace{1.725\baselineskip
\@plus .115\baselineskip \@minus .192\baselineskip}%
}%
Adjust them to your liking. In terms of \section
s, the KOMA-script bundle still uses \@startsection
(see Where can I find help files or documentation for commands like \@startsection
for LaTeX?). Here's the definition for \section
:
\newcommand\section{%
\@startsection{section}{\sectionnumdepth}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}
Adjust the two rubber lengths (arguments #4
and #5
to \@startsection
) to suit your needs.
Here is a minimal example where the mentioned lengths have been adjusted:
\documentclass[11pt,a4paper,BCOR10mm,DIV11,toc=listof,parskip=full,twocolumn]{scrbook}
\usepackage{etoolbox}
\makeatletter
\renewcommand{\chapterheadstartvskip}{\vspace{0pt}}
\renewcommand{\chapterheadendvskip}{\vspace{\baselineskip}}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\section}{-3.5ex \@plus -1ex \@minus -.2ex}{-\baselineskip}{}{}
\patchcmd{\section}{2.3ex \@plus .2ex}{.5\baselineskip}{}{}
\makeatother
\begin{document}
\raggedright
\chapter{chap1}
\section{sec1}
blaahblah
\section{sec2}
Blah
\chapter{chap2}
BlahBlah
\chapter{chap3}
Blah
\end{document}
Of course the above only references changes to \chapter
and \section
. You'd have to adjust lower-level sectional units in an analogous way. For example, here's an option to remove even more spacing around the sectional units, this time including that of \subsection
:
\usepackage{etoolbox}
\makeatletter
\renewcommand{\chapterheadstartvskip}{\vspace{0pt}}
\renewcommand{\chapterheadendvskip}{\vspace{\baselineskip}}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\section}{-3.5ex \@plus -1ex \@minus -.2ex}{-\z@}{}{}
\patchcmd{\section}{2.3ex \@plus .2ex}{1sp}{}{}
\patchcmd{\subsection}{-3.25ex\@plus -1ex \@minus -.2ex}{-\z@}{}{}
\patchcmd{\subsection}{1.5ex \@plus .2ex}{1sp}{}{}
\patchcmd{\@xsect}{\ignorespaces}{\vspace*{-.5\baselineskip}\ignorespaces}{}{}
\makeatother
Best Answer
The problem here is that LaTeX is trying to do a decent job of making the text look presentable by not allowing orphaned words before an
equation
environment. Taken from the Wikipedia entry on widows and orphans:The happens at the bottom of page 4 in your document:
If your document is not at a final stage of production, then I would suggest not worrying about this until later. That is because small changing in your document might end up getting rid of this problem without you having to do it manually. However, if you want to make a change to accommodate for this, you have a couple of options.
Option 1: You modify the text in the chapter before this point (by adding or removing text) so the spacing changes. This is what happens when you " delete a couple of last lines from the chapter". This is not optimal, since you may have to change the entire chapter/section flow. However, it remains an option.
Option 2: You increase the text block size just for this page, with
Note: Be sure to remove this requirement if there is a change in your document that would make this enlargement unnecessary.
Option 3: Your margin specification via
geometry
is:You could simply this to
to reduce the margins on all sides of your document from
30mm
to29.5mm
- effectively increasing the text block horizontally by only1mm
. This causes the document to be typeset with a marginal difference, allowing for a bit more to fit on the page and a better break at the bottom of page 4: