3

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
  • I'm not sure I know how to interpret your objective, viz., to "list both citations properly under the one author". Please provide an MWE (minimum working example) that illustrates what you've done so far, including information about the bibliography style file you use. E.g., does it generate author-year or numerical citations? It would also be helpful if you'd provide information on the two bib items you're citing and whose references you're trying to modify. – Mico Mar 9 '13 at 20:26
  • I've added an MWE. I didn't quite answer your questions but hopefully what I added is clear as to what I'm trying to do and what is currently happening. – bfootdav Mar 9 '13 at 21:02
3

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 with plainnat and shows how the file plainnat.bst may be modified to achieve your typesetting objectives. Hopefully, the bibliography style you're actually working with isn't too different from plainnat.

  1. Start by creating a copy of plainnat.bst; save the copy as, say, myplainnat.bst. (Never edit the original files.)

  2. Open the file myplainnat.bst with your favorite text editor.

  3. Locate the function article. (This function starts on lin 699 in my copy of plainnat.) Immediately before this function, insert the following lines of code:

    STRINGS {oldname}
    
    FUNCTION {name.or.dash}
    { 's :=
       oldname empty$
         { s 'oldname := s }
         { s oldname =
             { "---{}---{}---" }
             { s 'oldname := s }
            if$
         }
       if$
    }
    

    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.

  4. Next, locate each of the ten [10!] instances of the following line of code in myplainnat.bst:

      author format.key output
    

    and insert the instruction

      name.or.dash
    

    on a line by itself immediately following each of the author format.key output lines.

  5. Locate the two instances of the following five lines of code, in the functions book and inbook:

    { format.editors "author and editor" output.check
       editor format.key output
    }
    { format.authors output.nonnull
      crossref missing$
    

    and replace them with

    { format.editors "author and editor" output.check
      editor format.key output
      name.or.dash
     }
    { format.authors output.nonnull
      name.or.dash
      crossref missing$
    

    I.e., insert the instruction name.or.dash as indicated in each of two instances.

  6. In the function proceedings, locate the line

    editor format.key output
    

    and insert the line

    name.or.dash
    

    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.

  7. 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.

  8. Be sure to use the instruction \bibliographystyle{myplainnat} from now on.

Happy TeXing!

| improve this answer | |
  • Thank you so much for that -- I had given up hope. I am using a custom style and just put plainnat in the MWE since I didn't think that was where the problem was nor would anyone have my custom style so the MWE would fail for them. Anyway, I am using a customized plainnat so your instructions remained the same and it works like a charm, thanks again! – bfootdav Mar 12 '13 at 14:06
  • 1
    @bfootdav - You're most welcome! I'm glad that the proposed solution meets your needs. – Mico Mar 12 '13 at 14:22

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.