New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

literal_block and its caption has been separated by pagebreak in LaTeX output #2262

Closed
tk0miya opened this Issue Jan 23, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@tk0miya
Member

tk0miya commented Jan 23, 2016

Now, with sphinx-1.3.4, literal_block and its caption has been separated by pagebreak.
2016-01-23 23 53 38

@tk0miya

This comment has been minimized.

Show comment
Hide comment
@tk0miya

tk0miya Jan 23, 2016

Member

I attatched sample project to reproduce the problem.
2262.zip

Member

tk0miya commented Jan 23, 2016

I attatched sample project to reproduce the problem.
2262.zip

@andreacassioli

This comment has been minimized.

Show comment
Hide comment
@andreacassioli

andreacassioli Jan 28, 2016

Hi,
I am experiencing the same issue on Sphinx 1.3.5.

andreacassioli commented Jan 28, 2016

Hi,
I am experiencing the same issue on Sphinx 1.3.5.

jfbu added a commit to jfbu/sphinx that referenced this issue Feb 5, 2016

LaTeX captions of literal blocks now glued to framed verbatim
This could fix sphinx-doc#2262

Tested on top of 1.3.5 release.

The 1.3.5 Verbatim environment in sphinx.sty has many places allowing a
page break after the caption: from the \smallskip, and from the list,
and from the \MakeFramed because framed.sty explains it encourages page
breaks above it.

This commit sets up the caption from _inside_ the framed environment.

Test project on
https://github.com/sphinx-doc/sphinx/files/101910/2262.zip
compiles correctly. I have also tested with xcolor as its use has been
introduced in later commit 476f809.

More extensive tests needed.

	modified:   sphinx/texinputs/sphinx.sty
	modified:   sphinx/writers/latex.py

jfbu added a commit to jfbu/sphinx that referenced this issue Feb 5, 2016

LaTeX captions of literal blocks now glued to framed verbatim
This could fix sphinx-doc#2262

Tested on top of 1.3.5 release.

The 1.3.5 Verbatim environment in sphinx.sty has many places allowing a
page break after the caption: from the \smallskip, and from the list,
and from the \MakeFramed because framed.sty explains it encourages page
breaks above it.

This commit sets up the caption from _inside_ the framed environment.

Test project on
https://github.com/sphinx-doc/sphinx/files/101910/2262.zip
compiles correctly. I have also tested with xcolor as its use has been
introduced in later commit 476f809.

More extensive tests needed.

	modified:   sphinx/texinputs/sphinx.sty
	modified:   sphinx/writers/latex.py
@jfbu

This comment has been minimized.

Show comment
Hide comment
@jfbu

jfbu Feb 5, 2016

Contributor

Here are some images to illustrate the effect of the PR #2297 on the provided test files

capture d ecran 2016-02-05 a 18 13 18

After removing one item, no change, after removing two items, one gets
capture d ecran 2016-02-05 a 18 15 43

To check that caption counter is not increased too many times, here is with the test file extended to include a second literal-block:

capture d ecran 2016-02-05 a 18 13 57

Contributor

jfbu commented Feb 5, 2016

Here are some images to illustrate the effect of the PR #2297 on the provided test files

capture d ecran 2016-02-05 a 18 13 18

After removing one item, no change, after removing two items, one gets
capture d ecran 2016-02-05 a 18 15 43

To check that caption counter is not increased too many times, here is with the test file extended to include a second literal-block:

capture d ecran 2016-02-05 a 18 13 57

@jfbu

This comment has been minimized.

Show comment
Hide comment
@jfbu

jfbu Feb 5, 2016

Contributor

If one suppresses two \item's from the produced test.tex file, and then adds

    \vskip .56298cm

immediately after the itemize environment,
the frame starts like in the second picture of last comment (with SPHINXOPTS = moved to next page). But with a slightly bigger skip

    \vskip .56299cm

it starts like in the first picture, the whole thing inclusive of caption being moved to next page. This shows the PR does fix the page break problems, however I don't know enough of sphinx's latex builder yet to ascertain if other areas may be impacted (other than direct insertion by user of a framed environment, which was already impacted by earlier sphinx.sty and latex.py).

Contributor

jfbu commented Feb 5, 2016

If one suppresses two \item's from the produced test.tex file, and then adds

    \vskip .56298cm

immediately after the itemize environment,
the frame starts like in the second picture of last comment (with SPHINXOPTS = moved to next page). But with a slightly bigger skip

    \vskip .56299cm

it starts like in the first picture, the whole thing inclusive of caption being moved to next page. This shows the PR does fix the page break problems, however I don't know enough of sphinx's latex builder yet to ascertain if other areas may be impacted (other than direct insertion by user of a framed environment, which was already impacted by earlier sphinx.sty and latex.py).

jfbu added a commit to jfbu/sphinx that referenced this issue Feb 10, 2016

Address #2262 (latex): avoid pagebreaks after captions of literal blocks
This could fix sphinx-doc#2262

The 1.3.5 Verbatim environment from sphinx.sty has many places allowing
a page break after the caption: from the \smallskip, from the list
environment, and from the \MakeFramed: indeed framed package
documentation explains that it encourages page breaks above it.

The only way to avoid the pagebreaks is to put the caption inside the
environment whic is started by \MakeFramed. However, as this environment
typesets multiple times its contents, we must inhibit within it the
increase of counters (only the literal-block counter is concerned), this
is done thanks to a switch provided by the package amsmath which is
already loaded by sphinx.sty.

	modified:   sphinx/texinputs/sphinx.sty
	modified:   sphinx/writers/latex.py
	modified:   tests/test_directive_code.py

jfbu added a commit to jfbu/sphinx that referenced this issue Feb 14, 2016

Fix #2262 (latex): avoid pagebreaks after captions of literal blocks
This could fix sphinx-doc#2262
and also perhaps sphinx-doc#2319

As now the caption is set in an environment it appears to possibly solve
also issue #2319 Table counter is overrided by code-block's in LaTeX

The parent commit used only \FirstFrameCommand of latex package
framed, but \FrameCommand also must be customized in case the
framed contents fit on a single page. This is fixed here.

	modified:   sphinx/texinputs/sphinx.sty

@tk0miya tk0miya closed this in #2297 Mar 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment