Use information from label when formatting an entry text

Issue #122 new
Massimo D'Antoni created an issue

I am trying to create a formatting style to be used with natbib.sty, which relies on labels with author and year. A difficulty I found is that, in case two references have the same label, the solution with author-year citations is to add a letter to the year (e.g. 2018a, 2018b), and this letter should appear both in the label and in the text of the entry. However, I noticed that the label modifiers are introduced by the function format_entries, while the text of each entry is formatted in format_entry (both functions are defined in style/formatting/__init__.py). In order for format_entry to be aware that the year has been modified by format_entries, I suggest that in the definition of context in format_entry a 'label' key is added:

    def format_entry(self, label, entry, bib_data=None):
            context = {
                'entry': entry,
                'style': self,
                'label': label,               # <----------
                'bib_data': bib_data,
            }

In this way, the modified year in the label can be used to format the year of the text. Maybe there are better solutions, but this solved my problem.

Comments (0)

  1. Log in to comment