From 53ead2a0d9cbd0ab63eca2272ff51a913a9cc153 Mon Sep 17 00:00:00 2001 From: jfbu Date: Mon, 11 Nov 2019 10:11:34 +0100 Subject: [PATCH] LaTeX: fix #6809 --- CHANGES | 2 ++ sphinx/texinputs/sphinx.sty | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 68b6b1b19..0b0e0c2b0 100644 --- a/CHANGES +++ b/CHANGES @@ -54,6 +54,8 @@ Bugs fixed * #6001: LaTeX does not wrap long code lines at backslash character * #6804: LaTeX: PDF build breaks if admonition of danger type contains code-block long enough not to fit on one page +* #6809: LaTeX: code-block in a danger type admonition can easily spill over + bottom of page Testing -------- diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 2ae4f5e1c..0acdac989 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -1290,12 +1290,26 @@ \endOriginalVerbatim \ifspx@inframed \egroup % finish \sphinxVerbatim@ContentsBox vbox + \nobreak % update page totals \ifdim\dimexpr\ht\sphinxVerbatim@ContentsBox+ \dp\sphinxVerbatim@ContentsBox+ \ht\sphinxVerbatim@TitleBox+ - \dp\sphinxVerbatim@TitleBox>.9\textheight + \dp\sphinxVerbatim@TitleBox+ + 2\fboxsep+2\fboxrule+ + % try to account for external frame parameters + \FrameSep+\FrameRule+ + % Usage here of 2 baseline distances is empirical. + % In border case where code-block fits barely in remaining space, + % it gets framed and looks good but the outer frame may continue + % on top of next page and give (if no contents after code-block) + % an empty framed line, as testing showed. + 2\baselineskip+ + % now add all to accumulated page totals and compare to \pagegoal + \pagetotal+\pagedepth>\pagegoal % long contents: do not \MakeFramed. Do make a caption (either before or % after) if title exists. Continuation hints across pagebreaks dropped. + % FIXME? a bottom caption may end up isolated at top of next page + % (no problem with a top caption, which is default) \spx@opt@verbatimwithframefalse \def\sphinxVerbatim@Title{\noindent\box\sphinxVerbatim@TitleBox\par}% \sphinxVerbatim@Before