Interactive pdf?

7 views
Skip to first unread message

Simon King

unread,
Aug 13, 2009, 11:25:52 AM8/13/09
to sage-devel
Hi Sage-Devels,

apparently my new boss is very good in TeX: He showed me a draft (or
better: proof of concept) of a book in pdf format, and when you click
the examples, a gap session pops up and lets you compute these
examples. Or, if you click some (static) 3d-picture, an application
pops up, and then you can drag the object with the mouse and view it
from all sides.

This seems pretty cool to me.

Is it something that sage supports and facilitates (I guess my boss
had to put a lot of hand work in it)? Or have you experience with such
funny tricks? Of course I pointed out to him that one could probably
do similar things with a Sage worksheet, but still, interactive pdf
seems quite appealing to me.

Best regards,
Simon

William Stein

unread,
Aug 13, 2009, 12:25:50 PM8/13/09
to sage-...@googlegroups.com
On Thu, Aug 13, 2009 at 8:25 AM, Simon King<simon...@nuigalway.ie> wrote:
>
> Hi Sage-Devels,
>
> apparently my new boss is very good in TeX: He showed me a draft (or
> better: proof of concept) of a book in pdf format, and when you click
> the examples, a gap session pops up and lets you compute these
> examples.

Wow, so when I read a random pdf off the web and click on it, then it
could run a shell command, e.g., "rm -rf $HOME"?

William

>Or, if you click some (static) 3d-picture, an application
> pops up, and then you can drag the object with the mouse and view it
> from all sides.
>
> This seems pretty cool to me.
>
> Is it something that sage supports and facilitates (I guess my boss
> had to put a lot of hand work in it)? Or have you experience with such
> funny tricks? Of course I pointed out to him that one could probably
> do similar things with a Sage worksheet, but still, interactive pdf
> seems quite appealing to me.
>
> Best regards,
> Simon
>
> >
>



--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Simon King

unread,
Aug 13, 2009, 1:21:25 PM8/13/09
to sage-devel
Hi William,

On Aug 13, 5:25 pm, William Stein <wst...@gmail.com> wrote:
> On Thu, Aug 13, 2009 at 8:25 AM, Simon King<simon.k...@nuigalway.ie> wrote:
...
> Wow, so when I read a random pdf off the web and click on it, then it
> could run a shell command, e.g., "rm -rf $HOME"?

My boss just gave me some details.

In fact, the book comprises a pdf file *plus* certain shell scripts,
say run_ex_1.sh

In the latex file, he has commands like
\href{run:path/to/run_ex_1.sh}{Example 1}

This would result in the text "Example 1", which you could click. If
you do, you would first be asked whether you want to execute that
script or not. I don't know if this would work on any platform
(probably not).

After all, the scripts shipped with the book could contain evil
commands, so you have to decide whether you want to trust my boss :-)

But I think you could do nasty things on shell level with a Sage
worksheet as well, couldn't you?

Cheers,
Simon

David Joyner

unread,
Aug 13, 2009, 2:31:33 PM8/13/09
to sage-...@googlegroups.com
On Thu, Aug 13, 2009 at 11:25 AM, Simon King<simon...@nuigalway.ie> wrote:
>
> Hi Sage-Devels,
>
> apparently my new boss is very good in TeX: He showed me a draft (or
> better: proof of concept) of a book in pdf format, and when you click
> the examples, a gap session pops up and lets you compute these
> examples. Or, if you click some (static) 3d-picture, an application
> pops up, and then you can drag the object with the mouse and view it
> from all sides.
>
> This seems pretty cool to me.
>
> Is it something that sage supports and facilitates (I guess my boss
> had to put a lot of hand work in it)? Or have you experience with such


Would the following work (and maybe more secure): use \url{...} tags
in the latex source which link to published (or local, on your computer)
Sage notebook worksheets (which could run GAP or Sage or a 3dplot or whatever)?
Compile using pdflatex and you have your more-or-less interactive pdf.

William Stein

unread,
Aug 13, 2009, 8:19:29 PM8/13/09
to sage-...@googlegroups.com

Yes, if it is running on the user's computer. If it is running on a
web page though, e.g., http://sagenb.org, then no, you definitely
can't do nasty shell level stuff on the user's computer.

William

Ahmed Fasih

unread,
Aug 13, 2009, 10:04:53 PM8/13/09
to sage-devel
This seems a good enough time to ask: I'd like to use Notebook where
instead of using FCKEditor to typeset inter-cell rich text, one could
type latex in-browser. A latex2html converter would then operate on
those HTML cells. This way, one could imagine writing an entire thesis
or book chapter in Notebook, with the relevant cells right in it, and
export it to html or pdf (as in literate programming). To make it
appropriate for journal articles, it would need to omit the cells and
outputs.

Given that I can typeset Latex in the code cells themselves, this is
probably not too distant but will probably percolate in my head for a
few years, so if anyone has any inclination to go down this route, I'd
love to hear about it.

Jason Grout

unread,
Aug 13, 2009, 10:22:22 PM8/13/09
to sage-...@googlegroups.com


Have you used TexMacs? It sounds like that may be something you'd be
very interested in, especially since you can execute Sage cells in it.

Thanks,

Jason

William Stein

