Opened 13 years ago

Closed 13 years ago

#6591 closed enhancement (fixed)

[with patch, positive review] Implement view(object, viewer='pdf') and view(object, tightpage = True)

Reported by: Nicolas M. Thiéry Owned by: Nicolas M. Thiéry
Priority: major Milestone: sage-4.1.1
Component: interfaces Keywords: view, pdflatex, tightpage, tikz
Cc: Sage Combinat CC user, Rob Beezer, Fidel Barrera-Cruz, John Palmieri Merged in: Sage 4.1.1.alpha1
Authors: Nicolas M. Thiéry Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Nicolas M. Thiéry)

This small patch implements:

sage: view(object, viewer = "pdf")

which works even under the notebook.

Typical use cases:

  • you prefer your pdf browser to your dvi browser
  • you want to view latex snippets which are not displayed well in dvi viewers or jsmath (e.g. tikzpicture)

Potential extensions: view(object, viewer='png'), view(object, viewer='html')

Note: this partially reinstates #5920 which got a positive review and was said to be merged and closed, but apparently later discarded upon the merge of the overlapping #6012 (pdflatex option)

This patch also adds a tightpage option, which uses the preview package to create a document with each displaymath on a single page whose size is exactly that of the displaymath. This is for example useful for very large pictures (graphs!) generated with tikz.

Suggestions for how to doctest this are welcome.

Attachments (3)

trac_6591-doc.patch (3.2 KB) - added by John Palmieri 13 years ago.
apply on top of the other patch
trac_6591_view_viewer_tightpage-nt.patch (5.6 KB) - added by Nicolas M. Thiéry 13 years ago.
Apply only this one (it includes the doc patch)
trac_6591-doc2.patch (1.7 KB) - added by John Palmieri 13 years ago.
apply on top of the other patch

Download all attachments as: .zip

Change History (12)

comment:1 Changed 13 years ago by Nicolas M. Thiéry

Description: modified (diff)
Owner: changed from William Stein to Nicolas M. Thiéry

comment:2 Changed 13 years ago by Nicolas M. Thiéry

Keywords: view pdflatex tightpage tikz added

comment:3 Changed 13 years ago by John Palmieri

Reviewers: John Palmieri
Summary: Implement view(object, viewer='pdf') and view(object, tightpage = True)[with patch, needs review] Implement view(object, viewer='pdf') and view(object, tightpage = True)

Everything works as advertised, both from the command-line and the notebook (except that tightpage=True has no effect in the notebook if viewer is None). I would give it a positive review except that the new options aren't documented at all. I'm attaching a patch with documentation; if you're happy with it, the whole thing can get a positive review.

I have no idea how to doctest this, by the way...

Changed 13 years ago by John Palmieri

Attachment: trac_6591-doc.patch added

apply on top of the other patch

comment:4 in reply to:  3 Changed 13 years ago by Nicolas M. Thiéry

Replying to jhpalmieri:

Everything works as advertised, both from the command-line and the notebook (except that tightpage=True has no effect in the notebook if viewer is None). I would give it a positive review except that the new options aren't documented at all. I'm attaching a patch with documentation; if you're happy with it, the whole thing can get a positive review.

I have no idea how to doctest this, by the way...

Oops, sorry, I forgot about the doc ... Thanks!

In the meantime, I actually found a shortcoming in tightpage. I'll probably add a little fix later today.

comment:5 Changed 13 years ago by Nicolas M. Thiéry

Summary: [with patch, needs review] Implement view(object, viewer='pdf') and view(object, tightpage = True)[with patch, needs work] Implement view(object, viewer='pdf') and view(object, tightpage = True)

comment:6 Changed 13 years ago by Nicolas M. Thiéry

Summary: [with patch, needs work] Implement view(object, viewer='pdf') and view(object, tightpage = True)[with patch, needs review] Implement view(object, viewer='pdf') and view(object, tightpage = True)

I folded the patches together, and fixed the shortcoming in tightpage (using displaymath did put a limit on the width of the page). I also updated and reedited a bit the documentation. Btw: I am wondering whether the description of what happens in notebook mode should not go first.

Changed 13 years ago by Nicolas M. Thiéry

Apply only this one (it includes the doc patch)

Changed 13 years ago by John Palmieri

Attachment: trac_6591-doc2.patch added

apply on top of the other patch

comment:7 Changed 13 years ago by John Palmieri

Summary: [with patch, needs review] Implement view(object, viewer='pdf') and view(object, tightpage = True)[with patch, positive review] Implement view(object, viewer='pdf') and view(object, tightpage = True)

Positive review. A few very minor doc fixes added (for the change from \LaTeX to LaTeX, it seems that jsMath doesn't know about this command, so it doesn't look good in the notebook with #5653 applied).

Apply patches trac_6591_view_viewer_tightpage-nt.patch and trac_6591-doc2.patch.

I think it's fine to leave the description of notebook mode second; it would take actual thought to change it at this point. When I worked on this docstring a while ago, my feeling was that since most of the options are ignored in notebook mode, command-line mode should come first.

comment:8 Changed 13 years ago by Nicolas M. Thiéry

Thanks John! That was quick. Time difference is a good thing :-)

comment:9 Changed 13 years ago by Minh Van Nguyen

Merged in: Sage 4.1.1.alpha1
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.