Ticket #41 (new defect)

Opened 3 years ago

Last modified 2 years ago

Implement LaTeX representations of Out[NN] results

Reported by: rkern Assigned to: rkern
Priority: lowest Milestone:
Component: nbdoc Version:
Severity: normal Keywords: version-bump
Cc:

Description

One can generate nice LaTeX from certain objects like arrays (or polynomials or ...). This will probably need a separate subcell in the log since we would want to keep this kind of output separate from the more usual string representation. Some users won't have LaTeX installed, and the choice to see rendered LaTeX . C.f. SAGE.

SAGE defines a large number of classes representing mathematical entities, many of which have a convenient LaTeX representation which would be much nicer to look at than their str representations. These objects defined a _latex_() method which returns LaTeX code to be rendered and displayed. Some objects contain other _latex_()-able objects.

It would be nice to use interfaces and adaptation to implement this, a la PyProtocols?. We define an ILatexRepresentable interface that various object can claim to implement providing they have _latex_() methods. We can then register adapters for those object types that we can't add _latex_() methods to (e.g. lists, arrays, etc.). When the user chooses to see LaTeX renderings of output, the displayhook will request an ILatexRepresentable interface from the object. If the object directly implements the protocol, then we use the _latex_() method. Otherwise, we try to find a registered adapter for that kind of object (or rather, PyProtocols? does); we can then call the _latex_() method on the adapted object. Lastly, we go back to str.

A generalization might be _docbook_() which returns a snippet of DocBook? XML (which could contain a <latex> element, maybe MathML, and just some plain-old DocBook?-formatted text as alternate renderings all at the same time).

Change History

12/01/05 09:53:10 changed by anonymous

02/14/07 00:59:39 changed by fperez

  • priority changed from normal to lowest.