# fixed distance and no page break between lines

I'm trying to make a quotation environment which puts the quote on a gray background, with a colored rule right on top of it:

\documentclass{memoir}
\usepackage{color}
\pagestyle{empty}

\newenvironment{Quote}%
{\parindent0pt\parskip1\baselineskip%
\par%
\textcolor{red}{\rule{\hsize}{6pt}}\\[-\X]%
\nopagebreak%
}%

\begin{document}
\begin{Quote}A small quote\end{Quote}
\begin{Quote}A small quote\end{Quote}
%\begin{Quote}A small quote\end{Quote}
\end{document}


This works fine, but when I uncomment the third Quote, a page break occurs between the rule and the quotation, even though there is a \nopagebreak. Also, this introduces extra white between the rule and the shaded box of the other two Quote's. How can I prevent this?

-
Put margin=20mm – Harish Kumar Sep 5 '12 at 13:41

I propose you to employ mdframed for this:

\documentclass{memoir}
\usepackage{color}
\pagestyle{empty}
\usepackage{mdframed}

\newenvironment{Quote}
{\par\parindent0pt\parskip1\baselineskip
\begin{mdframed}[linecolor=red,
linewidth=6pt,