按标签字母顺序对手册书目进行排序

按标签字母顺序对手册书目进行排序

如何按标签的字母顺序对参考书目进行排序

\begin{the bibliography}{10}
\bibitem[Polchinski, 1984]{jpol}
Polchinski,~J.
\newblock{(1984)},
\newblock Renormalization group and effective lagrangians.
\newblock {\textbf{ Nuclear Physics B}}, 231:269--295.

\bibitem[Binney \textit{et al.}, 1992]{binney}
Binney,~J.~J., Dowrick,~N.~J.,  Fisher,~A.~J. and Newman,~M.~E.~J.
\newblock{(1992)},
\newblock \textbf{The Theory of critical phenomena: An introduction to the renormalization group}.
\newblock {Clarendon Press, Oxford, UK}.

\bibitem[Politzer, 1974]{politzer}
Politzer,~H.~D.
\newblock{(1974)},
\newblock Asymptotic freedom: An approach to strong interactions.
\newblock {\textbf{ Physics Reports}}, 14(4):129--180.
\end {the bibliography}

即我需要的顺序是 Binney 然后是 Polchinski 然后是 Politzer (在上面的例子中)

答案1

更新l3kernell3experimental包。下面是一些定义sortbibliography环境的代码,它(1)捕获直到的所有内容\end{sortbibliography}(使用environ您可能已经拥有的包),(2)将其找到的内容(\BODY)拆分为单个项目(在每个\bibitem),(3)删除第一个之前的所有内容\bibitem(并确保为空),(4)按字典顺序对项目进行排序,(5)在您选择的环境中排版所有内容(这里我使用了thebibliography,但您的设置中似乎有一个the bibliography环境。对于最多几千个项目,这应该很快,尽管我还没有对其进行广泛的测试。

\documentclass{article}
\usepackage{environ}
\usepackage{expl3}
\ExplSyntaxOn
\seq_new:N \l_riad_bib_seq % bibliography, split at \bibitem commands
\tl_new:N \l_riad_pre_tl   % part before the first \bibitem
\prg_new_conditional:Npnn \riad_str_compare:nNn #1#2#3 { TF }
  {
    % Comparing two entries in the bibliography is done using
    % the primitive \pdfstrcmp (for XeTeX, use \strcmp, for LuaTeX, use
    % \pdf@strcmp from Oberdiek's package pdftexcmds), which compares
    % strings in lexicographic order.
    %
    \if_int_compare:w
        \pdfstrcmp { \exp_not:n {#1} } { \exp_not:n {#3} } #2 \c_zero_int
      \prg_return_true:
    \else:
      \prg_return_false:
    \fi:
  }
\NewEnviron{sortbibliography}[2]
  {
    \begin{#1}{#2}
      \seq_set_split:NnV \l_riad_bib_seq { \bibitem } \BODY
      \seq_pop:NN \l_riad_bib_seq \l_riad_pre_tl
      \tl_remove_all:Nn \l_riad_pre_tl { \par } % Error checking: only \par and
      \tl_remove_all:Nn \l_riad_pre_tl { ~ }    % spaces before first \bibitem.
      \tl_if_empty:NF \l_riad_pre_tl            % Otherwise, complain about the
        {                                       % tokens found before \bibitem.
          \msg_error:nnxxx { riad } { junk-before }
            { \token_to_str:N \bibitem }
            { sortbibliography }
            { \tl_to_str:N \l_riad_pre_tl }
        }
      \seq_sort:Nn \l_riad_bib_seq
        {
          \riad_str_compare:nNnTF {##1} > {##2}
            { \sort_return_swapped: }
            { \sort_return_same: }
        }
      \seq_map_inline:Nn \l_riad_bib_seq { \bibitem ##1 }
    \end{#1}
  }
\msg_new:nnn { riad } { junk-before }
  { Extra~'#3'~before~the~first~'#1'~in~environment~'#2'. }
\ExplSyntaxOff
\begin{document}
\begin{sortbibliography}{thebibliography}{10}
\bibitem[Polchinski, 1984]{jpol}
Polchinski,~J.
\newblock{(1984)},
\newblock Renormalization group and effective lagrangians.
\newblock {\textbf{ Nuclear Physics B}}, 231:269--295.

\bibitem[Binney \textit{et al.}, 1992]{binney}
Binney,~J.~J., Dowrick,~N.~J.,  Fisher,~A.~J. and Newman,~M.~E.~J.
\newblock{(1992)},
\newblock \textbf{The Theory of critical phenomena: An introduction to the renormalization group}.
\newblock {Clarendon Press, Oxford, UK}.

\bibitem[Politzer, 1974]{politzer}
Politzer,~H.~D.
\newblock{(1974)},
\newblock Asymptotic freedom: An approach to strong interactions.
\newblock {\textbf{ Physics Reports}}, 14(4):129--180.
\end{sortbibliography}
\end{document}

答案2

You're in trouble here.您已决定创建手动参考书目,而不是使用 bib(la)tex ——这在某些情况下可能是合理的,但可能最多基本的手动书目的特点是排序也将是手动的...因为根本没有工具可以为您进行排序。

一个可能对你有帮助的选择是建议Jubobs 提供。第二种方法是,为你提供thebibliography一种格式,这种格式可以通过第三方工具进行处理,这些工具能够对纯文本行进行排序:例如任何电子表格应用程序,或者,如果你使用的是 Windows,温特(一款出色的多功能工具,可用于各种文本操作),或者甚至是您已经在使用的 TeX 编辑器(例如 WinEdt)。选择此类工具后,请尝试以下步骤:

(1) 使用搜索和替换删除您想要按其排序的字符串前面的所有内容。我猜您的情况应该是:\bibitem[--所以这些行现在以等开头Binney。(RegEx 在这里可能会有所帮助或必要)。

(2)使用第二次搜索和替换来删除项目内出现的所有换行符,用一些未使用的字符或字符串替换它们,例如-- 以便每个 bib 项目合并为一行。

前:

\bibitem[Binney \textit{et al.}, 1992]{binney}
Binney,~J.~J., Dowrick,~N.~J.,  Fisher,~A.~J. and Newman,~M.~E.~J.
\newblock{(1992)},
\newblock \textbf{The Theory of critical phenomena: An introduction to the renormalization group}.
\newblock {Clarendon Press, Oxford, UK}.

后:

Binney \textit{et al.}, 1992]{binney} ¶ Binney,~J.~J., Dowrick,~N.~J.,  Fisher,~A.~J. and Newman,~M.~E.~J. ¶ \newblock{(1992)}, ¶ \newblock \textbf{The Theory of critical phenomena: An introduction to the renormalization group}. ¶ \newblock {Clarendon Press, Oxford, UK}.

(3)使用您选择的排序工具对线条进行排序。

(4)按照第2步和第1步的相反步骤,将您的参考书目恢复为其原始格式。

(5)考虑使用自动书目 为你的下一篇论文:)

相关内容