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'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?

share|improve this question
    
Put margin=20mm –  Harish Kumar Sep 5 '12 at 13:41
add comment

1 Answer

up vote 2 down vote accepted

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.

enter image description here

share|improve this answer
    
wonderful, especially because I can set all inner- and outer margins. Thanks! –  Wybo Dekker Sep 5 '12 at 20:14
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.