견적 환경 참조

견적 환경 참조

현재 내 tex 파일에 다음과 같은 인용문이 있습니다.

\begin{quote}
blabla
\end{quote}

이제 나는 이 인용문을 인라인으로 참조하고 싶습니다. 레이블을 추가하면 작동하지만 caption이 인용문이 실제로 숫자 xy임을 보여주기 위해 작동할 수 없습니다. 이 환경은 분명히 \caption{}.

그래서 나는 다음을 시도했습니다.

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

그리고 \caption{test}라벨 바로 앞에 추가 기능이 작동하지 않습니다.

답변1

대체 모양은 아래를 참조하세요. 향후 참조를 허용하기 위해 aux 파일을 사용하는 버전은 부록을 참조하세요.

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}

여기에 이미지 설명을 입력하세요

부록:

\quoterefOP의 의견에 따르면 환경에서 레이블 정의 이전을 사용하고 있는 것 같습니다 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}

서문 끝에서 참조의 하이퍼링크를 통해 원하는 결과를 자동으로 얻을 수 있습니다.

관련 정보