7

I want to change the style for \quote areas in my entire document. These three lines is what I came up with. Font and margins changes take effect but not the bg color. Only the first char's bg color changes, not the the entire quote block.

\definecolor{block-gray}{gray}{0.85}

\newenvironment{myblock}
{\small \addtolength{\leftskip}{10mm} \addtolength{\rightskip}{10mm} \colorbox{block-gray} } 
{\normalsize \addtolength{\leftskip}{0mm} \addtolength{\rightskip}{0mm}}

\renewcommand{\quote}{\myblock}
8

For such jobs, tcolorbox is more suitable. The advantage here is the box is breakable across pages.

\documentclass{article}
\usepackage{showframe,lipsum}                    %% just for demo
\usepackage[most]{tcolorbox}
\definecolor{block-gray}{gray}{0.85}
\newtcolorbox{myquote}{colback=block-gray,grow to right by=-10mm,grow to left by=-10mm,
boxrule=0pt,boxsep=0pt,breakable}
\begin{document}
\noindent
  \begin{myquote}
    \lipsum
  \end{myquote}
\end{document}

enter image description here

In your method, you may better use environ package. However, this is not breakable across pages.

\documentclass{article}
\usepackage{xcolor,showframe}
\definecolor{block-gray}{gray}{0.85}

\usepackage{environ}

\NewEnviron{myblock}
{\colorbox{block-gray}{%
\parbox{\dimexpr\linewidth-2\fboxsep\relax}{%
\small\addtolength{\leftskip}{10mm}
\addtolength{\rightskip}{10mm}
\BODY}}
}

\renewcommand{\quote}{\myblock}
\renewcommand{\endquote}{\endmyblock}

\begin{document}
\noindent
  \begin{quote}
    The quote come here The quote come here The quote come here The quote come here The quote come hereThe quote come here The quote come here The quote come here The quote come here
  \end{quote}
\end{document}

enter image description here

  • Harish, both your solutions are valid for my document. However, there is one problem: how to make the quote block flow into the next page. It appears both solutions are trying hard to keep the blocks on the same page and they are messing up vertical spacing in-between paragraphs surrounding the quote. I'm unsure if this calls for posting another question. – Emacs User Apr 13 '15 at 18:32
  • 1
    @EmacsUser In your approach using \colorbox (second one in the answer), breaking across pages is not possible. That is why I recommended tcolorbox. In my tcolorbox solution, just add breakable to the options like ...boxsep=0pt,breakable} – user11232 Apr 13 '15 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.