TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have a quote in my tex file like this:

\begin{quote}
blabla
\end{quote}

Now I want to refer to this quote inline. Adding a label works but I cannot get the caption to work, in order to show that this quote is actually number x.y. As this environment does not seem to be a float environment, which is apparently a requirement for \caption{}.

So I have tried the following:

\begin{quote}
blabla
\label{quote:one}
\end{quote}

And addint \caption{test} right before the label does not work.

share|improve this question
4  
A quote environment does not have a counter, therefore labelling is useless, in this case. Your request requires some setup ;-) – Christian Hupfer Feb 23 at 14:37
up vote 5 down vote accepted

See below for Alternate Appearance. See ADDENDUM for version that uses aux file to allow future referencing

As Christian noted in a comment, a quote has no counter (and thus no identifying label). However, we could introduce one to the lquote environment, which requires a label as the argument, reference-able by \quoteref.

The implementation given below can be altered to suit the needs for quotation marks, numbering scheme and appearance, etc.

\documentclass{article}
\newcounter{numquote}
\newenvironment{lquote}[1]{%
  \stepcounter{numquote}%
  \expandafter\xdef\csname#1\endcsname{\fbox{\thenumquote}}%
  \quote``\ignorespaces}{\unskip''\fbox{\thenumquote}\endquote}
\newcommand\quoteref[1]{\csname#1\endcsname}
\begin{document}
Compare this quote
\begin{lquote}{quote:one}
blabla
\end{lquote}
to this one
\begin{lquote}{quote:two}
moreblabla
\end{lquote}
In quotation \quoteref{quote:one}, we see a difference from quote \quoteref{quote:two}.
\end{document}

enter image description here

Alternate Appearance

\documentclass{article}
\newcounter{numquote}
\newenvironment{lquote}[1]{%
  \stepcounter{numquote}
  \expandafter\xdef\csname#1\endcsname{\thenumquote}%
  \quote Quote \thenumquote: ``\ignorespaces}{\unskip''\endquote}
\newcommand\quoteref[1]{\csname#1\endcsname}
\begin{document}
Compare this quote
\begin{lquote}{quote:one}
blabla
\end{lquote}
to this one
\begin{lquote}{quote:two}
moreblabla
\end{lquote}
In quotation \quoteref{quote:one}, we see a difference from quote \quoteref{quote:two}.
\end{document}

enter image description here

ADDENDUM:

It seemed from the OP's comment that he may be using the \quoteref prior to the label definition in the lquote environment. To account for that, I have in this addendum implemented a system of writing out to the aux file to make the labels available even before they are defined.

\documentclass{article}
\makeatletter
\long\def \protected@iwrite#1#2#3{%
     \begingroup
     \let\thepage\relax
     #2%
     \let\protect\@unexpandable@protect
     \edef\reserved@a{\immediate\write#1{#3}}%
     \reserved@a
     \endgroup
     \if@nobreak\ifvmode\nobreak\fi\fi
    }
\newcounter{numquote}
\newenvironment{lquote}[1]{%
  \stepcounter{numquote}%
  \protected@iwrite\@auxout{\def\nex{\noexpand\noexpand\noexpand}}{%
    \nex\expandafter\xdef%
    \nex\csname #1%
    \nex\endcsname{\thenumquote}%
  }%
  \quote Quote \thenumquote: ``\ignorespaces}{\unskip''\endquote}
\makeatother
\newcommand\quoteref[1]{\csname#1\endcsname}
\begin{document}
In the future quotation \quoteref{quote:one}, 
  we see a difference from quote \quoteref{quote:two}.

Compare this quote
\begin{lquote}{quote:one}
blabla
\end{lquote}
to this one
\begin{lquote}{quote:two}
moreblabla
\end{lquote}
In quotation \quoteref{quote:one}, we see a difference from quote \quoteref{quote:two}.

\end{document}

enter image description here


Note: the \protected@iwrite macro came from egreg's answer at Writing \\ to a File.

share|improve this answer
    
At least one that takes note of my comments ;-) – Christian Hupfer Feb 23 at 15:01
    
Tried this but it does not show my a reference in the inline quote when writing \quoteref{quote:one}. Nothing appears there. Also, how can I make it looking more like the default captions? Not this "boxed" [1] but like "Quote x.y: blabla" below the quote. – Someguy Feb 23 at 15:03
1  
@Someguy I have provided something more in line with your comments. – Steven B. Segletes Feb 23 at 15:12
    
Looks good, thanks! Except it still does not show anything in the reference itself. I wrote (see Figure \quoteref{quote:one}) but it only appears as (see Figure ). – Someguy Feb 23 at 18:00
1  
@Someguy I have added an addendum to make use of the aux file to allow you to use \quoteref before the invocation of lquote. – Steven B. Segletes Feb 23 at 18:56

Only a \pageref makes sense:

\documentclass{article}
\usepackage{caption}
\begin{document}

\begingroup
\begin{quote}
    blabla
\end{quote} 
\captionof*{figure}{Test}\label{quote:one}
\endgroup

See quote on page~\pageref{quote:one}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.