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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
\documentclass{article}
\usepackage{keyreader}[2012/11/01]
\usepackage{xcolor}
\usepackage{graphicx}
\makeatletter
% Choice keys with braced default:
\krddefinekeys[JKV]{jorg}{%
choice/key1/{A/X}/{
A/X.do=\def\currcolor{blue},
A/Y.do=\def\currcolor{green},
B/X.do=\def\currcolor{red},
B/Y.do=\def\currcolor{magenta}
}
/\def\val{Value of key1: #1}
;
choice/align/justified/{
center.do=\def\curralign##1{\hfil##1\hfil},
right.do=\def\curralign##1{\hfill##1},
left.do=\def\curralign##1{##1\hfill},
justified.do=\let\curralign\@iden
}
;
}
\krdpresetkeys[JKV]{jorg}{key1=A/X,align=justified}
\newcommand\jorgcommand[2][]{%
\krdsetkeys[JKV]{jorg}{#1}%
\endgraf\bigskip
\parbox{\hsize}{\centering\textbf{\textcolor{\currcolor}{\val}}}%
\endgraf
\parbox{\hsize}{\curralign{\textcolor{\currcolor}{#2}}}%
}
% Shadow box:
\newdimen\shadowsize
\krddefinekeys*[KV]{ebox}[mp@]{%
bool/frame/true;
bool+/shadow/true//
\mp@shadowtrue
\@@warning{Invalid value for 'shadow': 'true' assumed}
;
cmd/framecolor/black;
cmd/shadecolor/white;
cmd/shadowcolor/gray;
cmd/framesize/.4pt;
cmd/boxsize/.1\columnwidth;
cmd/shadowsize/1pt;
choice+/align/center/
center.do=\let\mp@alignright\hfil\let\mp@alignleft\hfil,
right.do=\let\mp@alignright\hfill\let\mp@alignleft\relax,
left.do=\let\mp@alignright\relax\let\mp@alignleft\hfill,
justified.do=\let\mp@alignright\relax\let\mp@alignleft\relax
//
\let\mp@alignright\hfil\let\mp@alignleft\hfil
\@@warning{Invalid value for 'align'; 'center' used}
;
}
\savevaluekeys[KV]{ebox}{frame,framecolor,framesize}
\krdpresetkeys[KV]{ebox}{%
frame,framecolor=black,shadecolor=white,framesize=0.5pt,boxsize,align
}
\krdpostsetkeys[KV]{ebox}{%
shadow=\usevalue{frame},shadowcolor=\usevalue{framecolor}!40,
shadowsize=\usevalue{framesize}*4
}
\newcommand*\ebox[2][]{%
\krdsetkeys[KV]{ebox}{#1}%
\begingroup
\ifmp@frame
\fboxrule=\dimexpr\mp@framesize\relax
\else
\fboxrule=0pt
\fi
\ifmp@shadow
\shadowsize=\dimexpr\mp@shadowsize\relax
\else
\shadowsize=0pt
\fi
\setbox0=\hbox{%
\fcolorbox{\mp@framecolor}{\mp@shadecolor}{%
\hbox to\mp@boxsize{%
\mp@alignright #2\mp@alignleft
}%
}%
}%
\hskip\shadowsize
\color{\mp@shadowcolor}%
\rule[-\dp0]{\wd0}{\the\dimexpr\ht0+\dp0\relax}%
\llap{\raisebox{\shadowsize}{\box0\hskip\shadowsize}}%
\endgroup
}
\makeatother
\begin{document}
\parindent-60pt
% Shadow boxes:
\scalebox{2}{%
\ebox[shadecolor=brown!70]{ebox1}%
\ebox[framecolor=magenta,boxsize=2cm,align=right]{ebox2}%
\ebox[shadow=false,framesize=1pt,framecolor=red,boxsize=1.5cm,align=left]{ebox3}%
\ebox[framesize=1pt,framecolor=green,shadowcolor=blue]{ebox4}%
\ebox[frame=false,shadow,shadowcolor=yellow,framesize=.5pt]{ebox5}%
}
% Choice keys:
\def\name#1{\texttt{\textcolor{black}{#1}}}
\def\atext{%
\name{choice} keys of the \name{keyreader} package.
}
\jorgcommand[key1=A/X,align=justified]{\atext}
\jorgcommand[key1=A/Y,align=center]{\atext}
\jorgcommand[key1=B/X,align=right]{\atext}
\jorgcommand[key1=B/Y,align=left]{\atext}
\jorgcommand{\atext}
% Invalid value for key1 ('x+y' not allowed):
% \jorgcommand[key1=x+y]{\atext}
\end{document}
|