# Widow penalty not working

It seems my Widowpenalty is not working, as nothing changes, even with a value of 10000.

Is there some contradictory commands anywhere which may cause this problem? This is what I have

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath,graphicx,fullpage,microtype,hyperref,subfig,hypcap,amsfonts}

\DisableLigatures{encoding=*,family=*}
\numberwithin{equation}{section}
\setlength{\parindent}{0px}
\widowpenalty=300
\clubpenalty=300
\hyphenpenalty=300
\interfootnotelinepenalty=300
\setlength{\skip\footins}{5mm}
\expandafter\def\expandafter\normalsize\expandafter{%
\normalsize
\setlength\abovedisplayskip{0pt plus 3pt minus 9pt}
\setlength\abovedisplayshortskip{0pt plus 3pt minus 9pt}
\setlength\belowdisplayskip{12pt plus 3pt minus 9pt}
\setlength\belowdisplayshortskip{12pt plus 3pt minus 9pt}
}
\begin{document}

If there is a region which has a larger density of points, this region has a larger volume. This is how curvature occurs in the causal-set. This instance would be similar to the surface of sphere, where the inner shells have a higher volume relative to the outer shells, corresponding to a positive curvature. But what is the coversion rate between the number of elements and volume? Several arguments exist which mostly point to the same answer. For example, when examining the entropy of a black hole horizon, it seems there is one bit of entropy per plaquette of size $8\pi G\hbar$. This leads to a discreteness scale $l=\sqrt{8\pi G\hbar}$ around the Planck length \cite{Sorkin2003}.\\ % speculates about size of element
\\
This means that there are two forces which determine the relative position of causal-set elements. First of all, there is a force which tells each element to 'take up' around a Plack volume of spacetime. You can visualize this as a set of elements which grow like soap-bubbles until they are all around the same size. Each bubble touches its surrounding bubbles such that the whole set makes a surface in the hyperspace.\\
\\
The second force which acts between the elements contrains those bubbles which are linked to each other. The step from one element to the next should also be about a Planck length long. Whenever two elements are causally linked, they are contrained to be around this distance away from eachother within the hyperspace.\\
\\
Given these two forces, we can try to think of aln algorithm which is able to gives coordinates to each of the causal-set elements within the hyperspace. The idea is quite similar to Henson's algorithm discussed in section~\ref{sec:Obtaining the Metric} above. He proposed using the time-like distance to the top of a causal-diamond and the distance to the bottom to determine and element's relative position \cite{Henson2006}. % Very similar method for finding coordinates for causal-set elements
By looking at the repulsive forces of the growing soap-bubble, while contraining them by Planck-sized links, a similar effect occurs.\\
\\
Let us now imagine an algorithm which starts off by placing the causal-set elements in a random position. For each element, it determines the position to every one of the other points and calculates the repulsive force $f_r(i, j)$ acting on it from every other element. It also looks at all the elements which are linked to it and calculates the attractive force $f_a(i, j)$ running only through those links.

\begin{subequations}
\label{eq:Forces}
\begin{align}
f_r(i, j) & = -\frac{K^2}{\parallel x_i - x_j\parallel} & i \neq j \hspace{8mm} i, j \in G \\
f_a(i, j) & = \frac{\parallel x_i - x_j\parallel^2}{K} & i \leftrightarrow j
\end{align}
\end{subequations}

These forces can then be used to displace the element slightly, where the process can start over again until a steady-state is reached. In principle, the two forces acting between all elements gives the causal-set a particular energy. The energy is minimised when the elements are in the 'right' position. This is what the algorithm does.\\
\\
Although we are looking at a Lorentzian manifold, the algorithm just described already exists for Euclidean and Riemanian manifolds. In fact, there is a large body of work done on so called 'graph-drawing algorithms', and in particular on 'spring embedders' where links are replaced by springs to form a mechanical system \cite{Kobourov2007}. % Review of spring-embedders and pseudo-code for Riemanian geometries
The spring forces on the elements move the system to a minimal energy state.\\
\\
In Riemanian manifolds, the algorithm is slightly more complicated in that distances are defined in terms of geodesics. In this case, the metric of the hyperspace into which you are embedding the elements is needed. More precisely, the algorithm computes the forces acting on an element $n$ at position $x$ in its tangent space $T_xM$ where $\tau_x$ is the map from the manifold $M$ to this tangent space \cite{Kobourov2002}. % Introduces spring-embedded graphs in Riemanian geometries
The pseudo-code for this algorithm is the following:

