Package: bib2tex
bib2texA Python package to create a subset of BibTeX entries based on an author's name
(and an entrytype). The result is converted into a LaTeX list in which the author
can get highlighted with an underline. The list is sorted from new to old.The motivation for writing this package was to create a tool that generates lists
with own publications for e.g. a curriculum vitae.DemonstrationLet us assume the BibTeX filedata.bibcontained the following entry in addition
to entries by other authors:@TechReport{Rossum1995,author={van Rossum, Guido},institution={Centrum voor Wiskunde en Informatica (CWI)},title={Python tutorial},year={1995},address={Amsterdam},month=may,number={CS-R9526},groups={python},url={https://ir.cwi.nl/pub/5007/05007D.pdf},}To obtain a list with all entries containingGuido van Rossumin your BibTeX
data, simply call bib2tex and provide the path to thedata.bibfile, a prompt
will request an author name:bib2tex -i data.bib
Enter the author name for filtering BibTeX entries: RossumThe resulting LaTeX list is stored in the filerossum.texin the current working
directory and contains the following:\begin{itemize}\itemG.~van Rossum: ``Python tutorial'', Centrum voor Wiskunde en Informatica (CWI), 1995.\end{itemize}If the BibTeX data contains multiple entries for the author, they will be added
as items to the LaTeX itemize environment.You can specify a BibTeX entry type to narrow down the result list, or definecustom typesto obtain a list with a subset of a certain BibTeX entry type.
Furthermore,format schemescan be added to adjust the formatting of the LaTeX item string if desired.
There are more options to influence the conversion and run the command withouth
any need for an interaction.InstallationInstallbib2texfrom thePython Package Indexusingpip:pipinstallbib2texDependenciesclick(to provide the CLI)UsageCLIThe CLI can be called with the commandbib2tex, if the package is installed.
Run it with the--helpoption to get the following usage information and a list
of all options:Usage: bib2tex [OPTIONS]

  bib2tex - A command line utility to generate LaTeX lists from BibTeX data.

  Sorted lists are generated based on an author's name and entry types
  (optional). They are either merged into a LaTeX item environment and written
  into a file, or stored in individual files as LaTeX item environment.

  The files are written to the output directory and are named based on the
  filter options. If no entry type is declared, the filename is 'author.tex',
  while it is 'author_entrytype.tex' if you filter for one entry type, and
  'author_entrytype1-entrytype2...entrytypeN.tex' if multiple entry types are
  declared.

Options:
  -i, --bibtex-path FILE      (input) Path to the BibTeX file.  [default:
                              /path/defined/as/BIB/env/var; required]
  -o, --output-dir DIRECTORY  Path to output directory for LaTeX files.
                              [default: .; required]
  -a, --author TEXT           Author name for filtering entries.  [required]
  -c, --case-sensitive        Case sensitive filtering.
  -d, --definitions FILE      Path to a JSON file with custom type
                              definitions.
  -e, --entry-type TEXT       Specify entry type for filtering; declare
                              multiple times for batch conversion.
  -f, --force                 Perform the conversion without confirmations.
  -m, --merge                 Merge individual lists into one list (batch).
  -r, --reverse               Sort entries from old to new.
  -s, --format-scheme TEXT    Scheme name for LaTeX item formatting.
  -u, --underline             Underline the author in the LaTeX item.
  -v, --verbose               Print verbose output.
  --item TEXT                 Options for LaTeX item, e.g. "[--]".
  --itemize TEXT              Options for LaTeX itemze, e.g. "[itemsep=3pt]".
  --version                   Show the version and exit.
  -h, --help                  Show this message and exit.

  by Cs137, 2024 - development on Codeberg: https://codeberg.org/Cs137/bib2texExampleIn order to obtain all articles for the authorMyNamefrom the default BibTeX
file, call the CLI as follows:bib2tex-aMyName-earticleThe generated list is stored in the filemyname.texand the example assumes
that the--bibtex-pathis defined via the environment variableBIB.
Provide a path to it if the variable is undefined (-i path/to/example.bib).
Call the CLI with the--verbose | -voption to show log messages in the shell.ConfigurationThe path to the default BibTeX file can be defined with the environment variableBIB.Format schemeA format scheme is used to define the structure of BibTeX entries when converted
to LaTeX list items. Default format schemes exist for all valid BibTeX types, and
they are sourced from the directoryformat_schemes.Custom format schemes can be defined in a JSON file named with the format scheme
name. If a format scheme is missing for a certain entry type, the default format
scheme is taken into account. The format scheme string consists of valid
capitalised BibTeX tags wrapped in<>and is defined for each BibTeX entry type.Underneath is a typical format scheme string, keep in mind that the availability
of BibTeX tags depends on the entry type when defining new format schemes.<AUTHOR>: ``<TITLE>'', <YEAR>, DOI: \href{https://doi.org/<DOI>}{<DOI>}.Feel free to create a pull request to add new format schemes, and ensure your
schemes follow the required structure and placeholders.Custom typesIn order to allow more complex filter tasks, custom entry types are introduced.
A custom type is based on a valid BibTeX entry type and has certain keywords in
defined BibTeX fields.Create a JSON file containing a dictionary for each custom type you want to declare.
The dictionaries must contain the properties shown in the example underneath.
If a file with custom definitions is provided to the CLI, it accepts the custom
types declared in it as entry types to filter for as well.{"dataset":{"bibtex_type":"misc","format_schemes":{"default":"<AUTHOR>: ``<TITLE>'', <YEAR>, <LICENSE>, DOI: \\href{https://doi.org/<DOI>}{<DOI>}."},"search_strings":{"notes":"data set"}}}The keysearch_stringsis assigned to a dictionary, which holds a mapping in
order to identify custom entries in entries of the specifiedbibtex_type.
In the sample above, an entry type is considered asdataset, if it is a BibTeX
entry of typemiscand the BibTeX fieldnotescontains the stringdata set,
multiplesearch_stringscan be defined in the dictionary.Format scheme strings can be declared in theformat_schemesdictionary for the
custom type. The key corresponds to the name for the format scheme, ensure to
provide a default scheme for each custom type declared. Those may contain field
names that are not conform with BibTeX, likelicensein the example above.Assuming the filemy_types.jsoncontains the example shown above and the BibTeX
data contain entries corresponding to the defined search strings, those could be
converted into a LaTeX list using the following command:bib2tex-aMyName-dmy_types.json-edataset-vNotesAuthor's first names are always listed with initials, this is currently not configurable.Check thebib2tex.converter:to_latexfunction for a conversion without CLI. (Make click/CLI optional ?)ChangelogAll notable changes to this project are documented in theCHANGELOG.mdfile.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.