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.

I have a document where I use shaded mdframed frames for annotations. One annotation is on the very bottom of the page and somehow the frame extends to the next page even though all its content is on the previous page.

This was really hard to reproduce in a simpler document. I managed to simplify it to the MWE below which is also here, and the output is:

enter image description here

This example is very fragile, i.e. small changes will cause the frame to either end on the first page or push a line to the second one. In my document however it is a lot more robust. Even adding or removing a line from the frame doesn't solve the issue (the content of the page is just adjusted to fit the page and the frame shows the same behaviour). This may be explained by the use of other packages (e.g. microtype), but cannot be the cause of the problem. It does however make the approach of just editing the text to be a line shorter or longer unfeasible.

What might be causing this behaviour and how can I avoid it?

Code:

\documentclass[parskip=half, a4paper]{scrartcl}
\usepackage[margin=2cm, lmargin=3cm, footskip=1cm]{geometry}

\usepackage{amsmath}

\usepackage[compact, explicit]{titlesec}
\titleformat{\section}[hang]{\Large\bfseries}{\hspace{-1cm}section \thesection:}{1ex}{#1}
\titleformat{\subsection}[leftmargin]{\filleft\bfseries}{\hspace{-1cm}\alph{subsection})}{0ex}{}
\titleformat{\subsubsection}[runin]{\bfseries}{\hspace{-1em}\thesubsubsection\quad}{0ex}{\hspace{-1em}#1\mbox{\quad}}

\usepackage{titling}
\pretitle{\begin{center}\Huge\bfseries\sffamily}
\posttitle{\end{center}}
\preauthor{\begin{center}\rm\Large}
\postauthor{\end{center}}
\predate{\begin{center}\rm\large- }
\postdate{ -\end{center}}
\setlength{\droptitle}{-2cm}

\title{title}
\author{author\\author}
\date{date}

\usepackage[xcolor]{mdframed}
\newmdenv[hidealllines=true, backgroundcolor=gray!30, font=\small]{revision}

\begin{document}

\maketitle

\section{first}
\subsection{}
text

\subsection{}
text

\subsection{}
text

\subsection{}
text

text
\[
    x
\]
text

text
\[
    x
\]
text
\[
    x
\]
text

\section{second}
text
\begin{align*}
    x\\x\\x\\x
\end{align*}
text

text

text

text

text
\linebreak
text

\begin{revision}
    text

    text

    text

    text
\end{revision}

\section{third}
\subsection{}
text

\end{document}
share|improve this question
    
Forcing a new line seemed to remove the warning mdframed gave. i.imgur.com/Lv8Gt7E.png Although this is quite a hacky way of dealing with this, I'm sure there's a better solution. –  Argo Apr 12 at 21:12
    
Yes, as I mentioned, in this example the issue can be resolved by reducing the space in or before the frame. `\\` kills the space between the paragraphs and thus reduces the length of the frame. However, I have larger paragraphs in the document in question that are streched for the frame to be the last thing on the page, when I try this, so, the issue remains. –  schtandard Apr 12 at 21:22
    
The page you linked to never actually loads anything for me. It just keeps saying 'loading' and 'please wait'. Please post code here if you want people to look at it. –  cfr Apr 12 at 21:36
    
@cfr: Copied the code and the resultant image. –  Peter Grill Apr 12 at 23:17

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.