Refurbish exported Zotero-BibTex bibliographies into a more friendly representation.
In the current state exporting the contents of a Zotero database to Bibtex format most special characters are replaced by Zotero internal versions or escaped before written to the output file. This behavior is exceptionally annoying if entries contain code which is meant to be processed by (i.e. chemical or mathematical expressions and formulas in the title, etc.).
zotero-bibtize
can be used to post-process the generated Zotero output files
and remove added escape sequences (i.e. the output is an identical replica
of the raw entry contents stored in the Zotero interface)
After installing the package zotero-bibtize
can be invoked via a call to the
zotero-bibtize
command on the command line:
$ zotero-bibtize zotero_bibliography.bib bibtized_bibliography.bib
which will process the original contents zotero_bibliography.bib
and writes
the processed contents to the new bibtized_bibliography.bib
file.
Note that specifying a target file is optional and the input file will be
overwritten if left out.
Original bibtex entry generated by Zotero export:
$ cat zotero_bibliography.bib
@article{LangCM2015,
title = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the \{{NASICON}\} {Structure}: {A} {First}-{Principles} {Study}},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the {NASICON} {Structure}},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els{\textbackslash}"\{a\}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
After running zotero-bibtize zotero_bibliography.bib
:
$ cat zotero_bibliography.bib
@article{LangCM2015,
title = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure: A First-Principles Study},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els\"{a}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
Custom BibTex keys can be defined through the optional --key-format
option
that will be written to the bibliography file instead of the default keys
generated by Zotero. The key format defines the way how to combine and format
contents taken from the BibTex entry fields to build a custom key format. In
general the format key is of the form
[field1:option][field2:option]...
where field
defines the BibTex entry field to take the contents from and the
options defines different format options that will be applied to the contents.
Currently the following fields are implemented:
Adds the author's lastnames to the key entry
General format: [author:num:options]
Defines the maximal number of author names used for the key
The format options that will be applied to the author names, i.e.
- capitalize: Capitalize the names
- upper: Transform names uppercase
- lower: Transform names to lowercase
- abbreviate: Only us the first letter instead of the full name
Adds contents of the title string to the key entry
General format: [title:num:options]
Defines the maximal number of words in the title used for the key (Note that function keys will not be taken into account)
The format options that will be applied to the title contents, i.e.
- capitalize: Capitalize the names
- upper: Transform names uppercase
- lower: Transform names to lowercase
- abbreviate: Only us the first letter instead of the full name
Adds contents of the journal name to the key entry
General format: [journal:options]
The format options that will be applied to the journal name, i.e.
- capitalize: Capitalize the names
- upper: Transform names uppercase
- lower: Transform names to lowercase
- abbreviate: Only us the first letter instead of the full name
Add the publication year to the key entry
General format: [year:option]
Adding the year only allows to specify two types of options:
- short: Add the year to the key as 2-digit quantity
- long: Add the full year to the (i.e. as 4-digit quantitiy)
In the following example we create a custom key containing the first
author name and the abbreviated journal name followed by the publication
year. The key format defining such a key is of the following form:
[author:1:capitalize][journal:capitalize:abbreviate][year]
The original entry generated by Zotero looks like this:
$ cat zotero_bibliography.bib
@article{lang_lithium_ion_conduction_2015,
title = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the \{{NASICON}\} {Structure}: {A} {First}-{Principles} {Study}},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium {Ion} {Conduction} in {\textbackslash}ce\{{LiTi}2({PO}4)3\} and {Related} {Compounds} {Based} on the {NASICON} {Structure}},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els{\textbackslash}"\{a\}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}
After running zotero-bibtize zotero_bibliography.bib --key-format [author:1:capitalize][journal:capitalize:abbreviate][year]
the original contents will be processed by zotero-bibtize
and the original
Zotero key will be replaced with the modified version:
$ cat zotero_bibliography.bib
@article{LangCM2015,
title = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure: A First-Principles Study},
volume = {27},
issn = {0897-4756, 1520-5002},
shorttitle = {Lithium Ion Conduction in \ce{LiTi2(PO4)3} and Related Compounds Based on the NASICON Structure},
url = {http://pubs.acs.org/doi/10.1021/acs.chemmater.5b01582},
doi = {10.1021/acs.chemmater.5b01582},
language = {en},
number = {14},
urldate = {2019-02-11},
journal = {Chem. Mater.},
author = {Lang, Britta and Ziebarth, Benedikt and Els\"{a}sser, Christian},
month = jul,
year = {2015},
pages = {5040--5048}
}