6

I'm using the snugshade environment to draw a quote box, but it's a little to wide and not flush with the text on both sides.

I have absolutely no idea if i can fix this with this environment or if i have to use something else - which i would not prefer as a solution.

MWE:

\documentclass[12pt,a4paper]{scrbook}

\usepackage[svgnames]{xcolor}
\definecolor{lightgray}{gray}{0.95}
\definecolor{quoteColor}{gray}{0.15}

\usepackage{libertine}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{lipsum}

\newcommand*\openquote{\makebox(0,-45){\scalebox{5}{``}}}
\newcommand*\closequote{\makebox(0, -5){\scalebox{5}{''}}}
\colorlet{shadecolor}{lightgray}

\makeatletter
\newif\if@right
\def\shadequote{\@righttrue\shadequote@i}
\def\shadequote@i{\begin{snugshade}\begin{quote}\openquote}
\def\endshadequote{%
  \if@right\hfill\fi\closequote\end{quote}\end{snugshade}}
\@namedef{shadequote*}{\@rightfalse\shadequote@i}
\@namedef{endshadequote*}{\endshadequote}
\makeatother

\begin{document}

\lipsum[3]

\color{quoteColor}
\begin{shadequote}
\begin{quote}
\lipsum[4]
\end{quote}
\end{shadequote}

\lipsum[5]

\end{document}

Picture:

Picture of MWE

w00t
  • 63

1 Answers1

4

There's a glitch in the definition of snugshade:

\documentclass[12pt,a4paper]{scrbook}

\usepackage[svgnames]{xcolor}
\definecolor{lightgray}{gray}{0.95}
\definecolor{quoteColor}{gray}{0.15}

\usepackage{libertine}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{lipsum}

\newcommand*\openquote{\makebox(0,-45){\scalebox{5}{``}}}
\newcommand*\closequote{\makebox(0, -5){\scalebox{5}{''}}}
\colorlet{shadecolor}{lightgray}

\makeatletter
\renewenvironment{snugshade}{%
  \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep 
  \colorbox{shadecolor}{##1}\hskip-\fboxsep
      % There is no \@totalrightmargin, so:
      \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
  \MakeFramed {\advance\hsize-\width
    \advance\hsize-2\fboxsep %%%%%%%%%%%%% <------ ADDED
    \@totalleftmargin\z@ \linewidth\hsize
    \@setminipage}%
 }{\par\unskip\@minipagefalse\endMakeFramed}

\newif\if@right
\def\shadequote{\@righttrue\shadequote@i}
\def\shadequote@i{\begin{snugshade}\begin{quote}\openquote}
\def\endshadequote{%
  \if@right\hfill\fi\closequote\end{quote}\end{snugshade}}
\@namedef{shadequote*}{\@rightfalse\shadequote@i}
\@namedef{endshadequote*}{\endshadequote}
\makeatother

\begin{document}

\lipsum[3]

\begin{shadequote}
\begin{quote}
\lipsum[4]
\end{quote}
\end{shadequote}

\hbox to \textwidth{\kern-.4pt\smash{\vrule height 5cm}\hfill\smash{\vrule height 5cm}\kern-.4pt}
\nointerlineskip
\lipsum[5]

\end{document}

The \hbox to \textwidth{...} is just to provide the two rules that show the margin.

enter image description here

egreg
  • 1,121,712