unread,
Aug 14, 2009, 2:39:01 AM8/14/09
to sage-...@googlegroups.com

I had an inclination in this direction today when I was doing some
number theory research. I was developing an algorithm, partly doing
experiments in the notebook, and tracking all my progress in an emacs
latex document, ocassionally copying and pasting from the "Text" view
of a worksheet to verbatim blocks in emacs. For me, it would have
been very useful if the following were possible:

1. There were text cells between the compute cells, but their
contents were 100% latex, and stayed that way. Compute cells would be
exactly as is.

2. A process running in the background would latex a version of the
contents of my worksheet that would get written to disk regularly as a
100% valid latex document. It would have all the compute cells nicely
typeset in verbatim blocks (or something nicer), and everything
between compute cells would 100% be copied into this latex document.

3. I Preview program would run showing the nicely typeset form of
the latex document.

4. The possibility to also directly edit the latex document, and
have the Sage notebook server notice this and refresh the worksheet
based on those edits. This would make it easy to do big reorganize of
the document, search and replace throughout, a complicated emacs macro
somewhere, etc.


With 1-4 above, I could typeset 100% correctly absolutely any latex
document with no funny business, but would have Sage I/O nicely
integrated in the document. I could chose to ignore the pdf preview,
or look at it when I want to.

The above would actually be fairly easy to implement, IMHO. This
would only be something that works on your own local desktop of
course.

Note that this still has the old fashioned non WYSIWYG "write the doc
in one model, view typeset version in another" model. But I really
like having total control over my latex documents, with all my
standard macros, bibtex, etc., and this would make that possible,
while still embedding a complete sage worksheet session.

One issue that is not treated above is that a worksheet is typically a
lot shorter than a latex document, for me. For example, in what I was
doing earlier today the latex document was 32 typeset pages long. It
would thus also be very nice to easily be able to link multiple
worksheets together (maybe via ordered folders and cross references
between worksheets).

Anyway, I'm guessing part of the point of this discussion is that some
people see that the Sage notebook could have an additional broader
role as a different kind of Latex editing environment (different than
say Lyx or Texmacs or Emacs).

Regarding Texmacs, that is an odd program -- some people hate it and
some people really love it. You can usually tell which you will be
within a few minutes. Note that what I describe above is *hugely*
different than either Texmacs or Lyx, in that one would have 100%
control and be able to edit any latex document however you want. It
would be more like maybe TexShop on the Mac or WinEdt on Windows, or
maybe Kyle on Linux (I've used all three of TexShop, WinEdt, and Kyle
a lot, by the way).

-- William

Ahmed Fasih

unread,
Aug 14, 2009, 7:59:45 AM8/14/09
to sage-devel
Thanks Dr Stein, your ideas bring into focus what I was trying to
address.

> With 1-4 above, I could typeset 100% correctly absolutely any latex
> document with no funny business, but would have Sage I/O nicely
> integrated in the document.   I could chose to ignore the pdf preview,
> or look at it when I want to.

With #1-4 in place for locally-running Sage, I'd hope the Notebook
would still have the capacity to render some text cells in html (from
latex), leave others in plain latex text, and of course letting non-
Latex users retain FCKeditor. Ideally obtaining a nicely typeset pdf
from sagenb.com would be as easy as publishing a worksheet on
sagenb.com (one of the most outstanding features of Sage), with a
single underlying worksheet.

This might be better explained below.

> Anyway, I'm guessing part of the point of this discussion is that some
> people see that the Sage notebook could have an additional broader
> role as a different kind of Latex editing environment (different than
> say Lyx or Texmacs or Emacs).

I too see a couple of threads interwoven here.

First (for programmers), Notebook is already literate-programming-in-a-
browser for me (http://en.wikipedia.org/wiki/Literate_programming). I
use the text cells to write out in detail what's going on in rich
formatting, and weave Sage cells throughout to do the computation &
explain the results. However, in Knuth-orthodox literate programming,
the text cells would be in Latex, because 1) Latex has powerful ways
to handle complexity of large documents, and 2) the final product can
then be a typeset document, not just a webpage (this distinction is I
think going to get less unimportant in the future---nicely typeset
papers are just as easy for me to read or print out as Sage published
worksheets). So it could become more geared

And second (for technical authors), Notebook could become a standard
Latex editor on steroids: it could be a Gmail of Latexing (in-browser
so cross-platform; automatic backups if used on a professionally-
adminned server); your Latex is automatically version-controlled; you
can embed generated Sage results (equations, plots, etc.) in your
document, and if you choose, include the source to generate them, so
readers can easily check that the results aren't fake (you also
wouldn't have to deal with saving and maintaining static eps/pngs).

Best,
Ahmed

Jason Grout

unread,
Aug 14, 2009, 9:14:02 AM8/14/09
to sage-...@googlegroups.com
Ahmed Fasih wrote:

> With #1-4 in place for locally-running Sage, I'd hope the Notebook
> would still have the capacity to render some text cells in html (from
> latex), leave others in plain latex text, and of course letting non-
> Latex users retain FCKeditor.


I feel obligated to point out that Sage uses TinyMCE, not FCKeditor.

I think this is a great conversation to have. Thanks for bringing up
these points.

Thanks,

Jason

Reply all
Reply to author
Forward
0 new messages