Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Dan Davison <davison <at> stats.ox.ac.uk>
Subject: publishing pretty code with maths; jsMath -> pdf
Newsgroups: gmane.emacs.orgmode
Date: Friday 30th July 2010 04:13:59 UTC (over 6 years ago)
I've recently realised that when mixing code and maths one can get the
best of both HTML and LaTeX worlds by using jsMath[1] to export to HTML
and then creating a pdf from that. Just in case this wasn't already
obvious to people, here's an example.

The HTML output is here (the jsmath should[2] display)

http://www.princeton.edu/~ddavison/software/jsmath/jsmath.html

and the pdf output is here, with nice code fontification as well as
crisp fonts for the mathematical notation.

http://www.princeton.edu/~ddavison/software/jsmath/jsmath.pdf

Here's the org input

--------------------------------------------------------------
#+title:jsMath
#+style: 
#+options: latex:verbatim toc:nil author:nil timestamp:nil creator:nil


This should appear via jsMath:

\[
\int_{0}^{\infty} bxe^{-bx} dx = \frac{1}{b}
\]

and here's the dvipng output for comparison

[[file:exp.png]]

And here's some code that will be nicely formatted in the html and pdf.

#+begin_src R :exports both
  ## Mean of a sample of random numbers
  f <- function(n, b) mean(rexp(n, b))
  f(1000, 4)
#+end_src

#+results:
: 0.248342091803384

The pdf is [[./jsmath.pdf][here]].
--------------------------------------------------------


If you want to use src blocks for the latex, 

begin_src latex :results raw :exports results

will do the job.

This arose because I recently had to produce a document containing code
and maths. I decided to export to HTML in order to get pretty code
fontification, and then to use the web browser to produce a pdf so that
everything was in a single file. The trouble is of course the nasty
dvipng images of latex fragments. (Not org's fault -- the web's crawling
with them.) As a result I revisited that file using jsMath for the latex
fragments: no more fuzzy images of equations. Furthermore, using the web
browser to export to pdf creates a very nice looking pdf with the
htmlized emacs code buffers mixed with mathematical notation using
proper fonts. And you can send it to people who don't have jsMath
installed.

Dan

Footnotes:

[1] 
http://orgmode.org/worg/org-tutorials/org-jsmath.php
http://www.math.union.edu/~dpvc/jsMath/


[2] I've put jsMath on that server so it should display for you -- but I
had no luck with chrome; try firefox instead.




_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
 
CD: 2ms