BibTeX 參考文獻列表中三位作者後面跟著“et al”

BibTeX 參考文獻列表中三位作者後面跟著“et al”

我找到了一個非常相似問題的答案:BibTeX:如何將長作者名單減少為「Firstauthor et al.」?

但是,建議的解決方案對我來說不起作用。我有出版商提供的樣式,同時解釋說參考作者應該在第三作者之後被截斷(後面是等人)

在文件中我找到了{ namesleft #1 >並按照該回復中的指示進行了更改,但它不起作用。你能幫助我嗎?

{ 'bibinfo :=
 duplicate$ empty$ 'skip$ {
 's :=
 "" 't :=
 #1 'nameptr :=
 s num.names$ 'numnames :=
 numnames 'namesleft :=
   { namesleft #0 > }
   { s nameptr
     "{vv~}{ll}{ f{}}{ jj}"
     format.name$
     remove.dots
     bibinfo bibinfo.check
     't :=
     nameptr #1 >
      % {
       %  namesleft #1 >
nameptr #1 >
        {
         nameptr #3
         #1 + =
         numnames #5
         > and
           { "others" 't :=
             #1 'namesleft := }
           'skip$
         if$
         namesleft #1 >
           { ", " * t * }
           {
             "," *
             s nameptr "{ll}" format.name$ duplicate$ "others" =
               { 't := }
               { pop$ }
             if$
             t "others" =
               {
                 " " * bbl.etal *
               }
               { " " * t * }
             if$
           }
         if$
       }
       't
     if$
     nameptr #1 + 'nameptr :=
     namesleft #1 - 'namesleft :=
   }
 while$
 } if$
} ```

答案1

OP 在評論中指出他/她使用spbasicSpringer 提供的參考書目風格。

為了實現所需的格式-如果條目有,則顯示所有作者的姓名最多 4 個作者,但僅顯示前三位作者,後跟“et al”。如果該條目有超過4個作者—我建議您如下進行。

  • 製作一個副本spbasic.bst並呼叫該副本,例如,spbasic85.bst

  • spbasic85.bst在文字編輯器中開啟該文件。你用來編輯 tex 檔的程式就可以了。

  • 找到該函數format.names。 (在我的 bst 檔案副本中,該函數從第 455 行開始。)

  • 在此函數中,找到以下兩行:

          nameptr #1 >
            {
    
  • 緊接在這兩行之後,也就是在 的行之前namesleft #1 >,插入以下 8 行程式碼:

              nameptr #3
              #1 + =
              numnames #4
              > and
                { "others" 't :=
                  #1 'namesleft := }
                'skip$
              if$
    
  • 將檔案儲存spbasic85.bst在包含主 tex 檔案的資料夾中或 BibTeX 搜尋的資料夾中。如果您選擇後一個選項,請務必對您的 TeX 發行版的檔案名稱資料庫套用適當的更新。 (如果你不確定你是否理解了前面的句子,我強烈建議你選擇選項1...)

  • 在你的主 tex 檔案中,更改\bibliographystyle{spbasic}\bibliographystyle{spbasic85}執行完整的重新編譯週期——LaTeX、BibTeX 和 LaTeX 兩次——以傳播所有變更。


完整的 MWE:

在此輸入影像描述

\documentclass{article}
\begin{filecontents}[overwrite]{mybib.bib}
  @misc{abc,author="A and B and C",title="X",year=3000}
  @misc{abcd,author="A and B and C and D",title="Y",year=3001}
  @misc{abcde,author="A and B and C and D and E",title="Z",year=3002}
\end{filecontents}

\usepackage[authoryear]{natbib}
\bibliographystyle{spbasic85}

\begin{document}
\cite{abc}, \cite{abcd}, \cite{abcde}
\bibliography{mybib}
\end{document}

相關內容