sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.36k stars 462 forks source link

Allow custom packages to be injected or %latex and the Sage latex mode #5791

Closed 85eec1a4-3d04-4b4d-b711-d4db03337c41 closed 15 years ago

85eec1a4-3d04-4b4d-b711-d4db03337c41 commented 15 years ago

See http://groups.google.com/group/sage-devel/browse_thread/thread/39f1d0e71eae2453 for the discussion: It would be great of one could add packages that are automatically included when running LaTeX, i.e. for commutative diagrams.

Cheers,

Michael

Component: misc

Issue created by migration from https://trac.sagemath.org/ticket/5791

jhpalmieri commented 15 years ago
comment:1

Here's an attempt at this. To use it:

sage: latex.add_macro('\\newcommand{\\foo}{bar}')

and then a %latex cell with foo in it will be processed correctly, as will %jsmath and %html cells. Also,

sage: latex.add_to_preamble('\\usepackage{blah}')

will do what it says; it should only have an effect on %latex cells.

(In this patch, "macros" are things which are processed by latex and jsmath, while the "preamble" is only passed to latex. For both categories, you can add to the current string with latex.add_macro or latex.add_preamble, or you can replace it with latex.extra_macros or latex.extra_preamble.)

Some pictures are here and here.

Anyway, please test it out; the patch is against 3.4.2.alpha0.

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 15 years ago
comment:2

Attachment: latex-5791.patch.gz

Passes tests on misc/latex.py and misc/latex_macros.py in 3.4.2.alpha0, and works as advertised at command-line and in notebook.

PDF version of documentation builds fine also. Another great addition to Sage-LaTeX integration.

So this is ready to go - positive review.

85eec1a4-3d04-4b4d-b711-d4db03337c41 commented 15 years ago
comment:3

Merged in Sage 3.4.2.rc0.

Cheers,

Michael