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.
-
3Welcome 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 03 '12 at 23:27
1 Answers
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.bstand call it, say,myhumannat.bst. Do not edit/overwrite existing files of this nature.Open the file
myhumannat.bstin your favorite text editor and search for the function namedarticle. (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 functionsarticle,booklet,incollection,inproceedings,manual,mastersthesis,misc,phdthesis,proceedings,techreport, andunpublished, respectively):author format.key output % special for output.year.check % apalikeIn all of these instances, insert the line
name.or.dashbetween these two lines of code.
The functions that need further, special attention are those for entries of type
@bookand@inbook, because they have to deal with both repeated author(s) and repeated editor(s). To modify thebookfunction, 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.dashfunction.Give the same search-and-replace treatment to the first few lines of the
inbookfunction. Of course, if you're sure you won't ever have entries of type@inbookin your bib files, you may skip this step.Save the file
myhumannat.bstand 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!
- 506,678
-
Just came across this answer. Perfect for my problem with one caveat. Modifying
humannat.bst, is there a way to omit the dash? The style I'm trying to emulate (Society for American Archaeology) lists references for an author under a single author line. Basically I need to have the reference block as an indented list under the author. I tried replacing the code"---{}---{}---"with"{}{}"but that leaves the reference block un-indented (i.e. in line with the author) instead of skipping the author line, and"\leavemode\nopagebreak\newline"works but adds an extra line between references. – JSCard Dec 28 '15 at 21:39 -
@Scard - Have you tried
\phantom{---{}---{}---}(inside the functionname.or.dash)? – Mico Dec 29 '15 at 00:24 -
No I hadn't, but it still leaves the hanging 1st line indent like the
" {} {} "does. I need the references all indented and left aligned beneath the author name. This is my first attempt at working with the.bstfile directly so I'm not familiar with the function syntax, unfortunately. I tried working withmakebst, but the style produced won't work (produces a more MLA style, and the publications office doesn't allow it). – JSCard Dec 29 '15 at 17:22 -
Honestly, I'd rather not be customizing the
.bstbut the only journals that use this reference format don't use LaTeX or bib(la)tex... pretty much stuck. I also need to title-case article titles (sentence-cased inhumannat) and a few other tweaks, but this issue is the real tricky one as far as I can tell. – JSCard Dec 29 '15 at 17:43 -
@Scard - It would be helpful if you posted a new query, in which you'd lay out the exact formatting requirements you're facing. (If you want, you may post a link to the current posting for background information.) I must confess to not being sure what the exact requirements may be that you need to fulfill. – Mico Dec 30 '15 at 22:03