在引用前自动插入“Ref.”字样

在引用前自动插入“Ref.”字样

我想问一下,是否有一种简单的方法可以在我的任何引用前自动包含“Ref.”字样,即如果我这样做

Have a look in \cite{pub1}

然后出现

Have a look in Ref. [1]

答案1

无论您使用哪个参考包,以下内容都应该有效:

在此处输入图片描述

\documentclass{article}
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\LetLtxMacro\oldcite\cite% Store \cite in \oldcite
\renewcommand*{\cite}{Ref.~\oldcite}% Prepend \cite with Ref.~
\begin{document}
See \cite{abc}.
\begin{thebibliography}{x}
  \bibitem{abc} Some reference
\end{thebibliography}
\end{document}

方法是首先\cite通过其他宏保存\LetLtxMacro然后将其添加Ref.~到前面。或者,xpatch也可以使用以下方式添加<code>到强大的命令中:

\xpretocmd{\cite}{Ref.~}{}{}% \xpretocmd{<cmd>}{<code>}{<success>}{<failure>}

答案2

如果您正在使用,biblatex您可以将以下修改放入您的序言中。

\DeclareCiteCommand{\cite}[Ref.~\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

如果你不想覆盖的标准行为\cite,请使用

\DeclareCiteCommand{\refcite}[Ref.~\mkbibbrackets]
      {\usebibmacro{prenote}}
      {\usebibmacro{citeindex}%
       \usebibmacro{cite}}
      {\multicitedelim}
      {\usebibmacro{postnote}}

反而。

完整的 MWE

\documentclass[ngerman, a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{xpatch}% to patch the editor macros
\usepackage[style=numeric, backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\DeclareCiteCommand{\cite}[Ref.~\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{filecontents}{\jobname.bib}
@article{testart,
  author        = {Arnold Uthor and William Riter},
  title         = {A Very Interesting Article},
  journal       = {Journal of Articles},
  volume        = {7},
  number        = {3},
  pages         = {1-5},
  date          = {2010},
}
@book{testbook,
  author        = {Arnold Uthor},
  title         = {A Book},
  subtitle      = {Some Books Have Subtitles},
  date          = {2013},
  publisher     = {Peter Ublisher \& Co.},
  location      = {Place City},
}
\end{filecontents}


\begin{document}
  Let's cite \cite{testbook} and \cite{testart}.
  \nocite{*}
  \printbibliography
\end{document}

然后产生 在此处输入图片描述


编辑

根据@henrique的建议,我们还可以reference通过以下方式定义一个 bibstring

\NewBibliographyString{reference}
\DefineBibliographyStrings{english}{%
  reference = {ref\adddot},
}

并将其用于我们的定义中\refcite

\newrobustcmd*{\Refcite}{\bibsentence\refcite}
\DeclareCiteCommand{\refcite}[\bibstring{reference}\addnbspace\mkbibbrackets]% or \addnbthinspace
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

现在就可以像使用所有其他/命令一样\refcite使用。\Refcite\cite\Cite

\documentclass[american, a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=numeric, backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\NewBibliographyString{reference}
\DefineBibliographyStrings{english}{%
  reference = {ref\adddot},
}

\newrobustcmd*{\Refcite}{\bibsentence\refcite}
\DeclareCiteCommand{\refcite}[\bibstring{reference}\addnbspace\mkbibbrackets]% or \addnbthinspace
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{filecontents}{\jobname.bib}
@article{testart,
  author        = {Arnold Uthor and William Riter},
  title         = {A Very Interesting Article},
  journal       = {Journal of Articles},
  volume        = {7},
  pages         = {1-5},
  date          = {2010},
}
@book{testbook,
  author        = {Arnold Uthor},
  title         = {A Book},
  date          = {2013},
  publisher     = {Peter Ublisher \& Co.},
  location      = {Place City},
}
\end{filecontents}

\begin{document}
  Let's cite \refcite{testbook} and \refcite{testart}. \Refcite{testbook} and \refcite{testbook}.
  \nocite{*}
  \printbibliography
\end{document}

产量 在此处输入图片描述

相关内容