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 am using the natbib package with a bibliography style very similar to humannat. I would like to get a long dash instead of the full author name in multiple references where the author is the same. I would be grateful for any suggestions.

share|improve this question
2  
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Guido Nov 3 '12 at 23:27
add comment

1 Answer 1

up vote 12 down vote accepted

The bibliography style file humannat.bst has been around more or less unchanged for at least twenty years. As such, my first inclination is to recommend that you not bother modifying the file. Instead, select a more modern bibliography style file, preferably one that already knows about such "new-fangled" [!] fields such as url and doi. The header information in the file humannat.bst states that it is based on the (by now equally obsolete) apalike bibliography style. Thus, you may want to start your search for a more recent bibliography style with apa.bst and apa6.bst. Just a thought.

If you are, however, committed to using the humannat bibliography style, you could proceed as follows to instruct BibTeX to replace instances of repeated authors (and editors) with long dashes:

  • Make a copy of humannat.bst and call it, say, myhumannat.bst. Do not edit/overwrite existing files of this nature.

  • Open the file myhumannat.bst in your favorite text editor and search for the function named article. (It starts on line 586 in my local copy of this file.)

  • Just ahead of 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 in your question just how long the "dash" should be. I've chosen a length of "three em-dashes" in the function above. If you'd rather have a dash of only one or two em-dashes in length, you are free to modify the function in the obvious manner.

  • Next, there should be 11 instances of the following two lines of code in humannat.bst (in the functions article, booklet, incollection, inproceedings, manual, mastersthesis, misc, phdthesis, proceedings, techreport, and unpublished, respectively):

    author format.key output    % special for
    output.year.check       % apalike
    

    In all of these instances, insert the line

    name.or.dash
    

    between these two lines of code.

  • The functions that need further, special attention are those for entries of type @book and @inbook, because they have to deal with both repeated author(s) and repeated editor(s). To modify the book function, search for the following lines of code:

    FUNCTION {book}
    { output.bibitem
      author empty$
        { format.editors "author and editor" output.check
          editor format.key output
        }
        { format.authors output.nonnull
          crossref missing$
        { "author and editor" editor either.or.check }
        'skip$
          if$
        }
    

    and replace the entire block with

    FUNCTION {book}
    { output.bibitem
      author empty$
        { format.editors "author and editor" output.check
          editor format.key output
          name.or.dash
        }
        { format.authors output.nonnull
          name.or.dash
          crossref missing$
        { "author and editor" editor either.or.check }
        'skip$
          if$
        }
    

    Note the two new lines that invoke the name.or.dash function.

  • Give the same search-and-replace treatment to the first few lines of the inbook function. Of course, if you're sure you won't ever have entries of type @inbook in your bib files, you may skip this step.

  • Save the file myhumannat.bst and update the TeX filename database in a way that's appropriate for your TeX distribution, so that BibTeX can find it when LaTeX encounters the instruction

    \bibliographystyle{myhumannat}
    

Happy (Bib)TeXing!

share|improve this answer
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.