$$\label{eq:Riemanian algorithm} \begin{array}{l} \text{generate initial layout}(G)\\ \text{while not done do}\\ \hspace{5mm} \text{foreach } n \in G \text{ do}\\ \hspace{10mm} x := \text{position}[n]\\ \hspace{10mm} G' := \tau_x(G)\\ \hspace{10mm} x' := \text{force directed placement}(n, G')\\ \hspace{10mm} \text{position}[n] :=\tau_x^{-1}(x')\\ \hspace{5mm} \text{end}\\ \text{end} \end{array}$$

In theory, the Riemanian metric can be extended to a pseudo-Riemanian one, such as for Minkowski space. In practice, determining the map $\tau_x$ to the tangent space is the hardest step.\\
\\
These algorithms have also been translated to $Mathematica$ code \cite{Hu2005}. % Mathematica codes for spring embedders and also suggestion for multi-level drawing based on coarse-graining.
There are two different algorithms, one which has both repulsive and attractive forces running through every link, such that each link has an optimal Planckian size. The other has its repulsive force between every element such that they all take up about a Planck volume. For our causal-sets, a combination of these two algorithms may be most appropriate.\\
\\
\end{document}


Please always post a compete document that shows the problem not just a fragment. Setting widow penalty to 3000 makes it less desirable to break with a widow line, but even if you set it to 10000 to make it infinitely bad to break there, TeX may still do so if it has no better alternative. If you have a full page of text with no stretchable space on the page, and have \flushbottom in effect then there is no choice for page breaking TeX will break after the line that fills the page. If the penalty for breaking there is too high you will get a warning in the log.

If you want to avoid widows it isn't enough to increase the penalty of breaking there you normally need to decrease the penalty of breaking somewhere else typically by adding some glue somewhere.

\setlength\abovedisplayskip{0pt plus 3pt minus 9pt}


allows the space to be negative, is that really what you intend?

Don't use \\ in your document, the way to mark a paragraph break is a blank line. Conversely don't put blank lines before an equation. Despite the conversation in comments there are no figures or other floats on your document.

Basically, the markup in your document didn't give LaTeX any chance to find any reasonable breaks.

In particular if you go

.....aaa\\
\\
bbb....


then that is not two paragraphs it is one paragraph with two forced line breaks so a page break before the aaa does not make a widow and so a widow penalty is not inserted.

if you go

.....aaa

bbb....


then bb is the start of a new paragraph so a page break before aaa or after bbb would be discouraged by your penalties, also stretchable glue is inserted at the paragraph break which helps page breaking.

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath,graphicx,fullpage,microtype,hyperref,subfig,hypcap,amsfonts}

\DisableLigatures{encoding=*,family=*}
\numberwithin{equation}{section}
\usepackage{parskip}
\widowpenalty=300
\clubpenalty=300
\hyphenpenalty=300
\interfootnotelinepenalty=300
\setlength{\skip\footins}{5mm}

\begin{document}

If there is a region which has a larger density of points, this region has a larger volume. This is how curvature occurs in the causal-set. This instance would be similar to the surface of sphere, where the inner shells have a higher volume relative to the outer shells, corresponding to a positive curvature. But what is the coversion rate between the number of elements and volume? Several arguments exist which mostly point to the same answer. For example, when examining the entropy of a black hole horizon, it seems there is one bit of entropy per plaquette of size $8\pi G\hbar$. This leads to a discreteness scale $l=\sqrt{8\pi G\hbar}$ around the Planck length \cite{Sorkin2003}. % speculates about size of element

This means that there are two forces which determine the relative position of causal-set elements. First of all, there is a force which tells each element to 'take up' around a Plack volume of spacetime. You can visualize this as a set of elements which grow like soap-bubbles until they are all around the same size. Each bubble touches its surrounding bubbles such that the whole set makes a surface in the hyperspace.

The second force which acts between the elements contrains those bubbles which are linked to each other. The step from one element to the next should also be about a Planck length long. Whenever two elements are causally linked, they are contrained to be around this distance away from eachother within the hyperspace.

Given these two forces, we can try to think of aln algorithm which is able to gives coordinates to each of the causal-set elements within the hyperspace. The idea is quite similar to Henson's algorithm discussed in section~\ref{sec:Obtaining the Metric} above. He proposed using the time-like distance to the top of a causal-diamond and the distance to the bottom to determine and element's relative position \cite{Henson2006}. % Very similar method for finding coordinates for causal-set elements
By looking at the repulsive forces of the growing soap-bubble, while contraining them by Planck-sized links, a similar effect occurs.

