引用環境の参照

引用環境の参照

現在、Tex ファイルには次のような引用文があります。

\begin{quote}
blabla
\end{quote}

ここで、この引用をインラインで参照したいと思います。ラベルを追加すると機能しますが、 をcaption機能させて、この引用が実際には数値 xy であることを示すことができません。この環境は float 環境ではないようですが、これは の要件のようです\caption{}

そこで私は次のことを試しました:

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

\caption{test}また、ラベルの直前のaddint は機能しません。

答え1

代替の外観については以下を参照してください。将来の参照を可能にするために補助ファイルを使用するバージョンについては付録を参照してください。

Christian がコメントで指摘したように、引用にはカウンターがありません (したがって識別ラベルもありません)。ただし、lquoteラベルを引数として必要とし、 によって参照可能なラベルを環境に導入することはできます\quoteref

以下に示す実装は、引用符、番号付けスキーム、外観などのニーズに合わせて変更できます。

\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}

ここに画像の説明を入力してください

代替の外観

\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}

ここに画像の説明を入力してください

補遺:

OP のコメントから、彼は\quoteref環境でラベル定義の前に を使用している可能性があるようですlquote。それを考慮して、この付録では、ラベルが定義される前でもラベルを使用できるように aux ファイルに書き出すシステムを実装しました。

\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}

ここに画像の説明を入力してください


注: この\protected@iwriteマクロはegregの回答から引用したものです。ファイルへの書き込み

答え2

意味を成すのはa のみです\pageref:

\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}

答え3

受け入れられている解決策には多くの点で欠陥があります。LaTeX にはすでに独自の参照メカニズムがあり、それがバイパスされるため、ご覧のとおり問題が発生します。

代わりに、環境を次のように定義しますlquote

\newcounter{numquote}
\newenvironment{lquote}{%
  \refstepcounter{numquote}%
  \quote}{\unskip~\thenumquote\endquote}

これを次のように使います

\begin{lquote}
  blah blah
  \label{quote:one}
\end{lquote}
...
quote~\ref{quote:one}.

そして、

\usepackage{hyperref}

序文の最後に、参照のハイパーリンクを含む目的の結果が自動的に得られます。

関連情報