BibTeX, biblatex and biberHow to print the citation key within the bib output

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
alex2747
Posts: 18
Joined: Mon Apr 05, 2010 10:39 pm

How to print the citation key within the bib output

Post by alex2747 »

Hi,

is there a way I can print the citation key as part of the output of a citation? For example, if my bib entry is something like:

Code: Select all

@ARTICLE{Dey2001,
  author = {A. K. Dey},
  title = {Understanding and Using Context},
  journal = {Personal Ubiquitous Computing},
  year = {2001},
  volume = {5},
  pages = {4--7},
  number = {1},
  publisher = {Springer-Verlag} 
}
I would like to have something like the following generated:
A. K. Dey, Understanding and Using Context in Personal Ubiquitous Computing 5 (2001), Springer-Verlag, Dey2001
I tried to change my bst file to include something like:

Code: Select all

FUNCTION {format.id}
{ key empty$
    { "" }
    { key }
  if$
}
but that key seems not to be the citation key. Any idea how to achieve that?

Thanks
Alex

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

How to print the citation key within the bib output

Post by Montag »

For starters I can say that the use of the natbib-package provides such formats. The interesting part begins on page 6 of the file natbib.pdf.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
alex2747
Posts: 18
Joined: Mon Apr 05, 2010 10:39 pm

Re: How to print the citation key within the bib output

Post by alex2747 »

Hi,

I managed to take a standard bst file and to make some other changes to that file. I rather do not want to use a new package, to avoid looking into that issue and start all over again.
Is there no other simple way to have the citation key printed in the reference without natbib?

Thanks
Alex
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Re: How to print the citation key within the bib output

Post by Montag »

Hm ... ok.
If I understand you correctly, you want to print the citation key for all inline citations, right?
You could load natbib and use its features just for that.

You could still use your own .bst-file/bibliography-style for your bibliography.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
alex2747
Posts: 18
Joined: Mon Apr 05, 2010 10:39 pm

How to print the citation key within the bib output

Post by alex2747 »

Hi,

enrico wrote: If I understand you correctly, you want to print the citation key for all inline citations, right?
Yes, I think that is right
enrico wrote: You could load natbib and use its features just for that.

You could still use your own .bst-file/bibliography-style for your bibliography.
Hm, sure, that would be an option. So any suggestions what to put in to my bst file?

Thanks
Alex
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

How to print the citation key within the bib output

Post by Montag »

alex2747 wrote:
enrico wrote: You could load natbib and use its features just for that.

You could still use your own .bst-file/bibliography-style for your bibliography.
Hm, sure, that would be an option. So any suggestions what to put in to my bst file?
You could use the style you already made? :) You said:
alex2747 wrote:I managed to take a standard bst file and to make some other changes to that file.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
alex2747
Posts: 18
Joined: Mon Apr 05, 2010 10:39 pm

Re: How to print the citation key within the bib output

Post by alex2747 »

yes, I made some changes to that file, but I do not know what changes I need to make in order to have the citation key given as well in a citation.

Do you know how to do that or what I need to put into the bst file???

Thanks
Alex
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

How to print the citation key within the bib output

Post by Montag »

alex2747 wrote:yes, I made some changes to that file, but I do not know what changes I need to make in order to have the citation key given as well in a citation.

Do you know how to do that or what I need to put into the bst file???

Thanks
Alex
Come on, I already told you: For the inline citations and their different versions (with or without key ... and so on => "styles", if you will), you would have to consult the file called natbib.pdf (see above). If you decide to give natbib a try, that is.

The bst-file will be used for your bibliography.
AFAIK.
That's how I got to know about the use of a .bst-file.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
olofos
Posts: 56
Joined: Tue Nov 24, 2009 10:37 pm

How to print the citation key within the bib output

Post by olofos »

To get the citation key in the .bst file you use the function cite$.

The 'key' field in the bib-file is used, eg, by the alpha style to generate a label for entries without an author/editor. It is not related to the key/label used for citing the entry.

A nice reference for anything related to bibtex and the details of coding style files is the Tame the BeaST document by Nicolas Markey.
alex2747
Posts: 18
Joined: Mon Apr 05, 2010 10:39 pm

How to print the citation key within the bib output

Post by alex2747 »

Hi,
olofos wrote:To get the citation key in the .bst file you use the function cite$.

Thanks a lot; this was exactly what I needed. Nothing less, nothing more.

Cheers
Alex
Post Reply