9

I am trying to make a quotation environment as picture below.

enter image description here

The environment is indented the same as \parindent on each side, the environment is automatically italic, and you can put the person and the date in brackets not in italics.

I don't have an MWE since I'm not really sure where to start. I guess it's something to do with \newinvironment, but I've never used that before.

Could someone help please? Thanks in advance.

  • 3
    Don't reinvent the wheel. Your document class probably already contains a quote and a quotation environment, with slightly different formats, and one of them might be exactly what you want. The simplest way to get the attribution at the right margin is just to put \hfill in front of it - though if you have a lot of quotes and you need to automatically handle the situation where the attribution needs to go on a separate line because it won't fit on the last line of the quote, you might want a more sophisticated alternative. If so, ask another question just about that. – alephzero Sep 16 '17 at 19:45
  • 1
    To customise a quote/quotation environment, take a look at the quoting package. Another posssibility: the epigraph package. – Bernard Sep 16 '17 at 20:02
  • @alephzero ok good point. It'd be nice if I could do it automatically. But I guess that'll do. Also thanks to Bernard for the suggestion. – PercyF2519 Sep 16 '17 at 20:11
7

The quoting package is very useful, together with a trick found in the TeXbook (look for Bourbaki in the index).

\documentclass{article}
\usepackage{quoting,xparse}

\NewDocumentCommand{\bywhom}{m}{% the Bourbaki trick
  {\nobreak\hfill\penalty50\hskip1em\null\nobreak
   \hfill\mbox{\normalfont(#1)}%
   \parfillskip=0pt \finalhyphendemerits=0 \par}%
}

\NewDocumentEnvironment{pquotation}{m}
  {\begin{quoting}[
     indentfirst=true,
     leftmargin=\parindent,
     rightmargin=\parindent]\itshape}
  {\bywhom{#1}\end{quoting}}

\begin{document}

This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
\begin{pquotation}{Jack Johnson, 2003}
`This is a quotation. This is a quotation.
This is a quotation. This is a quotation.
This is a quotation. This is a quotation.
This is a quotation. This is a quotation.
This is a quotation.'
\end{pquotation}
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
\begin{pquotation}{Jack Johnson, 2003}
`This is a quotation. This is a quotation.
This is a quotation. This is a quotation.
This is a quotation. This is a quotation.
This is a quotation. This is a quotation.
This is a quotation. This is a quotation.'
\end{pquotation}
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.
This is not a quotation, this is normal text.

\end{document}

enter image description here

  • That's amazing, thank you! It's also nice because you can easily use it with citations. – PercyF2519 Sep 16 '17 at 21:28
5

Here's a solution based on the csquotes package:

enter image description here

\documentclass{memoir}
% filler text:
\newcommand\lipx{Lorem ipsum dolor sit amet, 
consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, 
felis. Curabitur dictum gravida mauris. Nam 
arcu libero, nonummy eget, consectetuer id, 
vulputate a, magna.}

\usepackage{csquotes}
\SetBlockThreshold{2}
\newcommand\myblockquote[2]{%
  \blockquote{\hspace*{2em}\emph{`#1'}\hfill(#2)}\par}

\begin{document}
\lipx\ \lipx

\myblockquote{\lipx}{Jack Johnson, 2003}

\lipx\ \lipx
\end{document}
  • 2
    Add some words to the quotation and see what happens. A possible failure is that the name may be split across lines; the second, less obvious failure is when the \hfill is used as a line break point, whence the name will be flush left. – egreg Sep 16 '17 at 20:50

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.