1

I have been trying to make custom theorem environments because the classical newtheorem command does not suit my needs. I have been stuck with a pagebreak problem which I explain below. Here is the code :

\documentclass[12 pt]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{fullpage}
\usepackage[framemethod=tikz]{mdframed}

\renewenvironment{proof}
    {\par
    \textit{\underline{Proof.}} \par
    \nopagebreak
    \vspace{12 pt}% 
            \begin{mdframed}[bottomline=false,topline=false,rightline=false]%
}
{%
    \end{mdframed}\par
    \vspace{-15 pt}%
    \begin{flushright} $\square$ \end{flushright}%
}

\begin{document}
Text

\vspace{550 pt}

Text
    \begin{proof}
        This text goes on the next page without the title "\textit{\underline{Proof.}}", and I would want my environment title to stick with its body. 
    \end{proof}
\end{document}

Any idea how to tackle this problem? I spent hours on it googling and I ran out of ideas.

EDIT : I managed to get rid of that stupid in-between environment by simply using the mdframed package the way it should be used. Still got the page break with this exact code though.

1
  • I started noticing that the distance between "Proof." and the beginning of my text is variable. (At some place it got horribly big, like 3 lines thick.) I don't know why this happens, but I suspect it has to do with mdframed. Commented Aug 20, 2013 at 5:49

1 Answer 1

3

You are missing some % and want at least a \nopagebreak

\renewenvironment{proof}
{\par
    \textit{\underline{Proof.}}\par
    \nopagebreak
    \vspace{12 pt}%
    \begin{proofline}%
}
{%
    \end{proofline}%
    \vspace{-15 pt}%
    \begin{flushright} $\square$ \end{flushright}%
}

You might need more, depending on the definition of proofline which you didn't show.


If you prevent page breaking at the natural place you need to allow stretchy white space on the previous page to "fill the gap", however in this case it isn't enough as the break happens within mdframed so the easiest thing is to use needspace to check how much space is on the page and force a page break if you are too close to the bottom.

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{fullpage}
\usepackage{needspace}
\usepackage[framemethod=tikz]{mdframed}

\renewenvironment{proof}
    {\par
    \pagebreak[1]%
    \vspace{0pt plus \fill}%
    \needspace{5\baselineskip}%
    \textit{\underline{Proof.}} \par
    \nopagebreak
    \vspace{12 pt}% 
    \nopagebreak
            \begin{mdframed}[bottomline=false,topline=false,rightline=false]%
    \nopagebreak
}
{%
    \end{mdframed}\par
    \vspace{-15 pt}%
    \begin{flushright} $\square$ \end{flushright}%
}

\begin{document}
Text

\vspace{550 pt}

Text
    \begin{proof}
        This text goes on the next page without the title "\textit{\underline{Proof.}}", and I would want my environment title to stick with its body. 
    \end{proof}
\end{document}
7
  • The proofline environment is actually empty, but I surround it with \surroundwithmdframed. Are the % supposed to be any helpful? What do they change? Commented Aug 19, 2013 at 22:13
  • If proofline is empty you should have a \par before the vspace -15pt (vspace in horizontal mode is .. strange) as for % see tex.stackexchange.com/questions/7453/… Commented Aug 19, 2013 at 22:17
  • How strange is it? The only reason why it's there is because I want my flush-righted square to be closer to my text (because of the surroundwithmdframed that I put around the environment proofline, it goes too far away). Would you do it another way? Commented Aug 19, 2013 at 22:55
  • I used your settings but I could reproduce the bug still. Any ideas? Commented Aug 19, 2013 at 23:36
  • I added a MWE in an edit of my question, perhaps you could try one more time? I would really appreciate it :D Commented Aug 20, 2013 at 1:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .