Skip to content

Instantly share code, notes, and snippets.

@casallas
Last active September 6, 2021 20:47
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casallas/eff4dfc39b44e3e696b1 to your computer and use it in GitHub Desktop.
Save casallas/eff4dfc39b44e3e696b1 to your computer and use it in GitHub Desktop.
Publishing clean bibtex files

These tricks require BibTool, which can be installed using homebrew.

To extract only the used fields call bibtool -x on a .aux file, e.g.

bibtool -x doc.aux -o output.bib

To delete fields that you don't want to share, e.g. notes and file locations,

bibtool -- "delete.field {annote}" -i input.bib -o output.bib
bibtool -- "delete.field {file}" -i input.bib -o output.bib

An easier way to deal with multiple options is to create a resource file, mine looks like this and its meant to "clean" mendeley generated bibtex files, yet modify them minimally:

delete.field      = "annote"
delete.field      = "file"
delete.field      = "keywords"
delete.field      = "abstract"
delete.field      = "mendeley-tags"
preserve.key.case = on
print.align.key   = 0
print.indent      = 2
print.align       = 0
print.line.length = 9999
print.wide.equal  = on
print.equal.right = off
print.use.tab     = off

You can call this file directly with the -r option, e.g., bibtool -r res_file -i input.bib -o output.bib, or save it in the current directory, or in the $HOME directory as .bibtoolrsc, so that you don't have to use the -r option.

More options and documentation here: http://www.gerd-neugebauer.de/software/TeX/BibTool/bibtool.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment