tex >> labels in bibliography with natbib's authoryear mode

by Stefan Rank » Tue, 15 Jul 2008 16:11:38 GMT

Hi,

natbib in numbers mode puts [1] in front of the entries in the
bibliography. In authoryear mode there is no label.

I'd like to have authoryear citations, but with a label in front of the
bibitems (the one that I would get with \citep{} in the text).

I can get *some* label by redefining NAT@biblabel::

\makeatletter \renewcommand\NAT@biblabel[1]{[#1]} \makeatother

However, the argument #1 is only the sequence number of the bibitem AFAIK.

Did anybody do something like that already?
Or does anybody have an idea how to get from that argument to the
authoryear-type label?

cheers,
stefan


tex >> labels in bibliography with natbib's authoryear mode

by vojta » Tue, 15 Jul 2008 18:46:54 GMT

In article < XXXX@XXXXX.COM >,



Try \bibliographystyle{abbrvnat}

See, for example, page 27 of:

http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.pdf

--Paul Vojta, XXXX@XXXXX.COM


tex >> labels in bibliography with natbib's authoryear mode

by Stefan Rank » Tue, 15 Jul 2008 19:42:37 GMT

on 15.07.2008 12:46 Paul Vojta said the following:


Thanks for the tip. But that does not achieve what I aim for.
abbrvnat still has no label at the beginning of the bibitem if used with
the authoryear option for natbib.

BTW, the bibstyles.pdf messes up the labels for nearly all the
authoryear styles, see:

http://keizai.xrea.jp/latex/bib/sample/sample-abbrvnat.pdf

for what abbrvnat looks like.

cheers,
stefan


tex >> labels in bibliography with natbib's authoryear mode

by Ulrike Fischer » Tue, 15 Jul 2008 23:16:51 GMT

Am Tue, 15 Jul 2008 10:11:38 +0200 schrieb Stefan Rank:


No. But perhaps this does what you want:

\makeatletter
\def\@lbibitem[#1]#2{%
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}{[#1]}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother

As you didn't provide a minimal example (which would e.g. have showed
what options and bibstyle you are using) this is completly untested.



--
Ulrike Fischer


tex >> labels in bibliography with natbib's authoryear mode

by Stefan Rank » Wed, 16 Jul 2008 03:49:56 GMT

Hi,

on 15.07.2008 17:16 Ulrike Fischer said the following:
<snip>
<snip>

yet it works. Thanks for that, it's nearly what I want.
Below is a minimal example. The [#1] results in the full natbib
authoryear info:
[Walrus et al.(2004)Walrus, Humpty, Queen, and Cat].
I'd like to reduce that to the output that \citep produces:
[Walrus et al. 2004].
I tried to find the relevant code in natbib.sty but I am lost in the
definition of \NAT@citex

I would be grateful for any suggestions.

cheers,
stefan

----------8<---------8<------------

\documentclass{article}

\usepackage[sort]{natbib}
\setcitestyle{authoryear,square,semicolon,aysep={},yysep={,}}

\makeatletter
\def\@lbibitem[#1]#2{%
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}{[#1]}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother

\begin{document}

test citation: \citep{WalrusETAL2004}

\begin{thebibliography}{28}

\bibitem[Walrus et~al.(2004)Walrus, Humpty, Queen, and Cat]{WalrusETAL2004}
The Walrus, Dumpty Humpty, Red Queen, and Cheshire Cat.
\newblock What is in a classic, 2004.

\end{thebibliography}


\end{document}



tex >> labels in bibliography with natbib's authoryear mode

by Ulrike Fischer » Wed, 16 Jul 2008 16:04:14 GMT

Am Tue, 15 Jul 2008 21:49:56 +0200 schrieb Stefan Rank:



natbib obviously splits the string with \NAT@parse and \NAT@split. But
it is difficult to find out what argument they exactly expect. You can
try to write your own splitting command:

\makeatletter

\def\mysplit#1)#2\@nil{%
\def\@mysecondoftwo{#2}%
\ifthenelse{\equal{@@arg}{#1}}
{% no year, take everything
\def\@mycitep{#1}}
{% take the part until and including year
\def\mycitep{#1)}}}

\def\@lbibitem[#1]#2{%
\mysplit#1)@@arg\@nil
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}{[{\mycitep}]}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother


--
Ulrike Fischer


tex >> labels in bibliography with natbib's authoryear mode

by Stefan Rank » Wed, 16 Jul 2008 17:44:35 GMT

on 16.07.2008 10:04 Ulrike Fischer said the following:
<snip>
<snip>

Thanks again, I experimented a bit, and went with a simple version of
using \citep{#2} iself in the bibitem, see below.
This has the unfortunate side-effect that, if you use hyperref, the
label is a link to itself (not too bad) and there is an additional not
very helpful back reference if you use pagebackref=true (rather bad).

stefan

----------

\documentclass{article}
\usepackage[pagebackref=true]{hyperref}
\usepackage[sort]{natbib}
\setcitestyle{authoryear,square,semicolon,aysep={},yysep={,}}

% the following redefines natbib internals to add a \citep like label
% for authoryear citations in the bibliography, as a side-effect the
% labels are links to themselves if hyperref is used.
\makeatletter
\def\@lbibitem[#1]#2{%
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}\citep{#2}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother

\begin{document}

test citation: \citep{WalrusETAL2004}

\clearpage % for demonstrating the problem with pagebackref

\begin{thebibliography}{28}

\bibitem[Walrus et~al.(2004)Walrus, Humpty, Queen, and Cat]{WalrusETAL2004}
The Walrus, Dumpty Humpty, Red Queen, and Cheshire Cat.
\newblock What is in a classic, 2004.

\end{thebibliography}

\end{document}


Similar Threads

1. natbib and label format in bibliography

Hi,

I recently switched from named to natbib (better compatibility with
hyperref) and still have one issue which I couldn't solve with the help
of manuals or newsgroup-search. I use:

\usepackage[authoryear]{natbib}
...
\bibliographystyle{plainnat}
\bibliography{thesis}

and my citations look like:

"... closed-world assumption [Reiter, 1978] is acknowledged as ..."

So far so good. Now in the bibliography, instead of

Raymond Reiter. On Closed World Data Bases. In Herve Gallaire and Jack
Minker, editors, Logic and Data Bases, pages 119--140. Plenum Press,
New York, 1978.

I would like to see

[Reiter, 1978] Raymond Reiter. On Closed World Data Bases. In Herve
Gallaire and Jack Minker, editors, Logic and Data Bases, pages
119--140. Plenum Press, New York, 1978.

i.e., also the citation label (like in the named-style). Is there any
way to achieve this with natbib?

thnx and best regards,
roman

2. natbib in authoryear, problems "compressing" refs with same first author and year

3. BibTex query: sorting of references in authoryear style with "natbib" package

Hi,

I'm using BibTex to generate a bibliography. Let's call the
bibliography mybib. I use the "natbib" package and want the references
displayed in "authoryear" style.

When I run Latex and BibTex and then Latex again (twice) on my  .tex
source file (let's call it Main.tex), I get this problem:

All the  books get listed first by year of publication,
All the articles and miscellaneous other entries get listed afterwards
(by year).

To clarify: the sorting order for the books seems to be the year of
publication (not author's name). Also all the books get listed
separately from the other entries.

But I want the usual authoryear style. I was under the impression that
the "natbib" package does this automatically.

 I've racked my brained and still can't figure out why the sorting is
getting messed up like this. Can someone help me "sort it out"?
Thanks,

Other facts which may or may not be relevant:

i) I use the \nocite{*} command to cite all my references.

ii) The following appears at an appropriate place in my Main.tex file
\bibliography{mybib}
\bibliographystyle{plainnat}

iii) I use no cross-references (in my bibliography database)

iv) I use the Emacs editor and have sorted out my bibliography entries
so the database itself (i.e. mybib.bib) is already in desired
alphabetical order by author name (be it book or article).

4. Biblatex [Was: Merge authoryear-ibid and authoryear-comp]

5. Merge authoryear-ibid and authoryear-comp

Hi!

Is there a (simple?) way to merge the functionalities of the
authoryear-ibid and authoryear-comp citation styles?


For example, with

   The first citation is \parencite{name1_2004,name1_2005) and the
   second citation is \parencite{name1_2004).


I want to obtain something like :

  The first citation is (Name1,2004,2005) and the second citation is
  (ibid., 2004).


Thanx in advance for your help!
jpg


jpg
-- 
 XXXX@XXXXX.COM 
       ^^^^year

6. multibib + natbib -- numerical labels are ambiguous

7. [hyperref, pdftex, natbib] www link in the bibliography

I'd like to generate a www (or file) link in the bibliography part when 
I specify an URL field in the file.bib.
The idea is to easily recover from the document.pdf the cited articles 
when they are available on the web (or locally on the computer).

Does anybody know or have an idea how to do that ?

8. HELP! Natbib bibliography with date after author