# How to reference a quote like an equation?

For my project, I've interviewed some people and used parts of those interviews as quotes in my project. Some quotes I would like to reference later on, just like how equations are referenced, with a number (1) right next to the equation.

My set up is

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage{pdfpages}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{setspace}
\usepackage{caption}
\newenvironment{myquote}{\list{}{\leftmargin=1.0cm\rightmargin=1.0cm}\centering\small\itshape\item[]}{\endlist}
\usepackage{mathtools}

\begin{document}
This is an example of what the subject might be.
\begin{myquote}
Oh really -stranger.
\end{myquote}

Some text in-between.

\begin{myquote}
yes really -me
\end{myquote}

As mentioned by me in quote No. 1, I responded to a stranger.

\end{document}


So if I'm writing:

\begin{myquote}
Example of a quote.
\end{quote}


I just get the quote, which is fine, but in some cases I also want a number to the right of it - for later references, like:

yes really -me                      (1)


Here is a picture of what I have:

And all I want is a number next to some of the quotes, just like it's possible to do with some equations.

I have tried to label it as an equation \label{eq:1} but it didn't work, and I also tried with the other labels. I have also tried How to reference a point in a document with a counter and descriptive text?, but that only gives me an active reference, which is close, but not quite what I'm looking for. I also tried Quote environment with reference at the end right, but that too wasn't quite what I was looking for. I have also tried \usepackage{csquotes} which for some reason doesn't work for me.

Solved:

\usepackage{environ}
\newcounter{quote}

\NewEnviron{myquotenumber}{\vspace{3ex}\par
\refstepcounter{quote}%
\hfill\parbox{\dimexpr \textwidth-2cm}%brug \parbox[b] for bunden [c] (standard) for center og [t] for top
{\centering\small\textit{\BODY}}
\hfill\llap{(\thequote)}\vspace{2ex}\par}


Now all quotes beginning with \begin{myquote} won't be numbered and quotes with \begin{myquotenumber}\cite{marker} has numbers and can be referenced with \ref{marker}.

• Would you also need a list of quotes, similar to figures and tables? – Johannes_B May 7 '15 at 13:46
• That won't be necessary. – user38934 May 7 '15 at 14:36

Trying to center the quote while placing the number on the right was too difficult using the list environment, so I used a \parbox instead. The main difference is that a \parbox will not break at the end of a page.

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage{pdfpages}
\usepackage{tikz}
\usetikzlibrary{positioning}
%\usepackage{caption}% incompatible with memoir
\usepackage{mathtools}
\usepackage{environ}

\newcounter{quote}

\NewEnviron{myquote}{\vspace{1ex}\par
\refstepcounter{quote}%
\hfill\parbox{\dimexpr \textwidth-2cm}%
{\centering\small\textit{\BODY}}%
\hfill\llap{(\thequote)}\vspace{1ex}\par}

\begin{document}
This is an example of what the subject might be.
\begin{myquote}\label{example}
Oh really -stranger.
\end{myquote}

Some text in-between.

\begin{myquote}
yes really -me
\end{myquote}

As mentioned by me in quote No. \ref{example}, I responded to a stranger.

\end{document}

• YES. It's working. I have two questions, for some small details. First question is, can the placement of the numbers be centered compared to the whole quote? At the moment, the numbers are aligned to the bottom line of the quote. Second question is, can only the quotes with a "\label" be numbered and not all of them? I think It's easier to find the few numbered quotes among the hundreds of quotes used throughout the report. – user38934 May 7 '15 at 16:05
• Solved second question by changing myquote to myquotenumber for the ones that is going to be referenced. – user38934 May 7 '15 at 16:12
• \parbox[b] for bottom, [c] (default) for center and [t] for top. Actually it uses the baseline for the top or bottom line. – John Kormylo May 7 '15 at 16:27

This will get you started. You can modify it for different numbering (e.g by section as 1.1, 1.2 etc change the within=none to within=section). This example has a table of quotes with page numbers. You can easily modify it so you have no quote caption (or only a caption within the table of quotes), and have a different layout with the number on the right (e.g. put the quote in a table with number to right) -- I used the epigraph package to lay out the quote itself, but you will do as you wish for that part.

\documentclass{article}
\usepackage{newfloat}
\DeclareFloatingEnvironment[name=myquote,listname={List of Quotes}, within=none,placement=htbp,]{myquote}
\usepackage{caption}

\usepackage{epigraph}

\begin{document}

\listofmyquote

\epigraph{The sky is blue.}
{\textit{Monty Python} \captionof{myquote}{The blue quote}\label{quot:xyz}}

\epigraph{And now for something completely diﬀerent.}
{\textit{Monty Python} \captionof{myquote}{Another Python quote}}

{\textit{Monty Python} \captionof{myquote}{Quote by Python}}

Here I refer to Quote~\ref{quot:xyz}

\end{document}


Well in response to your layout comment you can do whatever you like

Here is an example, though the code is getting a little spidery at this stage and you would need to clean it up and convert some to macros

