summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fbox/fbox.sty
blob: 24dd9a710647c877893d26b85952805b9c271d2f (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
101
102
103
104
105
106
107
108
109
110
111
112
%% This is file `fbox.sty',
%%
%% Copyright (C) 2019, 2020
%% Herbert Voss  <hvoss@tug.org>
%%
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%
% $Id: fbox.sty 1128 2020-01-03 20:57:59Z herbert $
%
% -------------------------------------
\ProvidesPackage{fbox}[2020/01/03 v. 0.04 allow parts of the frame (hv)]
%
\let\orig@fbox\fbox
\def\fb@lowerc@se#1{%     make \lowercase expandable
  \begingroup\edef\x{%
    \lowercase{\endgroup\def\noexpand\@tempa{#1}}}\x
}
%
\newif\if@fbox@star
\newif\if@fbox@space@left
\newif\if@fbox@space@right

\long\def\fbox{\@ifnextchar*{\@fbox@startrue\FBox@}{\@fbox@starfalse\FBox@*}}
\def\FBox@*{\@ifnextchar[\FBox@i\orig@fbox}
%
\def\FBox@i[#1]{%
  \if@fbox@star
    \@fbox@space@leftfalse
    \@fbox@space@rightfalse
  \else
    \@fbox@space@lefttrue
    \@fbox@space@righttrue
  \fi
  \ifx\relax#1\relax
    \@tempcntb=15
  \else
    \@tempcntb=\z@
    \fb@lowerc@se{#1}%
    \expandafter\FBox@ii\@tempa\@nil\relax
  \fi
  \FBox@iii
}
\def\FBox@ii#1#2\@nil{%
  \ifx#1t\advance\@tempcntb by 8                %  top
  \else
    \ifx#1l\advance\@tempcntb by 4              % left
      \if@fbox@star\@fbox@space@lefttrue\fi
    \else
      \ifx#1r\advance\@tempcntb by 2            % right
        \if@fbox@star\@fbox@space@righttrue\fi
      \else
         \ifx#1b\advance\@tempcntb by 1         % bottom
  \fi\fi\fi\fi
  \if\relax#2\relax\def\next{}\else\def\next{\FBox@ii#2\@nil}\fi
  \next
}
\def\FBox@iii#1{%
  \leavevmode
  \setbox\@tempboxa\hbox{%
    \color@begingroup
      \if@fbox@space@left\kern\fboxsep\fi{#1}\if@fbox@space@right\kern\fboxsep\fi
    \color@endgroup}%
  \@FrameB@x\relax}
%
\def\@FrameB@x#1{%
  \@tempdima\fboxrule
  \advance\@tempdima\fboxsep
  \advance\@tempdima\dp\@tempboxa
  \hbox{%
    \lower\@tempdima\hbox{%
      \vbox{%
        \ifnum\the\@tempcntb>8\relax
          \advance\@tempcntb by -8 
            \hrule\@height\fboxrule                       % top
        \fi
        \hbox{%
          \ifnum\@tempcntb>3
            \advance\@tempcntb by -4 
            \vrule\@width\fboxrule
          \fi                                             % left
          #1%
          \vbox{%
            \vskip\fboxsep
            \box\@tempboxa
            \vskip\fboxsep}%
          #1%
          \ifnum\@tempcntb>1\vrule\@width\fboxrule\fi}% right
          \ifodd\@tempcntb\hrule\@height\fboxrule\fi}%     bottom
    }%
  }%
}

\newsavebox\fpar@b@x

\long\def\fparbox{\@ifnextchar*{\@fbox@startrue\FParBox@}{\@fbox@starfalse\FParBox@*}}
\def\FParBox@*{\@ifnextchar[\FParBox@i\FParBox@ii}
\long\def\FParBox@i[#1]#2{%
  \savebox\fpar@b@x{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{#2}}%
  \FBox@i[#1]{\usebox\fpar@b@x}}
\long\def\FParBox@ii#1{%
  \savebox\fpar@b@x{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{#1}}%
  \orig@fbox{\usebox\fpar@b@x}}
  
  
\endinput