-
Notifications
You must be signed in to change notification settings - Fork 2k
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
latex: hint that code-blocks continue on next page (closes #3764) #3792
Conversation
doc/latex.rst
Outdated
@@ -218,6 +218,16 @@ Here are the currently available options together with their default values. | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is not too good
doc/latex.rst
Outdated
@@ -218,6 +218,16 @@ Here are the currently available options together with their default values. | |||
before or after, but this is accessible currently only by re-defining some | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with default to false
we could possibly merge in stable, as it is then only refactoring of non api code, with same output
sphinx/templates/latex/latex.tex_t
Outdated
@@ -30,6 +30,8 @@ | |||
<%= contentsname %> | |||
<%= numfig_format %> | |||
<%= pageautorefname %> | |||
\newcommand{\sphinxVerbatimContinuedText}{\footnotesize(<%= _('continued from previous page') %>)} | |||
\newcommand{\sphinxVerbatimContinuesText}{\footnotesize(<%= _('continues on next page') %>)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
sphinx/texinputs/sphinx.sty
Outdated
@@ -256,6 +256,7 @@ | |||
% verbatim | |||
\DeclareBoolOption[true]{verbatimwithframe} | |||
\DeclareBoolOption[true]{verbatimwrapslines} | |||
\DeclareBoolOption[true]{verbatimhintscontinuation} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above about using rather false
here
% let the framing obey the current indentation (adapted from framed.sty's code). | ||
\hskip\@totalleftmargin | ||
\hskip-\fboxsep\hskip-\fboxrule | ||
#1{VerbatimBorderColor}{VerbatimColor}{#2}% | ||
\spx@fcolorbox{VerbatimBorderColor}{VerbatimColor}{#1}{#2}{#3}% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
sphinx/texinputs/sphinx.sty
Outdated
\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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
sphinx/texinputs/sphinx.sty
Outdated
\def\sphinxVerbatimLastFrameCommand | ||
{\spx@colorbox\sphinxVerbatimContinued{}} | ||
|
||
\newcommand\sphinxVerbatimContinued{% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
for details http://www.sphinx-doc.org/en/stable/latex.html#the-sphinx-latex-style-package-options |
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 |
sphinx/texinputs/sphinx.sty
Outdated
% 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed. LGTM!
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
verbatimhintscontinuation
wasfalse
there would be backward compatibility, so it could be merged in stable.Relates
Currently the strings added to
latex.tex_t
have no translation. They are apart from an uppercase letter same as those fromlongtable.tex_t
. See #3791 in this context.