4

I am looking to add a prefix, say P to the reference list, so:

(1) the list will appear like

References

[P1] ...

[P2] ..

(2) when I cite them they appear as [P1] also.

I added the following to the preamble

\makeatletter

\def\@biblabel#1{[P#1]}

\makeatother

but this achieves the first requirement, not the second. So now when I cite the citation still appears as [1].

How to remedy this?

Thanks

TeXnician
  • 33,589
M.A
  • 255
  • 2
  • 7
  • 1
    Are you really using biblatex as your tagging suggests? \def\@biblabel#1{[P#1]} should not work in that case. You would use refcontexts and labelprefix with biblatex. – moewe Aug 30 '17 at 21:11
  • Assuming you're actually using BibTeX, not biblatex, which bibliography style do you employ? Do you load a citation management package such as cite or natbib? – Mico Aug 30 '17 at 21:52

2 Answers2

9

With current versions of biblatex, you need to use refcontexts for labelprefix

\documentclass{article}

\usepackage[backend=biber,defernumbers=true]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
  @book{lamport1994latex,
    title={LATEX: a document preparation system: user's guide and reference manual},
    author={Lamport, Leslie},
    year={1994},
    publisher={Addison-wesley}
  }
  @book{mittelbach2004latex,
    title={The LATEX companion},
    author={Mittelbach, Frank and Goossens, Michel and Braams, Johannes and Carlisle, David and Rowley, Chris},
    year={2004},
    publisher={Addison-Wesley Professional}
  }
\end{filecontents*}

\begin{document}
\newrefcontext[labelprefix=P]

\cite{lamport1994latex} is the one we started our journey with. Then
we also got~\cite{mittelbach2004latex}.  Both
\cite{lamport1994latex,mittelbach2004latex} are good ones.

\printbibliography
\end{document}
moewe
  • 175,683
6

This solution works only with older version (3.4) of biblatex

I think that you are looking for the following solution:

\documentclass{article}

\usepackage[backend=bibtex]{biblatex}


\addbibresource{\jobname.bib}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
  @book{lamport1994latex,
    title={LATEX: a document preparation system: user's guide and reference manual},
    author={Lamport, Leslie},
    year={1994},
    publisher={Addison-wesley}
  }
  @book{mittelbach2004latex,
    title={The LATEX companion},
    author={Mittelbach, Frank and Goossens, Michel and Braams, Johannes and Carlisle, David and Rowley, Chris},
    year={2004},
    publisher={Addison-Wesley Professional}
  }
\end{filecontents*}

\pagenumbering{gobble}

\begin{document}

\cite{lamport1994latex} is the one we started our journey with. Then
we also got~\cite{mittelbach2004latex}.  Both
\cite{lamport1994latex,mittelbach2004latex} are good ones.

\printbibliography[prefixnumbers=P]

\end{document}

enter image description here


For details, please see page 76 of the biblatex documentation.

Masroor
  • 17,842
  • With newer versions of biblatex prefixnumbers has been renamed to labelprefix, the option can now only be used from a refcontext command. Your answer only works with outdated version of the software. – moewe Aug 31 '17 at 05:55
  • The fact that \def\@biblabel#1{[P#1]} solved one part of the problem shows that the OP can't be using biblatex. With biblatex, \def\@biblabel#1{[P#1]} does nothing. – moewe Aug 31 '17 at 05:56
  • @moewe Sorry, did not note that. Actually, without a MWE, we can only make educated guesses, we can only presume and sometimes we can only conclude about the real scenario. And the askers seem to be real misers when putting their own codes in questions. They do not understand that they need to help us helping them. May be with this answer, the OP will decide switching to biblatex. – Masroor Aug 31 '17 at 06:12
  • Yes we are all guessing. But the problem with this answer is that it only works for outdated versions of biblatex. I wouldn't have complained otherwise, for the current version 3.7, however, this answer is practically useless. – moewe Aug 31 '17 at 06:34
  • @moewe I understand your point. In my machine (Ubuntu 16.04, updated regularly), version of biblatex is 3.4. Anyway, I am going to manually update the package and then edit my answer. – Masroor Aug 31 '17 at 06:43
  • 1
    It is a well-'loved' feature that Ubuntu and other Linux systems often ship stable (i.e. older or outdated) TeX live versions in their package repositories. If you want to live on the cutting edge, go with a vanilla TeX live (https://tex.stackexchange.com/q/1092/35864). Manually updating certain packages risks version incompatibilities. (Certainly between biblatex and Biber, likely with custom biblatex styles, maybe with other packages as well.) – moewe Aug 31 '17 at 06:59
  • 1
    @moewe With my other tasks, which are more pressing at this moment, it will mean a bit too much for me to carry out the LaTeX system upgrade. Would it be possible for you to post a solution based on the latest version of biblatex. Thanks. I have put the necessary warning in my solution. – Masroor Aug 31 '17 at 16:32