使用 natbib 和 plainnat 對引文和參考書目進行排序

使用 natbib 和 plainnat 對引文和參考書目進行排序

我正在用 LaTeX 寫一篇論文。我正在處理natbib包以及plainnat引文和參考文獻的樣式。問題是如何對引文和參考文獻進行排序。

我希望引文按年份排序(同一年按字母順序排列),參考文獻按作者姓氏字母順序排序。我該怎麼做?

我的程式碼:

    \documentclass[12pt,a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
    \usepackage[comma,authoryear,round]{natbib}
    \usepackage[none]{hyphenat} 
    \bibliographystyle{plainnat}
    \setcitestyle{citesep={;}}

    \begin{filecontents}{\jobname.bib}
    @book{A,
     author = {Ho, L. and Auntz, K. and Zwitter, B. F. and Valencia, D.},
     year = {2010},
     title = {Title Example 1},
    }
    @book{B,
     author = {Ho, L. and Yelp, A. and Richter, G. and Gregory, K. T.},
     year = {2005},
     title = {Title Example 2},
    }
    @book{C,
     author = {Ho, L. Abrook, H. and Dolman, R. G. and Fjing, H. and Ho, S. and Xerem, R.},
     year = {2013},
     title = {Title Example 3},
    }
    }
    @book{D,
     author = {Di Bernardo, L. and Mc Daug, C. and Coelho, L},
     year = {2000},
     title = {Title Example 4},
    }
    @book{E,
     author = {Gomes, L. N. L. and Ginoris, Y. P and Brand\~{a}o, C. C. S.},
     year = {2010},
     title = {Title Example 5},
    }
    \end{filecontents}


    \begin{document}
    Hi, this is an example. First a citation \citep{A,B},
then an inline citation \citet{B}.
Another citation \citep{C,D} and
the last one \citep{A,E}
    \bibliography{\jobname}
    \end{document}

以及觀察結果:

在此輸入影像描述

答案1

如果您將sort選項新增至natbib

    \usepackage[sort,comma,authoryear,round]{natbib}

然後它首先按作者姓名排序,然後按年份排序。您似乎想先按年份排序,然後按作者姓名排序。我不認為natbib有人支持這一點。

編輯:修改副本以plainnat.bst首先按年份排序而不是按名稱排序非常容易。這似乎不是您在範例中展示的內容,但也許這就是您想要的。

plainnat.bst首先,在目前目錄中建立一個副本並將其命名為yearnat.bst.在我的機器上我可以透過

$ cp `kpsewhich plainnat.bst` yearnat.bst

編輯yearnat.bst並將函數更改presort為以下內容。

FUNCTION {presort}
{ calc.label
  label sortify
  "    "
  *
  year field.or.null sortify
  "    "
  *
  type$ "book" =
  type$ "inbook" =
  or
    'author.editor.sort
    { type$ "proceedings" =
        'editor.organization.sort
        { type$ "manual" =
            'author.organization.sort
            'author.sort
          if$
        }
      if$
    }
  if$
  *
  "    "
  *
  cite$
  *
  #1 entry.max$ substring$
  'sort.label :=
  sort.label *
  #1 entry.max$ substring$
  'sort.key$ :=
}

所做的只是將year欄位移動到排序鍵的開頭。

現在編譯您的範例,添加sort上面的選項和\bibliographystyle{yearnat}.這是結果。

在此輸入影像描述

您可以看到所有內容首先按年份排序,然後按作者排序。如果你想知道它是如何運作的,你應該閱讀哈克(或透過運行texdoc btxhak)。

相關內容