-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi folks,
I made a first attempt at a bibtex() function for citing Sage components. It returns a string containing either the citation information in bibtex database format (i.e. what you would put in a .bib file) or in bibliography format (i.e. what you would put directly in a .tex file if you didn't want to bother with bibtex). Before I go on and put in the info for the various components, I'd appreciate it if people could take a look at it and comment on 1. whether it does what you want it to do 2. whether the code looks ok 3. miscellaneous (as an example of 3., I'd like to hear suggestions on the best way to get the volatile information like the version number from sage instead of hard-coding it in bibtex.py). I'm attaching the patch (made against sage-2.10.2) to this email. Best, Alex - -- Alexandru Ghitza Assistant Professor Department of Mathematics Colby College Waterville, ME 04901 http://bayes.colby.edu/~ghitza/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHwHjndZTaNFFPILgRAhRvAJ9XGG1achIql69hSWTDyFngDmzD2wCgqVj5 J4xkukNDFoVkpL9ZtlGU5iA= =7dS/ -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
# HG changeset patch # User Alexandru Ghitza <[EMAIL PROTECTED]> # Date 1203795825 18000 # Node ID c837c13f9ef1f893c4d0430475b2931612a3d9b5 # Parent 59538ebc8f3bc9e36d8e847c5c15a8cad5a90791 generate bibtex code for citing the sage components diff -r 59538ebc8f3b -r c837c13f9ef1 sage/misc/all.py --- a/sage/misc/all.py Fri Feb 22 18:45:11 2008 -0800 +++ b/sage/misc/all.py Sat Feb 23 14:43:45 2008 -0500 @@ -139,6 +139,8 @@ from functional import (additive_order, from latex import latex, view, pretty_print, pretty_print_default, jsmath + +from bibtex import bibtex # disabled -- nobody uses mathml #from mathml ml diff -r 59538ebc8f3b -r c837c13f9ef1 sage/misc/bibtex.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sage/misc/bibtex.py Sat Feb 23 14:43:45 2008 -0500 @@ -0,0 +1,207 @@ +""" +BibTeX support for producing citations for Sage components + +""" + +#***************************************************************************** +# +# SAGE: System for Algebra and Geometry Experimentation +# +# Copyright (C) 2008 Alexandru Ghitza <[EMAIL PROTECTED]> +# Copyright (C) 2008 William Stein <[EMAIL PROTECTED]> +# +# Distributed under the terms of the GNU General Public License (GPL) +# +# This code is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# The full text of the GPL is available at: +# +# http://www.gnu.org/licenses/ +#***************************************************************************** + + +key_dict = { + 'pari': 'PARI2', + 'sage': 'Sage', + 'singular': 'GPS07', + '_test': 'Test', + } + +title_dict = { + 'pari': 'PARI/GP', + 'sage': '{S}age {M}athematics {S}oftware', + 'singular': 'Singular. A Computer Algebra System for Polynomial Computations', + '_test': 'Just a Test, Nothing More', + } + +version_dict = { + 'pari': '2.3.3', + 'sage': '2.10.2', + 'singular': '3.0.4.1', + '_test': '99.1.alpha', + } + +author_dict = { + 'sage': 'William Stein', + 'singular': r'G.-M. Greuel and G. Pfister and H. Sch\"onemann', + '_test': 'John Doe', + } + +author_compiled_dict = { + 'sage': 'Stein, William', + 'singular': r'G.-M.~Greuel, G.~Pfister, and H.~Sch\"onemann', + '_test': 'Doe, John', + } + +organization_dict = { + 'pari': 'The PARI~Group', + 'sage': 'The Sage~Group', + 'singular': 'Centre for Computer Algebra', + '_test': 'ACME Test Group', + } + +url_dict = { + 'pari': 'http://pari.math.u-bordeaux.fr/', + 'sage': 'http://www.sagemath.org', + 'singular': 'http://www.singular.uni-kl.de', + } + +note_dict = { + 'pari': 'Available from', + '_test': 'Available nowhere', + } + +address_dict = { + 'pari': 'Bordeaux', + 'singular': 'University of Kaiserslautern', + } + +year_dict = { + 'pari': '2007', + 'sage': '2008', + 'singular': '2007', + '_test': '2008', + } + + +def bibtex(component = 'sage', compiled = False): + """ + Return the citation information for the desired component of Sage. + + If the flag "compiled" is False (default), the citation is + returned formatted as a BibTeX database entry, for inclusion + in a .bib file. If the flag "compiled" is True, the citation + is returned formatted as a LaTeX bibliography item, for + inclusion in a .tex file. + + EXAMPLES: + sage: st = bibtex('_test') + sage: st + '@manual{_test,\n key = {Test},\n title = {Just a Test, Nothing More (Version 99.1.alpha)},\n author = {John Doe},\n organization = {ACME Test Group},\n note = {Available nowhere},\n year = {2008},\n}' + sage: print st + @manual{_test, + key = {Test}, + title = {Just a Test, Nothing More (Version 99.1.alpha)}, + author = {John Doe}, + organization = {ACME Test Group}, + note = {Available nowhere}, + year = {2008}, + } + sage: st = bibtex('_test', compiled = True) + sage: st + '\\bibitem[Test]{_test}\nDoe, John, \\emph{Just a Test, Nothing More (Version 99.1.alpha)}, ACME Test Group, 2008. Available nowhere.' + sage: print st + \bibitem[Test]{_test} + Doe, John, \emph{Just a Test, Nothing More (Version 99.1.alpha)}, ACME Test Group, 2008. Available nowhere. + """ + + indent = ' ' + + if key_dict.has_key(component): + key = key_dict[component] + else: + key = component.capitalize() + if compiled is True: + key = '[' + key + ']' + else: + key = indent + 'key = {' + key + '},\n' + + if title_dict.has_key(component): + title = title_dict[component] + else: + title = component.capitalize() + if compiled is True: + title = r'\emph{' + title + else: + title = indent + 'title = {' + title + + if version_dict.has_key(component): + version = version_dict[component] + else: + version = None + if not (version is None): + title = title + ' (Version ' + version + ')' + if compiled is True: + title = title + '}, ' + else: + title = title + '},\n' + + author = '' + if compiled is True: + if author_compiled_dict.has_key(component): + author = author_compiled_dict[component] + ', ' + else: + if author_dict.has_key(component): + author = author_dict[component] + author = indent + 'author = {' + author + '},\n' + + organization = '' + if organization_dict.has_key(component): + organization = organization_dict[component] + if compiled is True: + organization = organization + ', ' + else: + organization = indent + 'organization = {' + organization + '},\n' + + note = '' + if note_dict.has_key(component): + note = note_dict[component] + if compiled is False: + note = indent + 'note = {' + note + + url = '' + if url_dict.has_key(component): + url = url_dict[component] + url = r' {\tt ' + url + '}' + if note is '' and compiled is False: + note = indent + 'note = {' + if compiled is True: + note = note + url + else: + note = note + url + '},\n' + + year = '' + if year_dict.has_key(component): + year = year_dict[component] + if compiled is True: + year = year + '. ' + else: + year = indent + 'year = {' + year + '},\n' + + address = '' + if address_dict.has_key(component): + address = address_dict[component] + if compiled is True: + address = address + ', ' + else: + address = indent + 'address = {' + address + '},\n' + + if compiled is True: + bibtex_code = r'\bibitem' + key + '{' + component + '}\n' + author + title + organization + address + year + note + '.' + else: + bibtex_code = '@manual{' + component + ',\n' + key + title + author + organization + note + year + address + '}' + #print bibtex_code + return bibtex_code