在下面的平均能量损失,环境”引用者“被用作一个“伪”标题:它不是一个真正的\caption
或\captionof
,但它仍然会生成一个计数器并显示一个单词,例如“引用“ 或者 ”数字“(或者你喜欢的其他任何东西)和一个计数数字之后。
我只是想知道我如何能轻松地参考对于这样的一个特定实例引用者“环境,与数字另外还有标题描述的 ”引用“(在某些情况下,或者在其他情况下:“数字“或其他任何内容)。
对于真实的\caption
或\captionof
,这并不太难。但是,我们如何为这个“伪”标题做到这一点?一个至关重要的步骤是知道如何恢复某个带标签的引用的编号,但不要根据其编号引用它(因为这可能会随着整个文档的变化而变化)。以某种方式自动引用\label
的标题描述,然后通过:自动恢复报价的号码。
MWE 展示了期望的最终结果是什么样子。
平均能量损失
\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
%%%%% quoter environment
\newcounter{quote}
\newmdenv[
hidealllines=true,
innertopmargin=16pt,
innerbottommargin=10pt,
leftmargin=0cm,
rightmargin=0cm,
skipabove=10pt,
skipbelow=10pt,
singleextra={
\coordinate (aux) at ( $ (O)!0.5!(P) $ );
\fill[rounded corners=6pt,line width=1pt,blue!30]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) {[sharp corners] --
([yshift=-6pt]P) --
([yshift=-6pt]O|-P) } -- cycle;
\draw[rounded corners=6pt,line width=1pt,blue]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) --
(P|-O) --
(O) -- cycle;
\node at ([xshift=2cm,yshift=3pt]aux|-P)
{\refstepcounter{quote}\large Quote~\thequote} ;
},
firstextra={
\coordinate (aux) at ( $ (O)!0.5!(P|-O) $ );
\fill[rounded corners=6pt,line width=1pt,blue!30,overlay]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) {[sharp corners] --
([yshift=-6pt]P) --
([yshift=-6pt]O|-P) } -- cycle;
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O) --
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) --
(P|-O);
\node[overlay] at ([xshift=2cm,yshift=3pt]aux|-P)
{\refstepcounter{quote}\large Quote~\thequote} ;
},
middleextra={
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O|-P) --
(O);
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(P) --
(P|-O);
},
secondextra={
\coordinate (aux) at ( $ (O)!0.5!(P|-O) $ );
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O|-P) --
(O) --
(P|-O) --
(P);
},
]{quoter}
%%%%% begin the beguine
\begin{document}
If you are interested in this, please see \textbf{Quote 1: Kierkegaard's quote, reproduced blindly from the internet}.
\begin{quoter}
\begin{center}
\textbf{Kierkegaard's quote, reproduced blindly from the internet}
\vspace{0.5em}
\hrule
\vspace{1em}
\end{center}
The function of prayer is not to influence God, but rather to change the nature of the one who prays.\footnote{Kierkegaard.}
\end{quoter}
\end{document}
PS:当然,如果能将\nameref
或“伪”名称引用自动(或可选)设置为可点击的超链接到实际的引用。
答案1
可以将文本内容写入.aux
文件
\labelText
我已经使用设置标题和设置标签的命令完成了此操作(根据用户规范)。
使用\nameref
then 来引用该标签。
格式化应该在文本标签外部完成,而不是在内部。
(由于我在平板电脑上书写,因此目前无法提供更好的解决方案)
\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{nameref}
\usetikzlibrary{calc}
%%%%% quoter environment
\newcounter{quote}
\newmdenv[
hidealllines=true,
innertopmargin=16pt,
innerbottommargin=10pt,
leftmargin=0cm,
rightmargin=0cm,
skipabove=10pt,
skipbelow=10pt,
settings={\refstepcounter{quote}},
singleextra={
\coordinate (aux) at ( $ (O)!0.5!(P) $ );
\fill[rounded corners=6pt,line width=1pt,blue!30]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) {[sharp corners] --
([yshift=-6pt]P) --
([yshift=-6pt]O|-P) } -- cycle;
\draw[rounded corners=6pt,line width=1pt,blue]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) --
(P|-O) --
(O) -- cycle;
\node at ([xshift=2cm,yshift=3pt]aux|-P)
{\large Quote~\thequote} ;
},
firstextra={
\coordinate (aux) at ( $ (O)!0.5!(P|-O) $ );
\fill[rounded corners=6pt,line width=1pt,blue!30,overlay]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) {[sharp corners] --
([yshift=-6pt]P) --
([yshift=-6pt]O|-P) } -- cycle;
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O) --
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) --
(P|-O);
\node[overlay] at ([xshift=2cm,yshift=3pt]aux|-P)
{\large Quote~\thequote} ;
},
middleextra={
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O|-P) --
(O);
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(P) --
(P|-O);
},
secondextra={
\coordinate (aux) at ( $ (O)!0.5!(P|-O) $ );
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O|-P) --
(O) --
(P|-O) --
(P);
},
]{quoter}
\makeatletter
\newcommand{\labelText}[2]{%
#1%
\immediate\write\@auxout{%
\string\newlabel{#2}{{1}{\thepage}{{Quote \thequote: #1}}{quoter.\number\value{quote}}{}}%
}%
}
%%%%% begin the beguine
\begin{document}
%\textbf{Quote 1: Kierkegaard's quote, reproduced blindly from the internet}.
If you are interested in this, please see \textbf{\nameref{kierkegaard}}
\begin{quoter}
\begin{center}
\textbf{\labelText{Kierkegaard's quote, reproduced blindly from the internet}{kierkegaard}}
%\textbf{Kierkegaard's quote, reproduced blindly from the internet}
\vspace{0.5em}
\hrule
\vspace{1em}
\end{center}
The function of prayer is not to influence God, but rather to change the nature of the one who prays.\footnote{Kierkegaard.}
\end{quoter}
\end{document}
更新链接
\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{hyperref}
\usetikzlibrary{calc}
%%%%% quoter environment
\newcounter{quote}
\renewcommand{\theHquote}{quote.\thequote}
\makeatletter
\newcommand{\labelText}[2]{%
#1%
\immediate\write\@auxout{%
\string\newlabel{#2}{{1}{\thepage}{{Quote \thequote: #1}}{quote.\theHquote}{}}%
}%
}
\makeatother
\newmdenv[
hidealllines=true,
innertopmargin=16pt,
innerbottommargin=10pt,
leftmargin=0cm,
rightmargin=0cm,
skipabove=10pt,
skipbelow=10pt,
settings={\refstepcounter{quote}},
singleextra={
\coordinate (aux) at ( $ (O)!0.5!(P) $ );
\fill[rounded corners=6pt,line width=1pt,blue!30]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) {[sharp corners] --
([yshift=-6pt]P) --
([yshift=-6pt]O|-P) } -- cycle;
\draw[rounded corners=6pt,line width=1pt,blue]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) --
(P|-O) --
(O) -- cycle;
\node at ([xshift=2cm,yshift=3pt]aux|-P)
{\large Quote~\thequote} ;
},
firstextra={
\coordinate (aux) at ( $ (O)!0.5!(P|-O) $ );
\fill[rounded corners=6pt,line width=1pt,blue!30,overlay]
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) {[sharp corners] --
([yshift=-6pt]P) --
([yshift=-6pt]O|-P) } -- cycle;
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O) --
(O|-P) --
(aux|-P) --
([yshift=12pt]aux|-P) --
([yshift=12pt,xshift=4cm]aux|-P) --
([xshift=4cm]aux|-P) --
(P) --
(P|-O);
\node[overlay] at ([xshift=2cm,yshift=3pt]aux|-P)
{\large Quote~\thequote} ;
},
middleextra={
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O|-P) --
(O);
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(P) --
(P|-O);
},
secondextra={
\coordinate (aux) at ( $ (O)!0.5!(P|-O) $ );
\draw[rounded corners=6pt,line width=1pt,blue,overlay]
(O|-P) --
(O) --
(P|-O) --
(P);
},
]{quoter}
%\string\newlabel{#2}{{1}{\thepage}{{#1}}{mylabelcounter.\number\value{mylabelcounter}}{}}
%%%%% begin the beguine
\begin{document}
If you are interested in this, please see \textbf{\nameref{kierkegaard}}
\clearpage
\begin{quoter} %\label{quoter}
\begin{center}
\textbf{\labelText{Kierkegaard's quote, reproduced blindly from the internet}{kierkegaard}}
\vspace{0.5em}
\hrule
\vspace{1em}
\end{center}
The function of prayer is not to influence God, but rather to change the nature of the one who prays.\footnote{Kierkegaard.}
\end{quoter}
\end{document}