按标题和字母顺序重新排序 .bib 文件

按标题和字母顺序重新排序 .bib 文件

重新排序 .bib 文件

你好,我想找一个 .bib 文件,重新排列条目,让它们最终按标题的字母顺序排列。让我用一个例子来解释一下我的意思。

例子

假设我有以下.bib 文件:

@book{dummit_abstract_2004,
    location = {Hoboken, {NJ}},
    edition = {3rd ed},
    title = {Abstract algebra},
    isbn = {978-0-471-43334-7},
    publisher = {Wiley},
    author = {Dummit, David Steven and Foote, Richard M.},
    date = {2004},
    keywords = {Abstract, Algebra}
}
@book{herstein_topics_1975,
    location = {Lexington, Mass},
    edition = {2d ed},
    title = {Topics in algebra},
    isbn = {978-0-536-01090-2},
    publisher = {Xerox College Pub},
    author = {Herstein, I. N.},
    date = {1975},
    keywords = {Algebra}
}
@book{burton_first_1970,
    location = {Reading, Mass},
    title = {A first course in rings and ideals},
    isbn = {978-0-201-00731-2},
    series = {Addison-Wesley series in mathematics},
    publisher = {Addison-Wesley Pub. Co},
    author = {Burton, David M.},
    date = {1970},
    keywords = {Ideals (Algebra), Rings (Algebra)}
}

我希望最终得到如下排序的文件:

@book{dummit_abstract_2004,
    location = {Hoboken, {NJ}},
    edition = {3rd ed},
    title = {Abstract algebra},
    isbn = {978-0-471-43334-7},
    publisher = {Wiley},
    author = {Dummit, David Steven and Foote, Richard M.},
    date = {2004},
    keywords = {Abstract, Algebra}
}
@book{burton_first_1970,
    location = {Reading, Mass},
    title = {A first course in rings and ideals},
    isbn = {978-0-201-00731-2},
    series = {Addison-Wesley series in mathematics},
    publisher = {Addison-Wesley Pub. Co},
    author = {Burton, David M.},
    date = {1970},
    keywords = {Ideals (Algebra), Rings (Algebra)}
}
@book{herstein_topics_1975,
    location = {Lexington, Mass},
    edition = {2d ed},
    title = {Topics in algebra},
    isbn = {978-0-536-01090-2},
    publisher = {Xerox College Pub},
    author = {Herstein, I. N.},
    date = {1975},
    keywords = {Algebra}
}

其中title线条用于按字母顺序重新排列条目。

比贝尔

我在其他几个问题中读到,biber 的tool模式可用于类似这样的操作,只要提供适当的配置文件。我尝试运行以下命令,它具有更好的格式(对齐和缩进)的优点

biber --tool --output-indent=4 --output-align --output-file=bibliography.bib --configfile=bibconfig.conf general.bib

我在其他问题中找到多个 .conf 文件,但没有给出我想要的结果,也就是说,条目的排序与示例中的顺序不同。

概括

可以做这样的事情吗?如果可以,biber 是最好的方法吗?或者可能是使用 UNIX 工具来操作文件之类的方法?

如果 biber 是最好的方法,那么什么是合适的配置文件?

此外,如果示例中的 bib 文件太短,请告诉我,如果需要,我可以提供一个更长的文件进行测试。

答案1

使用以下内容bibconfig.conf

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <nosort>
    <option name="settitles" value="\A(A|An|The)\s+"/>
  </nosort>
  <sortingtemplate name="tool">
    <presort>mm</presort>
    <sort order="1">
      <sortitem order="1">title</sortitem>
    </sort>
  </sortingtemplate>
</config>
biber --tool --output-indent=4 --output-align --output-file=bibliography.bib --configfile=bibconfig.conf general.bib

生产

@BOOK{dummit_abstract_2004,
    AUTHOR    = {Dummit, David Steven and Foote, Richard M.},
    LOCATION  = {Hoboken, {NJ}},
    PUBLISHER = {Wiley},
    DATE      = {2004},
    EDITION   = {3rd ed},
    ISBN      = {978-0-471-43334-7},
    KEYWORDS  = {Abstract,Algebra},
    TITLE     = {Abstract algebra},
}

@BOOK{burton_first_1970,
    AUTHOR    = {Burton, David M.},
    LOCATION  = {Reading, Mass},
    PUBLISHER = {Addison-Wesley Pub. Co},
    DATE      = {1970},
    ISBN      = {978-0-201-00731-2},
    KEYWORDS  = {Ideals (Algebra),Rings (Algebra)},
    SERIES    = {Addison-Wesley series in mathematics},
    TITLE     = {A first course in rings and ideals},
}

@BOOK{herstein_topics_1975,
    AUTHOR    = {Herstein, I. N.},
    LOCATION  = {Lexington, Mass},
    PUBLISHER = {Xerox College Pub},
    DATE      = {1975},
    EDITION   = {2d ed},
    ISBN      = {978-0-536-01090-2},
    KEYWORDS  = {Algebra},
    TITLE     = {Topics in algebra},
}

您需要定义一个名为 的排序模板tool,如果您想跳过诸如“A”、“An”、“The”之类的单词,则需要使用 定义排序排除nosort。更多详细信息,请参阅Biber 手册

相关内容