I'm using natbib with a custom bibliography style and so would rather not change away from natbib if I can help it. I have one author with two citations and I just want the References section to list both citations properly under the one author. I cannot figure out how to do this as currently the output treats each citation as belonging to a different author (as a different entry). I have not provided a MWE as it does not seem necessary in this case but I can if need be.
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{plainnat}
\begin{document}
Here is text \citep[p.1]{authorA}. And then more from same author \citep[p.1]{authorB}
\clearpage
\bibliography{bib}{}
\end{document}
And the bib file:
@book{authorA,
author={Smith, John},
title={Book},
}
@book{authorB,
author={Smith, John},
title={Other Book},
}
I would like the "References" section at the end of the article to look something like this:
Smith, John. Book
------Other Book
Instead of like this:
Smith, John. Book
Smith, John. Other Book
Best Answer
Note that the formatting of the bibliographic entries in the References section isn't actually governed by
natbib
;natbib
is mainly a citation management system that can handle various numeric and authoryear citation styles. The formatting of the bib entries -- including the replacement of a repeated author (or authors) by a long dash -- is determined by the bibliography style you specify.You mention in the first paragraph of your question that you use a custom bibliography style. However, in the MWE you state that you use the bibliography style
plainnat
. The following code assumes you're working withplainnat
and shows how the fileplainnat.bst
may be modified to achieve your typesetting objectives. Hopefully, the bibliography style you're actually working with isn't too different fromplainnat
.Start by creating a copy of
plainnat.bst
; save the copy as, say,myplainnat.bst
. (Never edit the original files.)Open the file
myplainnat.bst
with your favorite text editor.Locate the function
article
. (This function starts on lin 699 in my copy ofplainnat
.) Immediately before this function, insert the following lines of code:You didn't specify how long the dashes that replace the author's name (or authors' names) should be. In the code above, I use three consecutive em-dashes. Feel free to change this setup to suit your typographic needs and preferences.
Next, locate each of the ten [10!] instances of the following line of code in
myplainnat.bst
:and insert the instruction
on a line by itself immediately following each of the
author format.key output
lines.Locate the two instances of the following five lines of code, in the functions
book
andinbook
:and replace them with
I.e., insert the instruction
name.or.dash
as indicated in each of two instances.In the function
proceedings
, locate the lineand insert the line
immediately following that line.
If you've made all of these edits, you should have sixteen [16] instances of the string "name.or.dash" in your
.bst
file.Save the file
myplainnat.bst
either in the directory that contains your main.tex
file or in a directory that's in the search path of your TeX distribution.Be sure to use the instruction
\bibliographystyle{myplainnat}
from now on.Happy TeXing!