TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I get strange errors with the last versions of mdframed (v 1.4) and listings (v 1.4). Here is a minimal example:



The error I get is

You can't use \prevdepth in horizontal mode.

which I don't really understand... Any pointer as to what is going on would be greatly appreciated.

share|improve this question
Seems to be a bug. As a temporary workaround you can put the lstlisting within \begin{minipage}{\linewidth} ... \end{minipage}. – Peter Grill Mar 22 '12 at 21:44
Another workaround is to add the line \makeatletter\let\par\@@par\makeatother just below \end{lstlisting} (it seems that this environment doesn't reset \par to its expected value). – egreg Mar 22 '12 at 22:13
@PeterGrill: In this case the contents of listings can't be splitted. – Marco Daniel Mar 23 '12 at 12:44
@MarcoDaniel: Yep, that's why it was intended as a temporary workaround. I should have made a note of that in the original comment. – Peter Grill Mar 23 '12 at 14:58
up vote 4 down vote accepted

As @egreg wrote in the comment it seems that listings changed the internal definition of \par without reseting. However based on great comments of @DavidCarliste and @egreg in the chat I fixed the problem.

Please try the new version on github.

With the new version I get 0 errors and the following result:

enter image description here

share|improve this answer
Thank you, that seems to fix the problem! – Olivier Mar 23 '12 at 14:27
Perhaps my answer above was too lukewarm: HUGE thanks to you for being so responsive! :-) – Olivier Mar 24 '12 at 8:41
@Olivier: No problem ;-) – Marco Daniel Mar 24 '12 at 8:43

If you comment the line no 752 in mdframed, the file is compiling:

Comment the below mentioned:

\par\unskip\nointerlineskip\hrule \@height\z@ \@width\hsize
share|improve this answer
This would break many other things. – egreg Mar 23 '12 at 12:54

Your Answer


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.