Block quote with big quotation marks

How can I create a block quote enviroment with big quotation marks similar to the Cquote Template of Wikipedia?

Additionally it would be nice to place both quotation marks and quote in a colored box and to have the author closer to the citation.

-
JFYI: See now also Block quote with big quotation marks and opening quote on bottom. –  Speravir Feb 21 '13 at 3:32

Here's one solution using TikZ which defines a new environment using the framed package. You should preferably compile this with xelatex or lualatex, since it gives the easiest access to a wide range of fonts. I've added code to make it run under pdflatex as well.

The code has now been updated to allow some flexibility in the formatting of the different components of the quotation, and the environment takes two arguments:

Environment Syntax

 \begin{shadequote}[<alignment>]{<author>}
text of quote


Code

% !TEX TS-program = xeLaTeX

\documentclass[12pt]{article}
\usepackage{ifxetex,ifluatex}
\usepackage{etoolbox}
\usepackage[svgnames]{xcolor}

\usepackage{tikz}

\usepackage{framed}

% conditional for xetex or luatex
\newif\ifxetexorluatex
\ifxetex
\xetexorluatextrue
\else
\ifluatex
\xetexorluatextrue
\else
\xetexorluatexfalse
\fi
\fi
%
\ifxetexorluatex%
\usepackage{fontspec}
\usepackage{libertine} % or use \setmainfont to choose any font on your system
\newfontfamily\quotefont[Ligatures=TeX]{Linux Libertine O} % selects Libertine as the quote font
\else
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{libertine} % or any other font package
\newcommand*\quotefont{\fontfamily{LinuxLibertineT-LF}} % selects Libertine as the quote font
\fi

\newcommand*\quotesize{60} % if quote size changes, need a way to make shifts relative
% Make commands for the quotes
\newcommand*{\openquote}
{\tikz[remember picture,overlay,xshift=-4ex,yshift=-2.5ex]
\node (OQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont};\kern0pt}

\newcommand*{\closequote}[1]
{\tikz[remember picture,overlay,xshift=4ex,yshift={#1}]
\node (CQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont''};}

% select a colour for the shading

\newcommand*\shadedauthorformat{\emph} % define format for the author argument

% Now a command to allow left, right and centre alignment of the author
\newcommand*\authoralign[1]{%
\if#1l
\def\authorfill{}\def\quotefill{\hfill}
\else
\if#1r
\def\authorfill{\hfill}\def\quotefill{}
\else
\if#1c
\gdef\authorfill{\hfill}\def\quotefill{\hfill}
\else\typeout{Invalid option}
\fi
\fi
\fi}
% wrap everything in its own environment which takes one argument (author) and one optional argument
% specifying the alignment [l, r or c]
%
{\authoralign{#1}
\ifblank{#2}

\begin{document}

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

\end{document}


In this code, the font for the quotation marks is set independently of the main document font. This is because depending on the main font you choose, the very large quotation marks will not look good; Linux Libertine has pretty quotes that seem appropriate for the purpose. If you want to use this environment with another main document font, remove/change the \usepackage{libertine}.

Sample output

-
@Alun: Why do you define \quotefont? libertine is already present. –  Herbert Apr 30 '11 at 14:32
@Herbert Because these are decorative elements, it makes sense to define the font for the quotes independent of the document font. For example, if you just use Computer Modern, the big quotes look quite silly; The libertine font has a pretty quote for this purpose, and I would use it with most document fonts. –  Alan Munn Apr 30 '11 at 14:53
@Alun: You know, that I know that ... ;-) But then it makes sense to use another text font in your example, if you want to show this behaviour. –  Herbert Apr 30 '11 at 17:32
@Herbert I tried to make that clear in the code comments. I figured that anyone who wanted to play around with other fonts would figure it out. I'll add a comment to the text of the answer. –  Alan Munn Apr 30 '11 at 17:36
This is very nice! However, id one doesn't separate the author via \par from the quote the spacing of the closing quotation mark is somewhat of. Maybe there is a simple fix for that? It works nicer in Herbert's version. –  Emerson Apr 30 '11 at 18:59
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage{framed}

\newcommand*\openquote{\makebox(25,-22){\scalebox{5}{}}}
\newcommand*\closequote{\makebox(25,-22){\scalebox{5}{''}}}

\makeatletter
\newif\if@right
\makeatother
\begin{document}

Some quoted words

Some quoted words

A common mistake that people make when trying to design something completely
foolproof is to underestimate the ingenuity of complete fools.\par\emph{Douglas Adams}

\end{document}


-
Using your code in a minimal example works great, but when I copy it to a large document I work on I get the error "You can't use '\spacefactor' in vertical mode". Do you have any idea how to resolve this problem? Thanks! –  lumbric Mar 21 '12 at 22:39
you'd forgotten the makeatletter ... makeatother –  Herbert Mar 22 '12 at 11:09
Thanks a lot! It took me quite a while to figure out what happend, but you were right, I messed up the \makeatletter and \makeatother commands. This happend after exporting some code from LyX, at this step LyX put some additional \makeatletter and \makeatother around my custom code. –  lumbric Mar 26 '12 at 21:22
If there is a line break before the closing quote, it looks a bit strange. I don't have a real good suggestion, but I think placing simple a nolinebreak makes things a bit better. This means one would have to replace the line \if@right\hfill\fi\closequote\end{quote}\end{snugshade}} by \nolinebreak\if@right\hfill\fi\closequote\end{quote}\end{snugshade}}. This is a comment and not an edit, because I'm unsure if it's the best solution. –  lumbric Mar 28 '12 at 20:28
I'm trying to use this in my thesis which is based on classicthesis but the problem is, it mess with all my fonts and change them. What am I doing wrong here? The same holds for @Herbert 's answer. –  Pouya Sep 25 '13 at 15:31

(We just got another question asking for something similar: Quote style like on owni.eu. I wasn't aware of this question when I started to answer that one, but on becoming aware of it decided to post my answer here instead.)

It's also TikZ-based but slightly different to Alan's as the whole thing ends up in a TikZ node. This does mean that it won't work with page-breaking. One could also adapt the quote marks from Alan's version to make them look a bit better.

Here's the result:

And here's the code:

\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=\textwidth,
},
fancy quotes width/.initial={.8\textwidth},
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}{\textwidth - 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}


The lipsum package is just to provide some dummy text.

-
I like this one a lot and have started to use it in my documents. Thanks! –  adl Jan 26 '12 at 16:46
This looks seriously good in documents. Thanks! –  fg nu Jul 25 '12 at 6:53