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:
In typesetting, widows and orphans are words or short lines at the
beginning or end of a paragraph, which are left dangling at the top or
bottom of a column, separated from the rest of the paragraph.
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
...
\enlargethispage{\baselineskip}% Enlarge this page by \baselineskip
\begin{equation}
\sum_{j=1}^{n}u_{ij} > 0, \forall i \in {1,...,c} \label{eqn:nonempty}
\end{equation}
oraz
\begin{equation}
\sum_{i=1}^{c}u_{ij} = 1, \forall j \in {1,...,n} \label{eqn:one}
\end{equation}
...
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:
\usepackage[left=3.0cm,right=3cm,top=3.0cm,bottom=3.0cm]{geometry}
You could simply this to
\usepackage[margin=29.5mm]{geometry}% Margins of 29.5mm
to reduce the margins on all sides of your document from 30mm
to 29.5mm
- effectively increasing the text block horizontally by only 1mm
. 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:
Here's one possibility, using the titlesec
package; before each \section
, some commands can be used: \undefds
suppresses previous dates and subtitles; \sectiondate{<text>}
assigns <text>
as the date for the following \section
, and \sectionsubtitle{<text>}
assigns <text>
as the subtitle for the following \section
.
Since titlesec
was used, somre restrictions apply (See About memoir and titlesec incompatibility). The code:
\documentclass[article]{memoir}
\usepackage[margin=3cm]{geometry}% just for the example
\usepackage[T1]{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\usepackage{textcase}
\usepackage{lmodern}
\usepackage{lipsum}
\makeatletter
\newcommand*\nameundef[1]{%
\expandafter\let\csname #1\endcsname\@undefined}
\newcommand\sectiondatefont{\normalfont\sffamily\itshape\bfseries\Large}
\newcommand\sectionsubtitlefont{\normalfont\sffamily\LARGE}
\newcommand\sectiondate[1]{\def\@sectiondate{#1}}
\newcommand\sectionsubtitle[1]{\def\@sectionsubtitle{#1}}
\titleformat{\section}
{\normalfont\bfseries\huge\sffamily}{}{0em}
{\colorbox{gray}{%
\parbox[t]{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}{%
\vspace*{1ex}%
\@ifundefined{@sectiondate}
{}{{\sectiondatefont\@sectiondate}\\*}%
\raggedright%
\textcolor{white}{\huge\MakeTextUppercase{#1}}%
\@ifundefined{@sectionsubtitle}
{}{\\*{\sectionsubtitlefont\@sectionsubtitle}}%
\vspace*{1ex}
}%
}%
}
\newcommand\undefds{%
\nameundef{@sectiondate}\nameundef{@sectionsubtitle}}
\makeatother
\begin{document}
\sectiondate{March 15, 2013}
\sectionsubtitle{Test Subtitle}
\section{Test Section With a Title Spanning Two Lines}
\lipsum[4]
\undefds
\section{Test Section}
\lipsum[4]
\undefds
\sectiondate{April 23, 2009}
\section{Another Test Section}
\lipsum[4]
\undefds
\sectionsubtitle{Another Test Subtitle}
\section{Test Section}
\lipsum[4]
\end{document}
An image of the result:
Best Answer
The problem of spacing between section and subsection can't have an automatic solution, insofar as you can't know in advance whether the section title is followed by some text, or a subsection title. So I think you'll have to do it by hand.
The following code is a solution to what I've understood of your requirements: