Repository navigation
latex: hint that code-blocks continue on next page (closes #3764) - #3792
Conversation
| before or after, but this is accessible currently only by re-defining some | ||
| macros with complicated LaTeX syntax from :file:`sphinx.sty`. | ||
|
|
||
| ``verbatimhintscontinuation`` |
There was a problem hiding this comment.
the name is not too good
| macros with complicated LaTeX syntax from :file:`sphinx.sty`. | ||
|
|
||
| ``verbatimhintscontinuation`` | ||
| default ``true``. Boolean to specify if code blocks which happen to be split |
There was a problem hiding this comment.
with default to false we could possibly merge in stable, as it is then only refactoring of non api code, with same output
| <%= numfig_format %> | ||
| <%= pageautorefname %> | ||
| \newcommand{\sphinxVerbatimContinuedText}{\footnotesize(<%= _('continued from previous page') %>)} | ||
| \newcommand{\sphinxVerbatimContinuesText}{\footnotesize(<%= _('continues on next page') %>)} |
There was a problem hiding this comment.
as indicated in #3791 it seems gettext did not pick strings from longtable templates so I guess one will have to be careful about latex template as well
There was a problem hiding this comment.
should I add string option to 'sphinxsetup' such as verbatimcontinued, verbatimcontinues ? with current code, user can use 'preamble' key and \renewcommand. With options, I need to then delay the definitions corresponding to the user options to at begin document. The latex file is then less understandable. Or, we move the lines above to before loading sphinx.sty
There was a problem hiding this comment.
I think .sty file is usually used for modify styles and macros in LaTeX world.
So I feel preamble key is better to do that.
Note: it might be better to allow user's .sty file instead of preamble key.
Now the key became much important, but it is boring to maintain it in conf.py.
| % verbatim | ||
| \DeclareBoolOption[true]{verbatimwithframe} | ||
| \DeclareBoolOption[true]{verbatimwrapslines} | ||
| \DeclareBoolOption[true]{verbatimhintscontinuation} |
There was a problem hiding this comment.
see comment above about using rather false here
| \hskip\@totalleftmargin | ||
| \hskip-\fboxsep\hskip-\fboxrule | ||
| #1{VerbatimBorderColor}{VerbatimColor}{#2}% | ||
| \spx@fcolorbox{VerbatimBorderColor}{VerbatimColor}{#1}{#2}{#3}% |
There was a problem hiding this comment.
formerly, special framing was used only to "glue" caption text to frame. Now we use it for continuation strings, hence always here \spx@fcolorbox. The extra parameters are the above and below text.
| \def\spx@fcolorbox #1#2% | ||
| {\color@b@x {\fboxsep\z@\color{#1}\spx@VerbatimFBox}{\color{#2}}}% | ||
| \long\def\spx@fcolorbox #1#2#3#4% | ||
| {\color@b@x {\color{#1}\spx@VerbatimFBox{#3}{#4}}{\color{#2}}}% |
There was a problem hiding this comment.
formerly \fboxsep was set to zero, for the frame to touch the colored area
now, \spx@VerbatimFBox does not use \fboxsep so it is not needed to set it to zero
| \def\sphinxVerbatimLastFrameCommand | ||
| {\spx@colorbox\sphinxVerbatimContinued{}} | ||
|
|
||
| \newcommand\sphinxVerbatimContinued{% |
There was a problem hiding this comment.
this macro maybe customized by knowledgeable LaTeX user
|
I can't read the LaTeX macros well, so I will try to build PDF on my local later. |
|
sure I can wait ;-) a priori this is new feature hence for 1.7, although it could be merged into 1.6.x series if we set the default value of Even if we introduce at 1.7 possibility to use |
|
by the way, I forgot to mention the refactoring of LaTeX literal blocks in this PR makes possible now to get the code-block captions below rather than, as currently, above the frame. |
|
Did you remove borders of code-block? Personally I loved it. |
|
To remove borders of code-block, you need |
|
In my local, the border is disabled by default. Even if I set |
|
thanks for attentive review @tk0miya! this is not intended, and I confirmed it at my locale. I will fix that later... at some point I started testing with only background color. It worked fine in some earlier version with border. I must have done some latex bug afterwards. Thanks! |
|
There was a missing brace pair at e1d7e3f#diff-f6432e57ae706b42894b186ffe699da0R727. As a result some |
| % note that the caption brings \abovecaptionskip top vertical space | ||
| \moveright\dimexpr\fboxrule+.5\wd\@tempboxa | ||
| \hb@xt@\z@{\hss\unhcopy\spx@VerbatimTitleBox\hss}\fi | ||
| \setbox\@tempboxa\hbox{{#3}}% contents with background color |
There was a problem hiding this comment.
The extra brace pair: \hbox{{#3}} is important because #3 contains some \color command for the background. Without the extra braces, this colour contaminates the border. As the background is usually white, this means the border disappears.
|
Thanks for confirmation @tk0miya ;-).
Do you have opinion on 1. and 2. ? |
|
1c33784 to
5673e46
Compare
|
Thanks for review @tk0miya I have rebased on stable
In my testing with default |
5673e46 to
c2277ae
Compare
|
For 1.7 I will make a PR which will allow to customize:
And I have added At 1.7, the horizontal positioning will be customized via a If no objection I will merge this to stable soon. |
|
Thanks for review @tk0miya I have now merged and will make a PR on master for caption position of literal blocks. |
This adds new key for
'sphinxsetup'. Provisory name isverbatimhintscontinuation.The default is true and the effect is to print continuation hints when a code-block gets split in PDF output on multiple pages.
However, if default value of
verbatimhintscontinuationwasfalsethere would be backward compatibility, so it could be merged in stable.Relates
Currently the strings added to
latex.tex_thave no translation. They are apart from an uppercase letter same as those fromlongtable.tex_t. See #3791 in this context.