diff options
| author | jfbu <jfbu@free.fr> | 2019-01-13 10:37:34 +0100 |
|---|---|---|
| committer | jfbu <jfbu@free.fr> | 2019-01-13 10:37:34 +0100 |
| commit | 75afed1549cd273c5b69e4388b2a8ab77cd523cc (patch) | |
| tree | 2971f72afdefd95447f72d2333d4b0c8163f557c /sphinx/texinputs | |
| parent | 6817cd398453c344abb8b3906eb2cd22b0e6ece1 (diff) | |
| parent | 6e7e0692836e10eb0b32b6cfa5f7db0e63379302 (diff) | |
| download | sphinx-git-75afed1549cd273c5b69e4388b2a8ab77cd523cc.tar.gz | |
Merge branch '1.8'
Diffstat (limited to 'sphinx/texinputs')
| -rw-r--r-- | sphinx/texinputs/sphinx.sty | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index b898e599b..b4708eb0e 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -6,7 +6,7 @@ % \NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{sphinx}[2018/12/16 v1.8.3 LaTeX package (Sphinx markup)] +\ProvidesPackage{sphinx}[2019/01/12 v1.8.4 LaTeX package (Sphinx markup)] % provides \ltx@ifundefined % (many packages load ltxcmds: graphicx does for pdftex and lualatex but @@ -716,10 +716,38 @@ \setbox\spx@image@box\box\voidb@x % clear memory \includegraphics[#1,width=\linewidth]{#2}% \else + \setbox\spx@image@box\box\voidb@x % clear memory \includegraphics[#1]{#2}% \fi \fi } +% \sphinxsafeincludegraphics resizes images larger than the line width, +% or taller than about the text height (whether or not height/width options +% were used). This is requested to avoid a crash with \MakeFramed as used by +% sphinxShadowBox (topic/contents) and sphinxheavybox (admonitions), and also +% by sphinxVerbatim (but a priori no image inclusion there). +\newdimen\spx@image@maxheight +% default maximal setting will get reduced by sphinxShadowBox/sphinxheavybox +\AtBeginDocument{\spx@image@maxheight\textheight} +\newcommand*{\sphinxsafeincludegraphics}[2][]{% + \gdef\spx@includegraphics@options{#1}% + \setbox\spx@image@box\hbox{\includegraphics[#1,draft]{#2}}% + \in@false + \ifdim \wd\spx@image@box>\linewidth + \g@addto@macro\spx@includegraphics@options{,width=\linewidth}% + \in@true + \fi + % no rotation, no need to worry about depth + \ifdim \ht\spx@image@box>\spx@image@maxheight + \g@addto@macro\spx@includegraphics@options{,height=\spx@image@maxheight}% + \in@true + \fi + \ifin@ + \g@addto@macro\spx@includegraphics@options{,keepaspectratio}% + \fi + \setbox\spx@image@box\box\voidb@x % clear memory + \expandafter\includegraphics\expandafter[\spx@includegraphics@options]{#2}% +}% %% FIGURE IN TABLE @@ -1335,6 +1363,12 @@ % could nest if LaTeX writer authorized it \newenvironment{sphinxShadowBox} {\def\FrameCommand {\spx@ShadowFBox }% + \advance\spx@image@maxheight + -\dimexpr2\sphinxshadowrule + +2\sphinxshadowsep + +\sphinxshadowsize + +\baselineskip\relax + \let\sphinxincludegraphics\sphinxsafeincludegraphics % configure framed.sty not to add extra vertical spacing \ltx@ifundefined{OuterFrameSep}{}{\OuterFrameSep\z@skip}% % the \trivlist will add the vertical spacing on top and bottom which is @@ -1417,6 +1451,11 @@ \newenvironment{sphinxheavybox}{\par \setlength{\FrameRule}{\spx@notice@border}% \setlength{\FrameSep}{\dimexpr.6\baselineskip-\FrameRule\relax} + \advance\spx@image@maxheight + -\dimexpr2\FrameRule + +2\FrameSep + +\baselineskip\relax % will happen again if nested, needed indeed! + \let\sphinxincludegraphics\sphinxsafeincludegraphics % configure framed.sty's parameters to obtain same vertical spacing % as for "light" boxes. We need for this to manually insert parskip glue and % revert a skip done by framed before the frame. |
