Fix cropped LaTeX previews and PGF rendering in view() - #42620
Open
cxzhong wants to merge 2 commits into
Open
Conversation
|
Documentation preview for this PR (built with commit 98c89dd; changes) is ready! 🎉 |
cxzhong
marked this pull request as ready for review
August 4, 2026 07:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
previewtight-page cropping work with LuaLaTeX without adding a globalluatex85dependency;pageenvironment selected bypreview;view()andpdf()and add regression doctests.Root cause
Recent LuaTeX versions renamed the pdfTeX primitives still used by the
previewpackage, sopreviewproduced a normal full-size page instead of a tightly cropped page. This change defines only the five compatibility aliases thatpreviewuses, and only when LuaTeX exposes the renamed primitives.Separately,
_latex_file_rendered PGF through a resize box but left that box outside thepageenvironment, sopreviewdid not capture it. The resize box is now enclosed inpagewhen preview mode is active.This is a revised approach to #41445. It avoids requiring the optional
luatex85package for every generated LaTeX document and does not route ordinary TikZ expressions out of their existing math mode.Fixes #41413.
Fixes #41443.
Validation
git diff --checksrc/sage/misc/latex.pyrelintwith warnings treated as errors5.981 x 7.42 pt11.362 x 11.362 ptPDF29.745 x 29.745 ptPDFThe full Sage doctest suite was not run locally because the available environment does not include the GAP executable; GitHub CI will run the repository test matrix.