\documentclass{article}
\usepackage{newfloat}
\usepackage{array}
\DeclareFloatingEnvironment[name=myquote,listname={List of Quotes}, within=none,placement=htbp,]{myquote}
\usepackage{caption}
\usepackage{epigraph}
\def\signed #1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
\hbox{}\nobreak\hfil(#1)%
\parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\newsavebox\mybox
\newenvironment{aquote}[1]
{\savebox\mybox{#1}\begin{quote}}
{\signed{\usebox\mybox}\end{quote}}

\newcommand*{\tabbox}[2][t]{%
\vspace{0pt}\parbox[#1][3.7\baselineskip]{1cm}{\strut#2\strut}}

\DeclareCaptionLabelFormat{mylabformat}{\textbf{Q:#2}}%define a label format with prefix and bold
\captionsetup[myquote]{hypcap=false, format=plain,indention=0pt, labelformat=mylabformat, labelsep=colon,justification=RaggedRight, textfont=it, singlelinecheck=true,margin={1cm,1cm},maxmargin=0.05\linewidth, skip=10pt, position=top}%temporay test with captions package to make plan caption messes my magic figs

\begin{document}

\listofmyquote %purely optional

\begin{tabular}{p{0.8\linewidth}p{0.2\linewidth}}
\begin{aquote}{Bourbaki}
This is a case where the name fits in nicely with the quote so the name will appear in the same line.
\end{aquote}&
\tabbox[b]{\captionof{myquote}[Tag for table of quotes Bourbaki]{}}
\end{tabular}

\begin{tabular}{p{0.8\linewidth}p{0.2\linewidth}}
\begin{aquote}{Nicolas Bourbaki}
This is a case where the name won't fit in nicely with the quote, and in this case the name will be moved to the next line.
\end{aquote}&
\tabbox[b]{\captionof{myquote}[Tag for table of quotes Nicolas Bourbaki]{}\label{quot:xyz}}

\end{tabular}

\begin{tabular}{p{0.8\linewidth}p{0.2\linewidth}}
\begin{aquote}{Nicolas Bourbaki}
This is a case where the name won't fit in nicely with the quote, and in this case the name will be moved to the next line.
\end{aquote}&
\tabbox[b]{\captionof{myquote}[Tag for table of quotes Nicolas Bourbaki]{}}
\end{tabular}

Here I refer to Quote~\ref{quot:xyz}

\end{document}


• Note quite what I'm looking for. A list won't be necessary and the quotes are not displayed as I showed. – user38934 May 7 '15 at 14:51

Here is a colorful suggestion using tcolorbox.

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage[most]{tcolorbox}

\usepackage{showframe}

\newtcolorbox[auto counter,number within=section]{myquote}[2][]{%
colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
enlarge left by=1cm,enlarge right by = -1cm,width=\linewidth-2cm,
title=Quote~\thetcbcounter: #2,#1}
\begin{document}
\begin{myquote}[colback=yellow,label={myquote}]{user38934}
This is some quote which is very nice
\end{myquote}

This is my quote numbered~\ref{myquote} here
\end{document}


Tweak as you like. Here an list of quotes is also possible. That would look like this:

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage[most]{tcolorbox}

\usepackage{showframe}

\newtcolorbox[auto counter,number within=section,list inside=myquote]{myquote}[2][]{%
colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
enlarge left by=1cm,enlarge right by = -1cm,width=\linewidth-2cm,
title=Quote~\thetcbcounter: #2,#1}
\begin{document}
\tcblistof[\section]{myquote}{List of quotes}
\begin{myquote}[colback=yellow,label={myquote}]{user38934}
This is some quote which is very nice
\end{myquote}

This is my quote numbered~\ref{myquote} here
\end{document}


Without colours and number to the right and without numbers:

\documentclass{memoir}
\usepackage[most]{tcolorbox}

\usepackage{showframe}

\newtcolorbox[auto counter,number within=section]{myquote}[1][]{%
colback=white,boxrule=0pt,enhanced jigsaw,fontupper=\centering\small\itshape,%fonttitle=\bfseries,
enlarge left by=1cm,enlarge right by = -1cm,width=\linewidth-2cm,
overlay={
\node[anchor=east,inner xsep=0pt] at ([shift={(10mm,0mm)}]frame.east) {\strut(\thetcbcounter)};
},
#1}

% un-numbered quote.

\newtcolorbox{mynonumquote}[1][]{%
colback=white,boxrule=0pt,enhanced jigsaw,fontupper=\centering\small\itshape,%fonttitle=\bfseries,
enlarge left by=1cm,enlarge right by = -1cm,width=\linewidth-2cm,
#1}

\begin{document}
\begin{myquote}[label={myquote}]
This is some quote which is very nice
\end{myquote}

This is my quote numbered~\ref{myquote} here

\begin{mynonumquote}
This is some quote which is very nice
\end{mynonumquote}

\end{document}


• Close. I don't need the colors or the frames, but I would like the quote number to be to the right of the quote, like it's done for equations, and also how do I get the text to be \centering \small and \itshape ? (I tried this out, but it seems like all the quotes gets numbers now. Are there an option to not number them, like with sections (section*{})?) – user38934 May 7 '15 at 15:31
• @user38934 See the update please. – user11232 May 7 '15 at 16:11