Let us now imagine an algorithm which starts off by placing the causal-set elements in a random position. For each element, it determines the position to every one of the other points and calculates the repulsive force $f_r(i, j)$ acting on it from every other element. It also looks at all the elements which are linked to it and calculates the attractive force $f_a(i, j)$ running only through those links.
\begin{subequations}
\label{eq:Forces}
\begin{align}
f_r(i, j) & = -\frac{K^2}{\parallel x_i - x_j\parallel} & i \neq j \hspace{8mm} i, j \in G \\
f_a(i, j) & = \frac{\parallel x_i - x_j\parallel^2}{K} & i \leftrightarrow j
\end{align}
\end{subequations}

These forces can then be used to displace the element slightly, where the process can start over again until a steady-state is reached. In principle, the two forces acting between all elements gives the causal-set a particular energy. The energy is minimised when the elements are in the 'right' position. This is what the algorithm does.

Although we are looking at a Lorentzian manifold, the algorithm just described already exists for Euclidean and Riemanian manifolds. In fact, there is a large body of work done on so called 'graph-drawing algorithms', and in particular on 'spring embedders' where links are replaced by springs to form a mechanical system \cite{Kobourov2007}. % Review of spring-embedders and pseudo-code for Riemanian geometries
The spring forces on the elements move the system to a minimal energy state.

In Riemanian manifolds, the algorithm is slightly more complicated in that distances are defined in terms of geodesics. In this case, the metric of the hyperspace into which you are embedding the elements is needed. More precisely, the algorithm computes the forces acting on an element $n$ at position $x$ in its tangent space $T_xM$ where $\tau_x$ is the map from the manifold $M$ to this tangent space \cite{Kobourov2002}. % Introduces spring-embedded graphs in Riemanian geometries
The pseudo-code for this algorithm is the following:
$$\label{eq:Riemanian algorithm} \begin{array}{l} \text{generate initial layout}(G)\\ \text{while not done do}\\ \hspace{5mm} \text{foreach } n \in G \text{ do}\\ \hspace{10mm} x := \text{position}[n]\\ \hspace{10mm} G' := \tau_x(G)\\ \hspace{10mm} x' := \text{force directed placement}(n, G')\\ \hspace{10mm} \text{position}[n] :=\tau_x^{-1}(x')\\ \hspace{5mm} \text{end}\\ \text{end} \end{array}$$

In theory, the Riemanian metric can be extended to a pseudo-Riemanian one, such as for Minkowski space. In practice, determining the map $\tau_x$ to the tangent space is the hardest step.

These algorithms have also been translated to $Mathematica$ code \cite{Hu2005}. % Mathematica codes for spring embedders and also suggestion for multi-level drawing based on coarse-graining.
There are two different algorithms, one which has both repulsive and attractive forces running through every link, such that each link has an optimal Planckian size. The other has its repulsive force between every element such that they all take up about a Planck volume. For our causal-sets, a combination of these two algorithms may be most appropriate.

\end{document}

• Hey! Thank you for your answer. The page which is followed by a widow has a figure in it, so I assumed there was enough 'glue' to make it compact a bit. However, no value of 'widowpenalty' affects this problem. Is '\setlength\abovedisplayskip{}' not the right way add glue to figures? The space is indeed allowed to be negative, as the value '0pt' already includes quite a lot of space between equation and text, and a negative value makes this existing space slightly smaller. – LBogaardt Sep 9 '13 at 16:23
• Either way, my question was whether there is anything in the top lines of my document which conflicts with the widowpenalty settings. That is why I only posted the first lines. The answer according to you is 'no', I suppose. So there must be another reason, maybe the way I defined the 'glue' for figures..? – LBogaardt Sep 9 '13 at 16:27
• @LauBo Impossible to say given that incomplete fragment. As I say if you want it to break somewhere else there needs to be a break point there \abovedisplayskip is not used by figures at all, it is the TeX primitive space above display math  – David Carlisle Sep 9 '13 at 17:00
• So is there a way to add stretchable glue to a figure? Allowing LaTeX to adjust the space between text and figure if it helps solve a widow problem? – LBogaardt Sep 10 '13 at 13:23
• @LauBo \textfloatsep is the strechy glue added between figures and text, but it will not affect the widow lines it just affects the position of the floats after the decision to add them has been made. If you need more help you need to make a complete small example document that shows the problem. – David Carlisle Sep 10 '13 at 15:30