summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/minibox/minibox.sty
blob: 039620799e940deec20c149a5a75a44e36aa9fa1 (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
%    \begin{macrocode}
\RequirePackage{expl3}
\ProvidesExplPackage
  {minibox}
  {2013/04/20}
  {0.2}
  {Another type of box.}
%    \end{macrocode}
%
%    \begin{macrocode}
\bool_new:N \l_minibox_frame_bool
\keys_define:nn {minibox}
 {
  frame .choice: ,
  frame / true  .code:n = { \bool_set_true:N  \l_minibox_frame_bool } ,
  frame / false .code:n = { \bool_set_false:N \l_minibox_frame_bool } ,
  frame .default:n  = { true } ,

  l .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {l} } ,
  c .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {c} } ,
  r .code:n = { \tl_set:Nn \l_minibox_tabular_preamble_tl {r} } ,

  t .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {t} } ,
  m .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {c} } ,
  b .code:n = { \tl_set:Nn \l_minibox_tabular_valign_tl {b} } ,

  rule .dim_set:N = \l_minibox_rule_dim ,
  pad  .dim_set:N = \l_minibox_pad_dim  ,
 }
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_new:Npn \miniboxsetup #1 { \keys_set:nn {minibox} {#1} }
\miniboxsetup {l,m,rule=\fboxrule,pad=\fboxsep}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\minibox[2][]
 {
  \group_begin:
  \keys_set:nn {minibox} {#1}
  \bool_if:NTF \l_minibox_frame_bool
   {
    \setlength\fboxrule{\l_minibox_rule_dim}
    \setlength\fboxsep{\l_minibox_pad_dim}
    \fbox
   }
   { \use:n }
   {
    \begin{tabular}
      [\l_minibox_tabular_valign_tl]
      { @{} \l_minibox_tabular_preamble_tl @{} }
     #2
    \end{tabular}
   }
  \group_end:
 }
%    \end{macrocode}