LaTeX captions of literal blocks now glued to framed verbatim#2297
LaTeX captions of literal blocks now glued to framed verbatim#2297tk0miya merged 6 commits intosphinx-doc:masterfrom
Conversation
|
Sorry, I issued the PR too early. There is an issue with framed environment expanding multiple times its contents, hence the caption number is increased at least twice. I will look for a work-around. |
|
I know nothing to travis-ci, but it appears the test fails simply because the latex builder has been modified, hence some |
…iteral 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
0347395 to
89e8cb3
Compare
|
I have updated |
…al 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 sphinx-doc#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
|
Could also solve #2319 |
|
@jfbu Sorry, I cannnot determine this change is stable or not (I'm not good at LaTeX macros...) |
| % first portion of split frames: | ||
| \let\FirstFrameCommand\FrameCommand | ||
|
|
||
| % Unneeded %'s after control words removed. |
There was a problem hiding this comment.
Could you remove this line? This is not a description of macros.
Please note the description of codes (cf. purpose, behaviors and how it works).
modified: sphinx/texinputs/sphinx.sty
|
@tk0miya It is hard for me to answer with confidence, as I am not familiar enough yet with Sphinx latex writer, and I don't know all circumstances which trigger use of |
modified: sphinx/texinputs/sphinx.sty
|
Sorry for late response. I read your changes now, and it looks good to me. Before merging, I want to hear you that is this conflicts with minted (ref #2304). |
|
@tk0miya I can confirm that this patch is completely independent from the ones discussed in #2304.
Regarding #2304, I am not too much favorable to The present PR is not concerned with |
|
I will update the PR for better choice of macro names in the patched sphinx.sty. |
modified: sphinx/texinputs/sphinx.sty modified: sphinx/writers/latex.py modified: tests/test_directive_code.py
modified: tests/test_directive_code.py
|
Thank you for comment and update! |
LaTeX captions of literal blocks now glued to framed verbatim
|
Just merged. Thank you for contribution! |
Needed in particular for: - use of \iffirstchoice@ at commit 9d82cad (PR sphinx-doc#2297) - use of \text at commit 488ee52 addressing issue sphinx-doc#2501
This could fix #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.