# 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}
\usepackage[papersize={100mm,100mm},noheadfoot,margin=25mm]{geometry}
\pagestyle{empty}

\definecolor{shadecolor}{gray}{0.7}
\newdimen\X\X=22pt\advance\X3\baselineskip
\newenvironment{Quote}%
{\parindent0pt\parskip1\baselineskip%
\par%
\textcolor{red}{\rule{\hsize}{6pt}}\\[-\X]%
\nopagebreak%
\begin{quote}\noindent\leftmargin0pt\rightmargin0pt\begin{qshade}%
}%
{\end{qshade}\end{quote}}

\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

## 1 Answer

I propose you to employ mdframed for this:

\documentclass{memoir}
\usepackage{color}
\usepackage[papersize={100mm,100mm},noheadfoot,margin=25mm]{geometry}
\pagestyle{empty}
\usepackage{mdframed}

\definecolor{shadecolor}{gray}{0.7}

\newenvironment{Quote}
{\par\parindent0pt\parskip1\baselineskip
\begin{mdframed}[linecolor=red,
linewidth=6pt,
backgroundcolor=shadecolor,
bottomline=false,leftline=false,rightline=false]
}
{\end{mdframed}}

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


This won't have any break between the red rule on top and the quotation.

-
wonderful, especially because I can set all inner- and outer margins. Thanks! –  Wybo Dekker Sep 5 '12 at 20:14