2

Let's say I have an entry in my bibliography that looks like

@book{BOSCH,
    Author = {Bosch and Lutkebohmert and Raynaud},
    Publisher = {Springer},
    Title = {N{\'e}ron Models},
    Year = {1990}}

When I cite it using \cite{BOSCH} I get [1] in the PDF.

I would like, instead, to get [BOSCH]. Is this possible?

  • As a new user you should become familiar with some convention of this site. You can have a look at our starter guide. Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Marco Daniel Dec 18 '13 at 14:36
  • You can probably get it using the default debug style, but I wouldn't recommend that as the real solution. See section 3.3.1 of the biblatex guide for the default styles, and section 4.3 for how to write your own citation styles. – Willie Wong Dec 18 '13 at 14:36
  • Do you want to use the last name of the first author or the actual cite key of the item? What exactly do you want your bibliography to look like? – moewe Dec 18 '13 at 18:16
  • I would like the cite key of the item to appear instead of the number. Also, in the bibliography I'd like to have "[CITE KEY] - Entry" in place of "[1] - Entry" – Abramodj Dec 18 '13 at 18:24
4

EDIT

A shorter solution is to modify the alphabetic style. Just force the label to be set to citekey.

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{citekey}
  }
}

And we're done.

\documentclass{article}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,url=true,style=alphabetic]{biblatex}
\usepackage{filecontents}
\addbibresource{biblatex-examples.bib}

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{citekey}
  }
}

\begin{document}
  \cite{wilde,westfahl:space}
  \printbibliography
\end{document}

enter image description here


Initial solution

You might like this slight modification of the numeric style.

We make the cite bibmacro just print the entrykey.

\DeclareFieldFormat{key}{#1}
\renewbibmacro*{cite}{%
  \printtext[bibhyperref]{\printfield[key]{entrykey}}}

We also have to redefine the bibliography.

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield[key]{entrykey}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

I can't help but feel that the label width thing could be improved, but for very long labels that could also go awry.

\documentclass{article}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,url=true,style=numeric]{biblatex}
\usepackage{filecontents}
\addbibresource{biblatex-examples.bib}

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield[key]{entrykey}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

\DeclareFieldFormat{key}{#1}
\renewbibmacro*{cite}{%
  \printtext[bibhyperref]{\printfield[key]{entrykey}}}

\begin{document}
  \cite{wilde,westfahl:space}
  \printbibliography
\end{document}

enter image description here

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.