5

I would like to ask if there is an easy way to auto-include a "Ref." word before any of my citations ie if I do

Have a look in \cite{pub1}

then to show up like

Have a look in Ref. [1]
1
  • 2
    I would suggest not redefining the (simple) \cite command: what if you later realize that you want to cite something without the "Ref." string? then you won't be able to! So I suggest creating a new command with the requested functionality and using that instead. – nplatis Sep 16 '13 at 22:23
6

Regardless of the reference package you're using, the following should work:

enter image description here

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

The approach is to firstly save \cite in some other macro via \LetLtxMacro and then prepend Ref.~ to it. Alternatively, xpatch can also be used to prepend <code> to robust commands using

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

If you are using biblatex you can put the following modification into your preamble.

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

if you do not want to override the standard behaviour of \cite, go with

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

instead.

The full 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}

then yields enter image description here


Edit

As per @henrique's suggestion, we can also define a bibstring reference via

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

and use that in our definition of \refcite

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

One can now use \refcite and \Refcite just like all the other \cite/\Cite commands.

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

yields enter image description here

1
  • 1
    This might be overkill, but I'd add "Ref." as a bibstring in order to have language-specific citations (mostly for case-sensitive citation commands such as \cite and \Cite). – henrique Sep 16 '13 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.