handling of month, year in bibtex entry

Issue #84 new
Nico Schlömer created an issue

In BibTeX, there are different ways of dealing with months. One can provide the month literally as a string, e.g.,

month={The Month of May},

Another possibility is to just provide the "index" in terms of jan, feb, etc. without quotes or brackets, e.g.,

month=may

This has the advantage that it can be translated into the language of the document when compiled.

I'd like to make use of that, but pybtex doesn't provide that functionality yet, it seems. The Entry

    reference = pybtex.database.Entry(
        'article',
        fields={
            'title': u'A Framework for Deflated and Augmented ' +
                'Krylov Subspace Methods',
            'journal': u'SIAM. J. Matrix Anal. & Appl.',
            'number': u'2',
            'month': 5,
            'volume': u'34',
            'source': u'CrossRef',
            'pages': u'495-518'
            }

yields

TypeError: 'int' object is not iterable

when converted to a BibTeX string (via to_string(). Note 'month': 5.

Comments (3)

  1. Andrey Golovizin

    Technically, there is no special support for month names in the BibTeX core. Month labels, like jan, feb, etc. are just macros defined by most BibTeX styles. For example, unsrt.bst contains:

    MACRO {jan} {"January"}
    MACRO {feb} {"February"}
    MACRO {mar} {"March"}
    MACRO {apr} {"April"}
    MACRO {may} {"May"}
    MACRO {jun} {"June"}
    MACRO {jul} {"July"}
    MACRO {aug} {"August"}
    MACRO {sep} {"September"}
    MACRO {oct} {"October"}
    MACRO {nov} {"November"}
    MACRO {dec} {"December"}
    

    So the real problem with Pybtex is that there is no way to use macros as field values in database.Entry(). Even if the source .bib file contains macros, they are replaced by their string values during parsing. There is already another bug #77 on that. I'm thinking about implementing something like this some day:

    reference = pybtex.database.Entry(
        'article',
        fields={
            ...
            'month': Macro('may'),
            ...
        }
    )
    

    So please stay tuned or feel free to send a pull request. :)

  2. Log in to comment