1*7f2fe78bSCy Schubert%% TOPIC AND CONTENTS BOXES 2*7f2fe78bSCy Schubert% 3*7f2fe78bSCy Schubert% change this info string if making any custom modification 4*7f2fe78bSCy Schubert\ProvidesFile{sphinxlatexshadowbox.sty}[2021/01/27 sphinxShadowBox] 5*7f2fe78bSCy Schubert 6*7f2fe78bSCy Schubert% Provides support for this output mark-up from Sphinx latex writer: 7*7f2fe78bSCy Schubert% 8*7f2fe78bSCy Schubert% - sphinxShadowBox (environment) 9*7f2fe78bSCy Schubert% 10*7f2fe78bSCy Schubert% Dependencies (they do not need to be defined at time of loading): 11*7f2fe78bSCy Schubert% 12*7f2fe78bSCy Schubert% - of course the various colour and dimension options handled via sphinx.sty 13*7f2fe78bSCy Schubert% - dimension register \spx@image@maxheight from sphinxlatexgraphics.sty 14*7f2fe78bSCy Schubert% - \savenotes/\spewnotes from sphinxpackagefootnote 15*7f2fe78bSCy Schubert% - \ifspx@inframed defined in sphinx.sty 16*7f2fe78bSCy Schubert% 17*7f2fe78bSCy Schubert% Requires: 18*7f2fe78bSCy Schubert\RequirePackage{framed} 19*7f2fe78bSCy Schubert 20*7f2fe78bSCy Schubert% Again based on use of "framed.sty", this allows breakable framed boxes. 21*7f2fe78bSCy Schubert\long\def\spx@ShadowFBox#1{% 22*7f2fe78bSCy Schubert \leavevmode\begingroup 23*7f2fe78bSCy Schubert % first we frame the box #1 24*7f2fe78bSCy Schubert \setbox\@tempboxa 25*7f2fe78bSCy Schubert \hbox{\vrule\@width\sphinxshadowrule 26*7f2fe78bSCy Schubert \vbox{\hrule\@height\sphinxshadowrule 27*7f2fe78bSCy Schubert \kern\sphinxshadowsep 28*7f2fe78bSCy Schubert \hbox{\kern\sphinxshadowsep #1\kern\sphinxshadowsep}% 29*7f2fe78bSCy Schubert \kern\sphinxshadowsep 30*7f2fe78bSCy Schubert \hrule\@height\sphinxshadowrule}% 31*7f2fe78bSCy Schubert \vrule\@width\sphinxshadowrule}% 32*7f2fe78bSCy Schubert % Now we add the shadow, like \shadowbox from fancybox.sty would do 33*7f2fe78bSCy Schubert \dimen@\dimexpr.5\sphinxshadowrule+\sphinxshadowsize\relax 34*7f2fe78bSCy Schubert \hbox{\vbox{\offinterlineskip 35*7f2fe78bSCy Schubert \hbox{\copy\@tempboxa\kern-.5\sphinxshadowrule 36*7f2fe78bSCy Schubert % add shadow on right side 37*7f2fe78bSCy Schubert \lower\sphinxshadowsize 38*7f2fe78bSCy Schubert \hbox{\vrule\@height\ht\@tempboxa \@width\dimen@}% 39*7f2fe78bSCy Schubert }% 40*7f2fe78bSCy Schubert \kern-\dimen@ % shift back vertically to bottom of frame 41*7f2fe78bSCy Schubert % and add shadow at bottom 42*7f2fe78bSCy Schubert \moveright\sphinxshadowsize 43*7f2fe78bSCy Schubert \vbox{\hrule\@width\wd\@tempboxa \@height\dimen@}% 44*7f2fe78bSCy Schubert }% 45*7f2fe78bSCy Schubert % move left by the size of right shadow so shadow adds no width 46*7f2fe78bSCy Schubert \kern-\sphinxshadowsize 47*7f2fe78bSCy Schubert }% 48*7f2fe78bSCy Schubert \endgroup 49*7f2fe78bSCy Schubert} 50*7f2fe78bSCy Schubert 51*7f2fe78bSCy Schubert% use framed.sty to allow page breaks in frame+shadow 52*7f2fe78bSCy Schubert% works well inside Lists and Quote-like environments 53*7f2fe78bSCy Schubert% produced by ``topic'' directive (or local contents) 54*7f2fe78bSCy Schubert% could nest if LaTeX writer authorized it 55*7f2fe78bSCy Schubert\newenvironment{sphinxShadowBox} 56*7f2fe78bSCy Schubert {\def\FrameCommand {\spx@ShadowFBox }% 57*7f2fe78bSCy Schubert \advance\spx@image@maxheight 58*7f2fe78bSCy Schubert -\dimexpr2\sphinxshadowrule 59*7f2fe78bSCy Schubert +2\sphinxshadowsep 60*7f2fe78bSCy Schubert +\sphinxshadowsize 61*7f2fe78bSCy Schubert +\baselineskip\relax 62*7f2fe78bSCy Schubert % configure framed.sty not to add extra vertical spacing 63*7f2fe78bSCy Schubert \ltx@ifundefined{OuterFrameSep}{}{\OuterFrameSep\z@skip}% 64*7f2fe78bSCy Schubert % the \trivlist will add the vertical spacing on top and bottom which is 65*7f2fe78bSCy Schubert % typical of center environment as used in Sphinx <= 1.4.1 66*7f2fe78bSCy Schubert % the \noindent has the effet of an extra blank line on top, to 67*7f2fe78bSCy Schubert % imitate closely the layout from Sphinx <= 1.4.1; the \FrameHeightAdjust 68*7f2fe78bSCy Schubert % will put top part of frame on this baseline. 69*7f2fe78bSCy Schubert \def\FrameHeightAdjust {\baselineskip}% 70*7f2fe78bSCy Schubert % use package footnote to handle footnotes 71*7f2fe78bSCy Schubert \savenotes 72*7f2fe78bSCy Schubert \trivlist\item\noindent 73*7f2fe78bSCy Schubert % use a minipage if we are already inside a framed environment 74*7f2fe78bSCy Schubert \ifspx@inframed\begin{minipage}{\linewidth}\fi 75*7f2fe78bSCy Schubert \MakeFramed {\spx@inframedtrue 76*7f2fe78bSCy Schubert % framed.sty puts into "\width" the added width (=2shadowsep+2shadowrule) 77*7f2fe78bSCy Schubert % adjust \hsize to what the contents must use 78*7f2fe78bSCy Schubert \advance\hsize-\width 79*7f2fe78bSCy Schubert % adjust LaTeX parameters to behave properly in indented/quoted contexts 80*7f2fe78bSCy Schubert \FrameRestore 81*7f2fe78bSCy Schubert % typeset the contents as in a minipage (Sphinx <= 1.4.1 used a minipage and 82*7f2fe78bSCy Schubert % itemize/enumerate are therein typeset more tightly, we want to keep 83*7f2fe78bSCy Schubert % that). We copy-paste from LaTeX source code but don't do a real minipage. 84*7f2fe78bSCy Schubert \@pboxswfalse 85*7f2fe78bSCy Schubert \let\@listdepth\@mplistdepth \@mplistdepth\z@ 86*7f2fe78bSCy Schubert \@minipagerestore 87*7f2fe78bSCy Schubert \@setminipage 88*7f2fe78bSCy Schubert }% 89*7f2fe78bSCy Schubert }% 90*7f2fe78bSCy Schubert {% insert the "endminipage" code 91*7f2fe78bSCy Schubert \par\unskip 92*7f2fe78bSCy Schubert \@minipagefalse 93*7f2fe78bSCy Schubert \endMakeFramed 94*7f2fe78bSCy Schubert \ifspx@inframed\end{minipage}\fi 95*7f2fe78bSCy Schubert \endtrivlist 96*7f2fe78bSCy Schubert % output the stored footnotes 97*7f2fe78bSCy Schubert \spewnotes 98*7f2fe78bSCy Schubert } 99*7f2fe78bSCy Schubert 100*7f2fe78bSCy Schubert\endinput 101