Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass[12pt,a4paper]{mwrep}
\usepackage{polski}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage[draft]{graphicx}
\usepackage{amsmath}
\usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5}
% Make all figure use 'ht' position by default:
\makeatletter
\def\fps@figure{ht}
\makeatother

\begin{document}
\section{Lorem ipsum}
\emph{Lorem ipsum} dolor sit amet, consectetur adipiscing elit. Vestibulum in scelerisque velit. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero.
\begin{equation}
Z=
\begin{bmatrix} z_{11} & z_{12} & \cdots & z_{1n} \\
        z_{21} & z_{22} & \cdots & z_{2n} \\
        \vdots & \vdots & \ddots & \vdots \\
        z_{n1} & z_{n2} & \cdots & z_{nn}
\end{bmatrix}
\end{equation}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in scelerisque velit. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero.
\begin{gather}
E = mc^2 \\
a^2+b^2=c^2
\end{gather}

\emph{Lorem ipsum} dolor sit amet, consectetur adipiscing elit. Vestibulum in scelerisque velit. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero. Praesent ac mi libero.
\begin{figure}
\centering
\setlength\fboxsep{124pt}
\setlength\fboxrule{1pt}
\fbox{\includegraphics[scale=0]{dummy.jpg}}
\caption{Dummy caption}
\end{figure}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. \textbf{In sed tortor sit amet magna eleifend egestas.}
\begin{equation}
P=
\begin{bmatrix} 0.1 & 0.3 & 0.0 & 0.6 \\
                0.2 & 0.4 & 0.1 & 0.3 \\
        0.0 & 0.8 & 0.0 & 0.2 \\
        0.2 & 0.0 & 0.2 & 0.6
\end{bmatrix}
\end{equation}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in scelerisque velit. Praesent ac mi libero.

\section{Sed eu neque ligula.}
\emph{Sed eu neque ligula.} Mauris gravida risus et eros aliquet viverra. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam vel nisi eu mauris fermentum dictum. Ut erat dui, aliquam nec cursus vel, scelerisque a ipsum. Curabitur ut est est. Aenean quis felis a orci sodales varius nec non est. Sed in augue eget orci elementum interdum vel et velit. Vestibulum sed condimentum lacus. 
\end{document} 

This is sample layout of my document. Sorry It's so long but I was not able to reproduce the problem on smaller sample.

The problem is huge space between section header and text. Why bolded sentence (In sed tortor sit amet magna eleifend egestas.) is not on single page? It would look better and vertical space between header and text would be smaller.

How can I fix this and this vertical space?

Using usepackage[headsep=0pt]{geometry} as in How to remove vertical space between header and body of text? didn't help.

I need figures to be at ht. If there is no way to aviod vertical space, I'd rather want it at the bottom of the page instead of the way it is now.

share|improve this question
1  
That sentence is on the second page because LaTeX sets \predisplaypenalty=10000 in order that a math display doesn't go on the top of a new page, but is accompanied by at least one line of text. But the figure has nothing to do with this: the result is the same if you remove it. Use the \raggedbottom declaration before \begin{document}. –  egreg Mar 6 '12 at 9:58
    
Nice! That works. Why don't you post an answer so I can vote up and accept? –  Ichibann Mar 6 '12 at 10:10
add comment

1 Answer 1

up vote 5 down vote accepted

That sentence falls in the second page because LaTeX sets

\predisplaypenalty=10000

in order that a math display doesn't go on the top of a new page, but is accompanied by at least one line of text.

The figure has nothing to do with this: the result is the same if you remove it, because of the big matrix which can't be squeezed in the previous page. Use the

\raggedbottom

declaration before \begin{document}. The final result will be poor, but in a double spaced document the huge space between lines will gather the reader's attention and cover your tracks. :)

share|improve this answer
    
Of course \predisplaypenalty=0 solved my problem. –  Ichibann Mar 6 '12 at 10:19
1  
@Ichibann I'd say a big NO. Unless you're pursuing poor typography. :) –  egreg Mar 6 '12 at 10:21
    
Why not? I'd rather want an equation at the beginning of the page rather than below two last words of a longer sentence. Why is it bad? –  Ichibann Mar 6 '12 at 10:25
    
Ok, I'll do \predisplaypenalty=9999 ;) –  Ichibann Mar 7 '12 at 10:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.