3

In the plain.bst file, I need to modify the authors so that only the first author appears, followed by "et al". I'm stressing that, for reasons not worth mentioning here, this has to be done at the bst level (I cannot use other solutions such as replacing with another bst or some usepackage solution).

I have identified what is (probably) the correct function to modify, but I am not familiar with this language, and would appreciate guidance on how to modify it:

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
      nameptr #1 >
    { namesleft #1 >
        { ", " * t * }
        { numnames #2 >
        { "," * }
        'skip$
          if$
          t "others" =
        { " et~al." * }
        { " and " * t * }
          if$
        }
      if$
    }
    't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

I have searched high and low, and cannot find a suitable answer for this.

Thank you!

6
  • You wouldn't even consider using biblatex? It would be just an option on loading it.
    – Bernard
    Jan 20, 2021 at 17:14
  • @Bernard I've tried, but the journal (Bioinformatics, Oxford) format is problematic enough that when I put something like the following, it doesn't even display the bibliography: \usepackage[style=authoryear-icomp,maxbibnames=9,maxcitenames=2,backend=biber]{biblatex}
    – Anon
    Jan 20, 2021 at 17:20
  • That's quite strange. Even using bibtex as a backend?
    – Bernard
    Jan 20, 2021 at 17:29
  • @Bernard I just inserted the below, and got black boxes next to the numbers,apparently due to incompatibility with natbib (see: tex.stackexchange.com/questions/551582/…), which I'm not the one loading. \usepackage[style=numeric-comp, maxbibnames=1]{biblatex} \addbibresource{document.bib}.
    – Anon
    Jan 20, 2021 at 17:37
  • What should be done in the case of entries with exactly two authors? Is it ok to show both authors, or must one use the grammatically incorrect "FirstAuthor et al" truncation? After all, "et al." is short for "et alii", which translates to "and others". Note the plural "s" in "others".
    – Mico
    Jan 20, 2021 at 18:41

1 Answer 1

2

This answer is patterned after this answer to an older query entitled BibTeX: How to reduce long author lists to “Firstauthor et al.”?.

I suggest you proceed as follows.

  • Find the file plain.bst in your TeX distribution. Make a copy of this and name the copy, say, plainone.bst. (Never edit an original copy of files from a TeX distribution.)

  • Open plainone.bst in a text editor. (The program you use to edit your tex files will do fine.)

  • In plainone.bst, find the function format.names. (In my copy of the file, this function starts on line 183.)

  • In this function, find the following group of lines:

          { namesleft #1 >
              { ", " * t * }
              { numnames #2 >
    

    and replace it with the following group:

          {
            nameptr #1
            #1 + =
            numnames #1
            > and
              { "others" 't :=
                #1 'namesleft := }
              'skip$
            if$
            namesleft #1 >
              { ", " * t * }
              {
                s nameptr "{ll}" format.name$ duplicate$ "others" =
                  { 't := }
                  { pop$ }
                if$
                numnames #2 >
    

    Aside: If you change your mind and wish to truncate the author list if there are more than, say, four authors (as opposed to more than one author), please change nameptr #1 to nameptr #4 in line 2 and numnames #1 to numnames #4 in line 4 of the new code block.

  • Save the new bst file either in the directory where your main tex file is located or in a directory that's searched by BibTeX. If you choose the latter method, be sure to update the filename database of your TeX distribution suitably. (If you don't understand the meaning of the preceding sentence, you should probably choose the first option.)

  • In the main tex file, change \bibliographstyle{plain} to `\bibliographystyle{plainone} and run a full recompile cycle -- LaTeX, BibTeX, and LaTeX twice more -- to fully propagate all changes.

Happy BibTeXing.


An MWE and its output:

enter image description here

\documentclass{article}

\begin{filecontents}[overwrite]{mybib.bib}
@misc{a,author="Anne Author", title="U", year=3001}
@misc{ab,author="Anne Author and B", title="V", year=3002}
@misc{abc,author="Anne Author and B and C", title="W", year=3003}
@misc{abcd,author="Anne Author and B and C and D", title="X", year=3004}
\end{filecontents}

\usepackage{cite}
\begin{document}
\cite{a,ab,abc,abcd}
\bibliographystyle{plain-one}  % <-- be sure to point to the new bst file
\bibliography{mybib}
\end{document}
3
  • Wonderful, thanks! There is an error, though. If you want N authors (rather than 1) you should change the second line from "nameptr #1" to "nameptr #N". Not the fourth line. Jul 14, 2023 at 6:42
  • @FrancescoPotortì - Thanks for contacting me. I've reviewed the situation some more and have concluded that both lines 2 and 4 in the code fragment will need to be adjusted if more than 1 author is supposed to be shown. E.g., if truncation is supposed to be applied only to publications with more than 5 authors and that all authors should be shown for publications with 5 or fewer authors, then nameptr #5 is needed in line 2 and numnames #5 is needed in line 4. I'll update the paragraph that starts with "Aside" accordingly.
    – Mico
    Jul 14, 2023 at 8:16
  • Mh. I did as I wrote in my comment and it works... Jul 14, 2023 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .