wdbibtex.LaTeX.cite#

LaTeX.cite(s)#

Do cite command formatting.

Returns formated text from citation commands such as cite{key1} and cite{key1,key2,key3}, etc. By default, if there are three or more consecutive numbers, they are compressed into a range using an en-dash. Citation numbers are also sorted in the default condition.

Parameters:
sstr

Raw string to be formatted. For example, \cite{key1} or \cite{key2,key3}.

Examples

>>> import wdbibtex
>>> tx = wdbibtex.LaTeX()
>>> tx.citation_labels = {'key1': 1, 'key2': 2, 'key3': 3}
>>> tx.cite('\\cite{key1}')
'[1]'
>>> tx.cite('\\cite{key2,key3}')
'[2,3]'
>>> tx.cite('\\cite{key3,key2,key1}')
'[3,2,1]'
>>> import wdbibtex
>>> tx = wdbibtex.LaTeX()
>>> tx.add_package('cite')
>>> tx.citation_labels = {'key1': 1, 'key2': 2, 'key3': 3}
>>> tx.cite('\\cite{key1}')
'[1]'
>>> tx.cite('\\cite{key2,key3}')
'[2,3]'
>>> tx.cite('\\cite{key3,key2,key1}')
'[1\u20133]'

Note \u2013 is en-dash.