mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Move latex macros for easier maintenance
This commit is contained in:
parent
28226b59c5
commit
5e6d372929
@ -656,10 +656,6 @@
|
|||||||
\let\OriginalVerbatim \Verbatim
|
\let\OriginalVerbatim \Verbatim
|
||||||
\let\endOriginalVerbatim\endVerbatim
|
\let\endOriginalVerbatim\endVerbatim
|
||||||
|
|
||||||
% if the available space on page is less than \literalblockneedspace, insert pagebreak
|
|
||||||
\newcommand{\sphinxliteralblockneedspace}{5\baselineskip}
|
|
||||||
\newcommand{\sphinxliteralblockwithoutcaptionneedspace}{1.5\baselineskip}
|
|
||||||
|
|
||||||
% for captions of literal blocks
|
% for captions of literal blocks
|
||||||
% also define `\theH...` macros for hyperref
|
% also define `\theH...` macros for hyperref
|
||||||
\newcounter{literalblock}
|
\newcounter{literalblock}
|
||||||
@ -679,38 +675,6 @@
|
|||||||
% analogous to \listoffigures, but for the code listings (foo = chosen title.)
|
% analogous to \listoffigures, but for the code listings (foo = chosen title.)
|
||||||
\newcommand*{\ext@literalblock}{lol}
|
\newcommand*{\ext@literalblock}{lol}
|
||||||
|
|
||||||
% The title (caption) is specified from outside as macro \sphinxVerbatimTitle.
|
|
||||||
% \sphinxVerbatimTitle is reset to empty after each use of Verbatim.
|
|
||||||
\newcommand*\sphinxVerbatimTitle {}
|
|
||||||
% This box to typeset the caption before framed.sty multiple passes for framing.
|
|
||||||
\newbox\spx@Verbatim@TitleBox
|
|
||||||
% This is a workaround to a "feature" of French lists, which shows when non-
|
|
||||||
% paragraph material immediately follows a list. A priori usable generally
|
|
||||||
% as it does only \par for normal situations.
|
|
||||||
\newcommand*\sphinxvspacefixafterfrenchlists{%
|
|
||||||
\ifvmode\ifdim\lastskip<\z@ \vskip\parskip\fi\else\par\fi
|
|
||||||
}
|
|
||||||
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
|
|
||||||
\newcommand*\sphinxLiteralBlockLabel {}
|
|
||||||
\newcommand*\sphinxSetupCaptionForVerbatim [1]
|
|
||||||
{%
|
|
||||||
\sphinxvspacefixafterfrenchlists
|
|
||||||
\needspace{\sphinxliteralblockneedspace}%
|
|
||||||
% insert a \label via \sphinxLiteralBlockLabel
|
|
||||||
% reset to normal the color for the literal block caption
|
|
||||||
% the caption inserts \abovecaptionskip whitespace above itself (usually 10pt)
|
|
||||||
% there is also \belowcaptionskip but it is usually zero, hence the \smallskip
|
|
||||||
\def\sphinxVerbatimTitle
|
|
||||||
{\py@NormalColor
|
|
||||||
\captionof{literalblock}{\sphinxLiteralBlockLabel #1}\smallskip }%
|
|
||||||
}
|
|
||||||
\newcommand*\sphinxSetupCodeBlockInFootnote {%
|
|
||||||
\fvset{fontsize=\footnotesize}\let\caption\sphinxfigcaption
|
|
||||||
\sphinxverbatimwithminipagetrue % reduces vertical spaces
|
|
||||||
% we counteract float.sty's \caption which does \@normalsize
|
|
||||||
\let\normalsize\footnotesize\let\@parboxrestore\relax
|
|
||||||
\abovecaptionskip \smallskipamount \belowcaptionskip \z@skip}
|
|
||||||
|
|
||||||
\newif\ifspx@inframed % flag set if we are already in a framed environment
|
\newif\ifspx@inframed % flag set if we are already in a framed environment
|
||||||
% if forced use of minipage encapsulation is needed (e.g. table cells)
|
% if forced use of minipage encapsulation is needed (e.g. table cells)
|
||||||
\newif\ifsphinxverbatimwithminipage \sphinxverbatimwithminipagefalse
|
\newif\ifsphinxverbatimwithminipage \sphinxverbatimwithminipagefalse
|
||||||
@ -841,6 +805,38 @@
|
|||||||
{\kern\fontdimen2\font}%
|
{\kern\fontdimen2\font}%
|
||||||
}%
|
}%
|
||||||
|
|
||||||
|
% if the available space on page is less than \literalblockneedspace, insert pagebreak
|
||||||
|
\newcommand{\sphinxliteralblockneedspace}{5\baselineskip}
|
||||||
|
\newcommand{\sphinxliteralblockwithoutcaptionneedspace}{1.5\baselineskip}
|
||||||
|
% The title (caption) is specified from outside as macro \sphinxVerbatimTitle.
|
||||||
|
% \sphinxVerbatimTitle is reset to empty after each use of Verbatim.
|
||||||
|
\newcommand*\sphinxVerbatimTitle {}
|
||||||
|
% This box to typeset the caption before framed.sty multiple passes for framing.
|
||||||
|
\newbox\sphinxVerbatim@TitleBox
|
||||||
|
% This is a workaround to a "feature" of French lists, when literal block
|
||||||
|
% follows immediately; usable generally (does only \par then), a priori...
|
||||||
|
\newcommand*\sphinxvspacefixafterfrenchlists{%
|
||||||
|
\ifvmode\ifdim\lastskip<\z@ \vskip\parskip\fi\else\par\fi
|
||||||
|
}
|
||||||
|
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
|
||||||
|
\newcommand*\sphinxLiteralBlockLabel {}
|
||||||
|
\newcommand*\sphinxSetupCaptionForVerbatim [1]
|
||||||
|
{%
|
||||||
|
\sphinxvspacefixafterfrenchlists
|
||||||
|
\needspace{\sphinxliteralblockneedspace}%
|
||||||
|
% insert a \label via \sphinxLiteralBlockLabel
|
||||||
|
% reset to normal the color for the literal block caption
|
||||||
|
\def\sphinxVerbatimTitle
|
||||||
|
{\py@NormalColor\sphinxcaption{\sphinxLiteralBlockLabel #1}}%
|
||||||
|
}
|
||||||
|
\newcommand*\sphinxSetupCodeBlockInFootnote {%
|
||||||
|
\fvset{fontsize=\footnotesize}\let\caption\sphinxfigcaption
|
||||||
|
\sphinxverbatimwithminipagetrue % reduces vertical spaces
|
||||||
|
% we counteract \caption issueing \@normalsize
|
||||||
|
% this all happens in a group
|
||||||
|
\let\normalsize\footnotesize\let\@parboxrestore\relax
|
||||||
|
\abovecaptionskip \smallskipamount \belowcaptionskip \z@skip
|
||||||
|
}
|
||||||
% needed to create wrapper environments of fancyvrb's Verbatim
|
% needed to create wrapper environments of fancyvrb's Verbatim
|
||||||
\newcommand*{\sphinxVerbatimEnvironment}{\gdef\FV@EnvironName{sphinxVerbatim}}
|
\newcommand*{\sphinxVerbatimEnvironment}{\gdef\FV@EnvironName{sphinxVerbatim}}
|
||||||
% Sphinx <1.5 optional argument was in fact mandatory. It is now really
|
% Sphinx <1.5 optional argument was in fact mandatory. It is now really
|
||||||
|
Loading…
Reference in New Issue
Block a user