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 get strange errors with the last versions of mdframed (v 1.4) and listings (v 1.4). Here is a minimal example:

\documentclass{minimal}
\usepackage{mdframed}
\usepackage{listings}

\begin{document}
\begin{mdframed}
\begin{lstlisting}
blah
\end{lstlisting}
bloh
\end{mdframed}
\end{document}

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
2  
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
add comment

2 Answers

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
add comment

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
2  
This would break many other things. –  egreg Mar 23 '12 at 12:54
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.