Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sphinxlatexshadowbox.sty « texinputs « sphinx - github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d6c78666cf9fb53cb7cbda107057f7e1f74ecfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%% TOPIC AND CONTENTS BOXES
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexshadowbox.sty}[2021/01/27 sphinxShadowBox]

% Provides support for this output mark-up from Sphinx latex writer:
%
% - sphinxShadowBox (environment)
%
% Dependencies (they do not need to be defined at time of loading):
%
% - of course the various colour and dimension options handled via sphinx.sty
% - dimension register \spx@image@maxheight from sphinxlatexgraphics.sty
% - \savenotes/\spewnotes from sphinxpackagefootnote
% - \ifspx@inframed defined in sphinx.sty
%
% Requires:
\RequirePackage{framed}

% Again based on use of "framed.sty", this allows breakable framed boxes.
\long\def\spx@ShadowFBox#1{%
  \leavevmode\begingroup
  % first we frame the box #1
  \setbox\@tempboxa
   \hbox{\vrule\@width\sphinxshadowrule
         \vbox{\hrule\@height\sphinxshadowrule
               \kern\sphinxshadowsep
               \hbox{\kern\sphinxshadowsep #1\kern\sphinxshadowsep}%
               \kern\sphinxshadowsep
               \hrule\@height\sphinxshadowrule}%
         \vrule\@width\sphinxshadowrule}%
  % Now we add the shadow, like \shadowbox from fancybox.sty would do
  \dimen@\dimexpr.5\sphinxshadowrule+\sphinxshadowsize\relax
  \hbox{\vbox{\offinterlineskip
              \hbox{\copy\@tempboxa\kern-.5\sphinxshadowrule
                    % add shadow on right side
                    \lower\sphinxshadowsize
                          \hbox{\vrule\@height\ht\@tempboxa \@width\dimen@}%
                    }%
              \kern-\dimen@ % shift back vertically to bottom of frame
              % and add shadow at bottom
              \moveright\sphinxshadowsize
                    \vbox{\hrule\@width\wd\@tempboxa \@height\dimen@}%
              }%
        % move left by the size of right shadow so shadow adds no width
        \kern-\sphinxshadowsize
       }%
  \endgroup
}

% use framed.sty to allow page breaks in frame+shadow
% works well inside Lists and Quote-like environments
% produced by ``topic'' directive (or local contents)
% could nest if LaTeX writer authorized it
\newenvironment{sphinxShadowBox}
  {\def\FrameCommand {\spx@ShadowFBox }%
   \advance\spx@image@maxheight
   -\dimexpr2\sphinxshadowrule
           +2\sphinxshadowsep
           +\sphinxshadowsize
           +\baselineskip\relax
   % 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
   % typical of center environment as used in Sphinx <= 1.4.1
   % the \noindent has the effet of an extra blank line on top, to
   % imitate closely the layout from Sphinx <= 1.4.1; the \FrameHeightAdjust
   % will put top part of frame on this baseline.
   \def\FrameHeightAdjust {\baselineskip}%
   % use package footnote to handle footnotes
   \savenotes
   \trivlist\item\noindent
    % use a minipage if we are already inside a framed environment
    \ifspx@inframed\begin{minipage}{\linewidth}\fi
    \MakeFramed {\spx@inframedtrue
    % framed.sty puts into "\width" the added width (=2shadowsep+2shadowrule)
    % adjust \hsize to what the contents must use
    \advance\hsize-\width
    % adjust LaTeX parameters to behave properly in indented/quoted contexts
    \FrameRestore
    % typeset the contents as in a minipage (Sphinx <= 1.4.1 used a minipage and
    % itemize/enumerate are therein typeset more tightly, we want to keep
    % that). We copy-paste from LaTeX source code but don't do a real minipage.
    \@pboxswfalse
    \let\@listdepth\@mplistdepth \@mplistdepth\z@
    \@minipagerestore
    \@setminipage
    }%
  }%
  {% insert the "endminipage" code
    \par\unskip
    \@minipagefalse
   \endMakeFramed
     \ifspx@inframed\end{minipage}\fi
   \endtrivlist
   % output the stored footnotes
   \spewnotes
  }

\endinput