如何像方程式一样引用引文?

如何像方程式一样引用引文?

为了我的项目,我采访了一些人,并将这些采访的部分内容用作quotes我的项目。有些引言我以后会引用,就像引用方程式一样,在方程式旁边有一个数字 (1)。

我的设置是

\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}
\usepackage[colorlinks=true]{hyperref}

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

如果我这样写:

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

我只得到了报价,这很好,但在某些情况下,我还希望在它的右边有一个数字 - 以供以后参考,例如:

yes really -me                      (1) 

这是我所拥有的图片:

在此处输入图片描述

我想要的只是一些引号旁边的数字,就像一些方程式那样。

我尝试过将其标记为方程式\label{eq:1},但没有成功,我也尝试过其他标签。我也尝试过如何用计数器和描述性文本引用文档中的某个点?,但这只给了我一个有效的引用,虽然很接近,但不是我想要的。我也试过了引用环境并在末尾引用,但这也不是我想要的。我也试过了,\usepackage{csquotes}但不知为何不起作用。

解决了:

在序言中添加了以下内容:

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

现在所有以 开头的引号\begin{myquote}都不会被编号,而以 的引号\begin{myquotenumber}\cite{marker}都有编号,可以用 来引用\ref{marker}

答案1

使用列表环境尝试将引文居中并将数字放在右侧太困难了,因此我改用 \parbox。主要区别在于 \parbox 不会在页面末尾中断。

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

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

答案2

这将帮助您入门。您可以修改它以使用不同的编号(例如,按 1.1、1.2 等部分将 within=none 更改为 within=section)。此示例有一个带页码的引文表。您可以轻松修改它,以便没有引文标题(或引文表中只有标题),并且使用右侧带有数字的不同布局(例如,将引文放在右侧带有数字的表格中)——我使用 epigraph 包来布局引文本身,但您可以根据需要对那部分进行操作。

\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 different.}
{\textit{Monty Python} \captionof{myquote}{Another Python quote}}

\epigraph{is that a dead parrot}
{\textit{Monty Python} \captionof{myquote}{Quote by Python}}

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

\end{document}

在此处输入图片描述

好吧,回应你的布局评论你可以做任何你喜欢的事情

这是一个例子,虽然在这个阶段代码变得有点复杂,你需要清理它并将一些代码转换为宏

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

在此处输入图片描述

答案3

以下是使用 的丰富多彩的建议tcolorbox

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

\usepackage{showframe}
\usepackage[colorlinks=true]{hyperref}

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

在此处输入图片描述

随意调整。这里也可以列出引文。看起来就像这样:

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

\usepackage{showframe}
\usepackage[colorlinks=true]{hyperref} 

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

在此处输入图片描述

没有颜色和右侧的数字,也没有数字:

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

\usepackage{showframe}
\usepackage[colorlinks=true]{hyperref}

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

在此处输入图片描述

答案4

如果您希望新报价具有与常规报价相同的格式,我会执行以下操作:

\documentclass{memoir}
\usepackage{lipsum}
\usepackage{environ}
\newcounter{quote}
\NewEnviron{myquote}%define new quote env
{%
\par\noindent\refstepcounter{quote}%
\parbox{0.9\textwidth}{%
\begin{quote}\BODY%
\end{quote}%
}\hfill\parbox{.1\textwidth}{(\thequote)}}

\begin{document}
This is an example of what the subject might be.    
\begin{myquote}\label{example}
\lipsum[1][1-2]
\end{myquote}

Some text in-between.

\begin{quote}
\lipsum[1][1-2]
\end{quote}

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

\end{document}

结果显示如下:

在此处输入图片描述

相关内容