Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to use natbib and other attempts but for vain. I would like to produce a cite key which is identical to the BibTeX entry. For example, if I have a BibTeX entry Bt98, then I want \cite{Bt98} to produce something like [Bt98].

Any ideas how can I accomplish this?

share|improve this question
    
Should be easy to realize. Do you need the package natbib anyway? –  Herbert Jan 7 '11 at 9:43
    
@Herbert: At the moment I don't need natbib, I just tried to use it in order to produce the desired result. I'd be happy to do it without it. –  Dror Jan 7 '11 at 9:52
add comment

3 Answers

up vote 17 down vote accepted

Here's a biblatex solution with a properly formatted bibliography.

\documentclass{article}

\usepackage[style=alphabetic,sorting=debug]{biblatex}

\DeclareFieldFormat{labelalpha}{\thefield{entrykey}}
\DeclareFieldFormat{extraalpha}{}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{whatever,
  author = {Author, A.},
  year = {2001},
  title = {Testing the effects of biblatex styles on bibliography formatting},
}
@misc{B02f,
  author = {Buthor, B.},
  year = {2002},
  title = {First},
}
@misc{B02s,
  author = {Buthor, B.},
  year = {2002},
  title = {Second},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\nocite{*}

\begin{document}

\printbibliography

\end{document}

enter image description here

(The filecontents environment is only used to include some external files directly into the example, so that it compiles. It is not necessary for the solution.)

share|improve this answer
    
Thanks a lot! This seems like the solution for my setting. One remark though, I was not familiar with the package filecontents, and it made your answer unclear at first sight. –  Dror Jan 7 '11 at 17:24
    
@Dror: I'm sorry I didn't bother to explain filecontents. –  lockstep Jan 7 '11 at 17:30
    
No worries! At first it made me insert a lengthy edit to my original question, but then somehow I figured it out. So now it seems OK. I have to admit, I thought the solution would be simpler. Some sort of predefined style. –  Dror Jan 7 '11 at 17:45
    
If you're starting from bibtex, you still do this using biblatex by adding backend=bibtex in the arguments to \usepackage{biblatex}. If you're relying on natbib as well, the only way I could get the list of refs I needed was to take a copy of my source and strip all the natbib stuff, replacing it with biblatex as above. –  Chris H Sep 18 '13 at 15:09
add comment

without natbib, don't know if it sjould be the same in the bibliography??

\documentclass{article}


\makeatletter
\def\@citex[#1]#2{\leavevmode
  \if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \@cite{#2}{#1}}
\makeatother


\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{whatever,
  author = {Author, A.},
  year = {2001},
  title = {Testing the effects of biblatex styles on bibliography formatting},
}

@misc{B02f,
  author = {Buthor, B.},
  year = {2002},
  title = {First},
}

@misc{B02s,
  author = {Buthor, B.},
  year = {2002},
  title = {Second},
}
\end{filecontents}


\begin{document}

foo\cite{whatever} and bar\cite{B02s}

\bibliographystyle{alpha}
\bibliography{\jobname}


\end{document}
share|improve this answer
    
Your changes affect the in-text-citation labels, but not the labels and the sorting order in the bibliography. –  lockstep Jan 7 '11 at 12:30
1  
@lockstop: I know, otherwise I hadn't ask if it should be ion the bib too ... ;-) And the question was to change \cite ... –  Herbert Jan 7 '11 at 12:53
add comment

biblatex with, for example, the style=draft option will do this.

share|improve this answer
    
has also an effect to the bibliography –  Herbert Jan 7 '11 at 11:31
    
+1 for pointing me to sorting=debug. –  lockstep Jan 7 '11 at 12:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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