summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/thmtools/thmdef-shaded.dtx
blob: 55559b3a1f89a04854606a8806e6bfa6d2a85f70 (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
% \iffalse meta-comment
%
% Copyright (C) 2010 by Ulrich M. Schwarz
% See file COPYING for more details.
%\fi
%
%\iffalse (hide this from DocInput)
%<*shaded>
%\fi
%    \begin{macrocode}
  \define@key{thmdef}{shaded}[{}]{%
  \thmt@trytwice{}{%
    \RequirePackage{shadethm}%
    \RequirePackage{thm-patch}%
    \addtotheorempreheadhook[\thmt@envname]{%
      \setlength\shadedtextwidth{\linewidth}%
      \kvsetkeys{thmt@shade}{#1}\begin{shadebox}}%
    \addtotheorempostfoothook[\thmt@envname]{\end{shadebox}}%
    }%
  }
%   There are some parameters you could set the default for (try them as is,
% first).
%    (i) shadethmcolor  The shading color of the background.  See the
%      documentation for the color package, but with a `gray' model, I find .97
%      looks good out of my printer, while a darker shade like .92 is needed
%      to make it copy well.  (Black is  0, white is 1.)
%    (i*) shaderulecolor  The shading color of the border of the shaded box.
%      See (i).  If \shadeboxrule is set to 0pt then this won't print anyway.
%    (i**) shadeboxrule  The width of the border around the shading.  Set it to
%      0pt (not just 0) to make it disappear.
%    (i***) shadeboxsep  The length by which the shade box surrounds the text.
\define@key{thmt@shade}{textwidth}{\setlength\shadedtextwidth{#1}}
\define@key{thmt@shade}{bgcolor}{\thmt@definecolor{shadethmcolor}{#1}}
\define@key{thmt@shade}{rulecolor}{\thmt@definecolor{shaderulecolor}{#1}}
\define@key{thmt@shade}{rulewidth}{\setlength\shadeboxrule{#1}}
\define@key{thmt@shade}{margin}{\setlength\shadeboxsep{#1}}

\def\thmt@colorlet#1#2{%
  %\typeout{don't know how to let color `#1' be like color `#2'!}%
  \@xa\let\csname\string\color@#1\@xa\endcsname
    \csname\string\color@#2\endcsname
  % this is dubious at best, we don't know what a backend does.
}
\AtBeginDocument{%
  \ifcsname colorlet\endcsname
    \let\thmt@colorlet\colorlet
  \fi
}

\def\thmt@drop@relax#1\relax{}
\def\thmt@definecolor#1#2{%
  \thmt@def@color{#1}#2\thmt@drop@relax 
    {gray}{0.5}%
    \thmt@colorlet{#1}{#2}%
  \relax
}
\def\thmt@def@color#1#2#{%
  \definecolor{#1}}
%    \end{macrocode}
%\iffalse (hide this from DocInput)
%</shaded>
%\fi