Size: 4257
Comment:
|
Size: 5779
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 22: | Line 22: |
Note: To best view the two examples below from Beezer's linear algebra text, it is necessary to slightly tweak the jsMath configuration in Sage. It is a one-character edit. You can still view the sections, but "reasons" given in math displays (generally in proofs) won't render right and you will see lots of "@a()" stuff. This will be fixed once [[http://trac.sagemath.org/sage_trac/ticket/8202 | Trac 8202]] is merged, which is slated for Sage 4.3.2. So check the ticket and check your version of Sage ({{{sage --version}}}) and maybe you don't need to do this. The file to edit is {{{ SAGE_ROOT/local/lib/python/site-packages/sagenb-0.6-py2.6.egg/sagenb/data/sage/js/jsMath.js }}} where you might have to adjust the numbering on the {{{sagenb}}} package. Then at line 97 (or thereabouts) make the following change {{{ jsMath.safeHBoxes=1 --> jsMath.safeHBoxes=0 }}} Also, these examples have a bit of a formatting problem for larger matrices (more than two rows) on my setup, but I'm uncertain if that is my problem or more general. A report, either way, would be appreciated if you look at these. * tikz graphics migration (2010/02/03)<<BR>> * tikz graphics in latex source passing through to the worksheet * combinatorial graphs in Sage creating tikz source, also included * worksheet has graphics as SVG, live cells, graph editor * Not all browsers render SVG? Tested in Firefox * [[attachment:graphics-test.tex | Latex source]], some generated by Sage * [[attachment:graphics-test.pdf | PDF]], a faithful rendition * [[attachment:graphics-test.sws | Worksheet]], note SVG graphics, run code, experiment with graph editor * This experiment prompted by a [[http://old.nabble.com/Using-pgfsys-tex4ht.def-to-make-svg-output-td16685147.html | mailing list discussion]] |
|
Line 26: | Line 50: |
* Textbook Section Experiment (2010/01/30, updated 2010/02/07)<<BR>> This is a straight conversion of a math-heavy section from Beezer's linear algebra text. * See note above about jsMath and amtrix formatting. * The original tex4ht output is at [[http://linear.ups.edu/jsmath/0220/fcla-jsmath-2.20li35.html#x36-143000 | FCLA Section FS in jsMath]] which seems to render just fine for me. * There is no embedded Sage code here yet, but that will be easy to add. * [[attachment:math-stress-test.sws | Worksheet]] |
|
Line 53: | Line 85: |
* Textbook Section Experiment (2010/01/30)<<BR>> This is a straight conversion of a math-heavy section from Beezer's linear algebra text. * The original tex4ht output is at [[http://linear.ups.edu/jsmath/0220/fcla-jsmath-2.20li35.html#x36-143000 | FCLA Section FS in jsMath]] which seems to render just fine for me. * Worksheet below is a straight conversion as in the Group Theory demo above, but has at least three problems: 1. Graphic is not being picked up (easy to fix in parsing script). 2. Some formatting (like matrix brackets) not rendering right. 3. Links in theorems use {{{\text{@(a href="#definition.LNS")Definition LNS@(/a)}}}} construct which is broken in notebook, and is a mystery to me at the moment. * [[attachment:math-stress-test.sws | Worksheet]] |
|
Line 70: | Line 92: |
== Related Project == [[http://bitbucket.org/whuss/sws2tex/ | sws2tex]], [[http://user.mendelu.cz/marik/sage/skolka.pdf | Example]]<<BR>> Anybody want to try for the round-trip, Latex -> SWS -> Latex? |
|
Line 71: | Line 97: |
* tikz graphics generation with tex4ht?<<BR>> [[http://old.nabble.com/Using-pgfsys-tex4ht.def-to-make-svg-output-td16685147.html | Mailing list discussion]]<<BR>> [[http://en.wikipedia.org/wiki/File:Circle_graph.svg | Resultant Example]] |
Converting Latex Documents to Sage Worksheets
Introduction
Latex documents can be translated to jsMath, the tool used to render mathematics in the Sage notebook. This project is about automating the conversion process so that authors can easily use a single command to convert a book-length Latex document to a collection of Sage worksheets. These could have embedded Sage input cells, possibly containing interacts, and the cross-referencing features of Latex would be preserved in the collection of Sage worksheets.
Rob Beezer, [email protected], rbeezer on #sage-devel IRC
Links
Trac Ticket 8105 Contains project snapshots, links to other tickets
Mercurial Repository @BitBucket
Clone using:hg clone https://[email protected]/rbeezer/tex2sws/
Examples
To view a worksheet, click on the "worksheet" link, then in the resulting page find the big blue download box and use your browser's function to copy the link there.
Then open your notebook, click the "Upload" link near the upper-left and then paste in the link into the URL field (the second one).
Note: To best view the two examples below from Beezer's linear algebra text, it is necessary to slightly tweak the jsMath configuration in Sage. It is a one-character edit. You can still view the sections, but "reasons" given in math displays (generally in proofs) won't render right and you will see lots of "@a()" stuff. This will be fixed once Trac 8202 is merged, which is slated for Sage 4.3.2. So check the ticket and check your version of Sage (sage --version) and maybe you don't need to do this.
The file to edit is
SAGE_ROOT/local/lib/python/site-packages/sagenb-0.6-py2.6.egg/sagenb/data/sage/js/jsMath.js
where you might have to adjust the numbering on the sagenb package. Then at line 97 (or thereabouts) make the following change
jsMath.safeHBoxes=1 --> jsMath.safeHBoxes=0
Also, these examples have a bit of a formatting problem for larger matrices (more than two rows) on my setup, but I'm uncertain if that is my problem or more general. A report, either way, would be appreciated if you look at these.
tikz graphics migration (2010/02/03)
- tikz graphics in latex source passing through to the worksheet
- combinatorial graphs in Sage creating tikz source, also included
- worksheet has graphics as SVG, live cells, graph editor
- Not all browsers render SVG? Tested in Firefox
Latex source, some generated by Sage
PDF, a faithful rendition
Worksheet, note SVG graphics, run code, experiment with graph editor
This experiment prompted by a mailing list discussion
Group Theory Primer (2010/01/28)
Lots of simple Sage code, some simple mathematics, one interact (search for "@interact")
Best working demo (though it lacks a title)
Worksheet SourceTextbook Section Experiment (2010/01/30, updated 2010/02/07)
This is a straight conversion of a math-heavy section from Beezer's linear algebra text.- See note above about jsMath and amtrix formatting.
The original tex4ht output is at FCLA Section FS in jsMath which seems to render just fine for me.
- There is no embedded Sage code here yet, but that will be easy to add.
Linked Worksheets (2010/01/30)
A simple manufactured example of cross-worksheet linking.- Fire up Sage, then create a new, temporary notebook with the user "link"
sage: from sagenb.notebook.notebook import Notebook sage: nb = Notebook('/tmp/test.sagenb') sage: nb.add_user('link', 'link', '', force=True) sage: nb.save() sage: exit
- At system command-line extract archive (below) to create the worksheets with numbers 0 and 1 in link's space.
$ cd /tmp/test.sagenb/home $ tar -xvf <path-to>/link-worksheets.tar.gz
- Fire up Sage to start a notebook session in the temporary notebook:
sage: notebook(directory="/tmp/test.sagenb")
- You may need to create an admin password (do it).
You may see the worksheets, but be logged in as admin.
If needed, be certain to login as "link" with password "link."
- Open worksheet 0, execute a cell or two, find link to worksheet 1.
- Follow link to worksheet 1, execute some cells here too.
- Fire up Sage, then create a new, temporary notebook with the user "link"
tex4ht
This is a list of known configurations of tex4ht that seem to work:
- "tex4ht is part of the standard mactex distribution" (Dana Ernst, 2010/01/29)
- "TeXLive 2009 (separate from Ubuntu package manager) includes its own little package manager ('tlmgr') and I used that to install tex4ht" (Dan Drake, 2010/01/30)
- Ubuntu/Kubuntu/Debian: Untested, (K)Ubuntu Karmic 2009/05/21, Debian stable 2008/07/01, Debian testing 2009/06/11
Related Project