Opened 12 years ago

Closed 12 years ago

#6591 closed enhancement (fixed)

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

Reported by: nthiery Owned by: nthiery
Priority: major Milestone: sage-4.1.1
Component: interfaces Keywords: view, pdflatex, tightpage, tikz
Cc: sage-combinat, rbeezer, fidelbarrera, jhpalmieri Merged in: Sage 4.1.1.alpha1
Authors: Nicolas M. Thiéry Reviewers: John Palmieri
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by nthiery)

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 jhpalmieri 12 years ago.
apply on top of the other patch
trac_6591_view_viewer_tightpage-nt.patch (5.6 KB) - added by nthiery 12 years ago.
Apply only this one (it includes the doc patch)
trac_6591-doc2.patch (1.7 KB) - added by jhpalmieri 12 years ago.
apply on top of the other patch

Download all attachments as: .zip

Change History (12)

comment:1 Changed 12 years ago by nthiery

  • Description modified (diff)
  • Owner changed from was to nthiery

comment:2 Changed 12 years ago by nthiery

  • Keywords view pdflatex tightpage tikz added

comment:3 follow-up: Changed 12 years ago by jhpalmieri

  • Reviewers set to John Palmieri
  • Summary changed from Implement view(object, viewer='pdf') and view(object, tightpage = True) to [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 12 years ago by jhpalmieri

apply on top of the other patch

comment:4 in reply to: ↑ 3 Changed 12 years ago by nthiery

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 12 years ago by nthiery

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

comment:6 Changed 12 years ago by nthiery

  • Summary changed from [with patch, needs work] Implement view(object, viewer='pdf') and view(object, tightpage = True) to [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 12 years ago by nthiery

Apply only this one (it includes the doc patch)

Changed 12 years ago by jhpalmieri

apply on top of the other patch

comment:7 Changed 12 years ago by jhpalmieri

  • Summary changed from [with patch, needs review] Implement view(object, viewer='pdf') and view(object, tightpage = True) to [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 12 years ago by nthiery

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

comment:9 Changed 12 years ago by mvngu

  • Merged in set to Sage 4.1.1.alpha1
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.