[Tex/LaTex] Block quote with big quotation marks in margin

quotingtikz-pgf

I really like Herberts solution to the question Block quote with big quotation markd which looks like this:

enter image description here

\documentclass{article}
\thispagestyle{empty}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\makeatletter

\tikzset{%
  fancy quotes/.style={
    text width=\fq@width pt,
    align=justify,
    inner sep=1em,
    anchor=north west,
    minimum width=\linewidth,
  },
  fancy quotes width/.initial={.8\linewidth},
  fancy quotes marks/.style={
    scale=8,
    text=white,
    inner sep=0pt,
  },
  fancy quotes opening/.style={
    fancy quotes marks,
  },
  fancy quotes closing/.style={
    fancy quotes marks,
  },
  fancy quotes background/.style={
    show background rectangle,
    inner frame xsep=0pt,
    background rectangle/.style={
      fill=gray!25,
      rounded corners,
    },
  }
}

\newenvironment{fancyquotes}[1][]{%
\noindent
\tikzpicture[fancy quotes background]
\node[fancy quotes opening,anchor=north west] (fq@ul) at (0,0) {``};
\tikz@scan@one@point\pgfutil@firstofone(fq@ul.east)
\pgfmathsetmacro{\fq@width}{\linewidth - 2*\pgf@x}
\node[fancy quotes,#1] (fq@txt) at (fq@ul.north west) \bgroup}
{\egroup;
\node[overlay,fancy quotes closing,anchor=east] at (fq@txt.south east) {''};
\endtikzpicture}

\makeatother

\begin{document}
\lipsum[1]

\begin{fancyquotes}
\lipsum[1]
\end{fancyquotes}

\lipsum[1]
\end{document}

Is it possible to move the quotation marks into the margin such that the quoted text has nearly the same width as \textwidth?

Best Answer

Here is an implementation of Herbert's idea using the tcolorbox:

screenshot

The important part of the code below is:

\newtcolorbox{fancyquotes}{%
        enhanced jigsaw, 
        breakable,      % allow page breaks
        frame hidden,   % hide the default frame
        left=0cm,       % left margin
        right=0cm,      % right margin
        overlay={%
            \node [scale=8,
                text=black,
                inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
            \node [scale=8,
                text=black,
                inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
                },
            % paragraph skips obeyed within tcolorbox
                    parbox=false,
    }

which defines a newenvironment that allows page breaks and has the quotes in the top left and bottom right of the environment. Adjust the keys as you see fit!

Here's the complete code:

% arara: pdflatex
\documentclass{article}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}

\newtcolorbox{fancyquotes}{%
    enhanced jigsaw, 
    breakable,      % allow page breaks
    frame hidden,   % hide the default frame
    left=0cm,       % left margin
    right=0cm,      % right margin
    overlay={%
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
            },
        % paragraph skips obeyed within tcolorbox
                parbox=false,
}

\begin{document}
\lipsum[1]

\begin{fancyquotes}
    \lipsum[1]
\end{fancyquotes}

\lipsum[1]

\begin{fancyquotes}
    \lipsum
\end{fancyquotes}

\end{document}

If you wish the behaviour of page-broken environments to be different, then you can adjust the environment as follows, for example,

\newtcolorbox{fancyquotes}{%
    enhanced jigsaw, 
    breakable,      % allow page breaks
    frame hidden,   % hide the default frame
    left=0cm,       % left margin
    right=0cm,      % right margin
    overlay  unbroken={%
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
    },
    % if you wish to have the look different for page-broken boxes, adjust the following
    overlay first={%
    \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
    },
    overlay middle={},
    overlay last={%
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
    },
    % paragraph skips obeyed within tcolorbox
    parbox=false,
}

This puts quotes at the beginning and at the end, but not in the 'middle' bits, i.e, across page breaks.