13

I would like to number the quotations that appear in my document. I like what LaTeX does with the equation environment, and would like something similar, so that if I had typed

\begin{quote}
Quote 1  
\end{quote}
more text more text more text  
\begin{quote}
Quote 2  
\end{quote}

The two quotes would appear with numbers off to the side like would happen if I had used the equation environment.

Thanks for your help.

Torbjørn T.
  • 206,688
  • 1
    Probebly make use of theorem environments. They are highly customizable. See amsthm and ntheorem. – jmc Apr 05 '12 at 20:20
  • Welcome to TeX.SE! Two quick comments. First, the style in this group, when asking a question, is not to thank people in words; rather, when you get answers, do consider upvoting the good ones and accepting the best. Second, it would be helpful if you provided a bit more information about your document's setup: Which document class do you use, and do you use any special packages for typesetting quotations? For instance, there's a LaTeX package called "quoting". – Mico Apr 05 '12 at 20:22
  • Do the quotes span more than one line, like a paragraph? If it spans more than one line, is it okay if the block is numbered in the middle (vertically), or should be at the top/bottom? Do you want the numbers in the margin, or within the text block (like with an equation)? Please clarify. – Werner Apr 05 '12 at 20:47

2 Answers2

16

One way is to use the resume feature of the enumitem package, which gives you much flexibility in choosing how you want your quotes to be numbered. Below I have defined a list to have a depth of 2 and use numbers for the first level quotes and switch to letters for the second level quotes (if any). The color blue was added just so that the quote environment would stand out:

enter image description here

Notes:

  • The showframe package was added just so that you could see where the margins of the text are.

References:

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{xcolor}

\usepackage{enumitem} \newlist{myQuoteEnumerate}{enumerate}{2}% Set max nesting depth \setlist[myQuoteEnumerate,1]{label=(\arabic)}% Use numbers for level 1 \setlist[myQuoteEnumerate,2]{label=(\alph)}% Use letters for level 2

\newenvironment{MyQuote}{% \begin{myQuoteEnumerate}[resume=*,series=MyQuoteSeries]% \color{blue}% \item \begin{quote}% }{% \end{quote}% \end{myQuoteEnumerate}% }%

\begin{document} \noindent some text some text some text % \begin{MyQuote} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris et diam viverra mauris commodo eleifend. Donec quis massa nisi.
\begin{MyQuote} Suspendisse magna nisi, rhoncus sed sagittis sed, auctor id quam. Phasellus quis neque ut tellus tristique accumsan. Curabitur dignissim laoreet pellentesque. Integer placerat consectetur commodo. \end{MyQuote} \end{MyQuote} % more text more text more text % \begin{MyQuote} Proin elit massa, sollicitudin vitae consectetur sit amet, sollicitudin nec nisl. Nulla facilisi. \end{MyQuote} \end{document}

Peter Grill
  • 223,288
  • This is helpful, and your sample document is particularly useful for showing how to further modify this setup. It happens that the other answer matches the aesthetic I was hoping for more, however. – underwhelmer Apr 07 '12 at 19:22
12

(Edit: please see the additional suggestions made in comments by others.)

Here's a simple approach using a \parbox.

\documentclass[12pt]{article}
\usepackage{lipsum}

\newcounter{quotecount}
\newcommand{\MyQuote}[1]{\vspace{1cm}\addtocounter{quotecount}{1}%
     \parbox{10cm}{\em #1}\hspace*{2cm}(\arabic{quotecount})\\[1cm]}

\begin{document}
\lipsum[1]
\MyQuote{\lipsum[2]}
\lipsum[3]
\MyQuote{\lipsum[4]}
\lipsum[5]

\end{document}

simple test

André
  • 2,345
  • 3
    Using \stepcounter{quotecount} is equivalent to \addtocounter{quotecount}{1}. However, using \refstepcounter{quotecount} instead allows one to use \label and later \ref it. – Werner Apr 06 '12 at 02:44
  • Ah, this is perfect. Werner: this is helpful; I will frequently be referring to my quotes. – underwhelmer Apr 07 '12 at 19:24
  • 2
    In the solution with the parbox, I would suggest using variable sizes: \newcommand{\MyQuote}[1]{\addtocounter{quotecount}{1}% \indent\parbox{\textwidth - 4\parindent}{\bigskip\em #1}\hfill(\arabic{quotecount})\bigskip} – dingenis Oct 01 '14 at 16:32
  • 1
    I’d add \par to the beginning of the env to ensure that \vspace works and also use \par\vspace at the end and not \\[…] – Tobi Oct 03 '14 at 12:51
  • 1
    And note that these quotes can't be broken across pages. – Tobi Oct 03 '14 at 12:52
  • 1
    @andre can I suggest you update your answer with the suggestions of werner, user79927 and tobi? I needed to add all of them to make your answer useful. – Joel Aug 18 '16 at 07:08