I have been using the following proof environment for a while now:

    \vspace{6 pt}
    \begin{mdframed}[skipabove=0pt, skipbelow=0pt, innertopmargin=0pt, innerbottommargin=0pt, bottomline=false,topline=false,rightline=false]%
    \noindent \textit{\textbf{Proof.}}  
    \vspace{6 pt}

which usually gives something like this, i.e. the desired result: enter image description here

but once every 50 pages (it's just a way of saying this does not happen often), something like this happens:

enter image description here

The issue is obviously that little line at the bottom going a little too far down (about one line of text too far) when it is supposed to come at the same height as the text (since I set the bottom margins to zero), but unfortunately it is not. I don't know how to force mdframed to stick with that text. The vertical spaces are there to mimic the space lost by setting margins down to zero.

Any better ideas?

(I really love this line on the side for the following two reasons: makes it immediate to see how long a proof is, and it really separates results from proofs nicely, so that the reader interested in a proof does not look forever in blocks of text. So I would really appreciate if this problem could be fixed! More importantly, it gives me error messages (bad boxes), so I don't want to look if an error is "just that" or if it's something else when my documents have hundreds of pages.)

Added : The code of the example where it fails. Just to give you an idea how random this phenomenon is : if I modify something somewhere else in the document and this particular proof landed a few lines higher, the line would align correctly.

    We already know that localization is right-exact by \refthm{localization-and-tensor}, so it suffices to show that localization preserves injective maps ; in other words, if $M_1 \subseteq M_2$, then the map $S^{-1} M_1 \to S^{-1}M_2$ defined by $S^{-1}M_1 \ni \frac ms \to \frac ms \in S^{-1}M_2$ is injective. There is not much to say : given $\frac ms \in S^{-1}M_1 \setminus \{0\}$, there exists no $s' \in S$ such that $sm = 0$ ; therefore $\frac ms \in S^{-1}M_2 \setminus \{0\}$. Flatness of $S^{-1}A$ as an $A$-module follows by \refthm{localization-and-tensor}. 

Just to remove any black boxes, here is how \refthm is defined :


(where \ref comes from the amsmath package) and here is an example of the exact same content but modifications 4-5 pages earlier so that the same content lands correctly displayed in the middle of a page:

enter image description here

EDIT : When going with egreg's answer, I notice some slightly undesirable phenomenon, but not problematic:

enter image description here

I used to control the spacing before and after the line on the left by adding some vertical spacing before and after my box. Is there some tcolorbox command which would allow me to do it neatly? I tend to dislike manually doing vertical spacing.

  • Please show the code that goes with the proof at the bottom of page 104.
    – Mico
    Dec 30, 2016 at 22:59
  • I think the issue has to do with proof that end at the bottom of a page.
    – egreg
    Dec 30, 2016 at 23:05
  • @egreg: Yes, I seem to notice it almost exclusively then. But then again, some proofs end at the bottom of the page and the phenomenon happens (sometimes). I don't know what causes it, nor am I able to reproduce it via a MWE. So I am clueless at the moment. Dec 30, 2016 at 23:14
  • Could you post a full code? That said, are stuck with doing this with mdframed?
    – Bernard
    Dec 30, 2016 at 23:34

1 Answer 1


My impression is that the issue arises when a proof ends too near to the end of a page, so mdframed tries to break it.

The tcolorbox package seems more robust under this respect.




  before skip=\topsep,
  after skip=\topsep,
  borderline west={0.4pt}{0.4pt}{black},
  right=12pt, % I'd avoid this






enter image description here

  • This package looks amazing! I will look at its documentation. Thanks a lot! I am intrigued as to why your answer is written the way it is written though, more precisely because of the xpatch. Is it not simpler to just add the text "proof" manually? What do you gain with such a trick? I tried it though, not -one- single badbox in 200 pages! Not bad! Dec 31, 2016 at 0:44
  • P.S. I indeed would "avoid this", as it is not desirable for my purposes. Mega +1, great answer! I still have one mini-question related to your answer: see my edit. Dec 31, 2016 at 0:55
  • @PatrickDaSilva I prefer the pre-made proof environment by amsmath for a number of reasons. The \xpatchcmd is for printing “Proof” in bold-italic (but I still prefer simple italic). If you end such a proof with a display, remember \qedhere. Or make up your own proof environment as you did (before the \tcolorboxenvironment command.
    – egreg
    Dec 31, 2016 at 10:00
  • I achieved what I wanted by modifying the values of before skip and after skip to 20pt and 24pt, respectively. Many thanks! Dec 31, 2016 at 14:53

You must log in to answer this question.

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