summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xetex/zhspacing/zhsusefulmacros.sty
blob: d6c5fec5b8aa02b80dc732850109207e083d9c52 (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
%	zhsusefulmacros.sty
%	This file provides several useful LaTeX macros as well as \ifLaTeX@e,
%	and \futurenonspacelet.
%	Licensed under LPPL.
\catcode`\@=11
\ifx\@usefulmacros@defined\@undefined\else
  \expandafter\endinput
\fi
\def\@usefulmacros@defined{\relax}
\def\@usefulmacros@LaTeX@e{LaTeX2e}
\def\ifLaTeX@e{\ifx\fmtname\@usefulmacros@LaTeX@e}
\ifLaTeX@e\else
\def\@nnil{\@nil}%
\def\@empty{}%
\def\@fornoop#1\@@#2#3{}%
\long\def\@for#1:=#2\do#3{%
  \expandafter\def\expandafter\@fortmp\expandafter{#2}%
  \ifx\@fortmp\@empty \else
    \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi}%
\long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
       #5\def#4{#2}\ifx #4\@nnil \else#5\@iforloop #3\@@#4{#5}\fi\fi}%
\long\def\@iforloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
       \expandafter\@fornoop \else
      #4\relax\expandafter\@iforloop\fi#2\@@#3{#4}}%
\def\@tfor#1:={\@tf@r#1 }%
\long\def\@tf@r#1#2\do#3{\def\@fortmp{#2}\ifx\@fortmp\space\else
    \@tforloop#2\@nil\@nil\@@#1{#3}\fi}%
\long\def\@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
       \expandafter\@fornoop \else
      #4\relax\expandafter\@tforloop\fi#2\@@#3{#4}}%
\long\def\@ifnextchar#1#2#3{%
  \let\reserved@d=#1%
  \def\reserved@a{#2}%
  \def\reserved@b{#3}%
  \futurelet\@let@token\@ifnch}
\def\@ifnch{%
  \ifx\@let@token\@sptoken
    \let\reserved@c\@xifnch
  \else
    \ifx\@let@token\reserved@d
      \let\reserved@c\reserved@a
    \else
      \let\reserved@c\reserved@b
    \fi
  \fi
  \reserved@c}
\def\:{\let\@sptoken= } \:  % this makes \@sptoken a space token
\def\:{\@xifnch} \expandafter\def\: {\futurelet\@let@token\@ifnch}
%
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
\expandafter\ifx\csname ifcsname\endcsname\relax
\def\@ifundefined#1{%
  \expandafter\ifx\csname#1\endcsname\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\else
\def\@ifundefined#1{%
  \unless\ifcsname#1\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\fi
%
\def\@namedef#1{\expandafter\def\csname #1\endcsname}
%
\fi % end of \ifLaTeX@e\else

\def\@BTcs{}
\let\nexttoken\relax
\let\next\relax
\def\futurenonspacelet#1{\def\@BTcs{#1}%
   \afterassignment\@BTfnslone\let\nexttoken= }
\def\@BTfnslone{\expandafter\futurelet\@BTcs\@BTfnsltwo}
\def\@BTfnsltwo{\expandafter\ifx\@BTcs\@sptoken\let\next=\@BTfnslthree
   \else\let\next=\nexttoken\fi \next}
\def\@BTfnslthree{\afterassignment\@BTfnslone\let\next= }

\ifx\fbox\@undefined
\newbox\fbox@tmpbox
\newdimen\fbox@linewidth
\newdimen\fbox@tmpdim
\fbox@linewidth=0.4pt
\long\def\fbox#1{%
  \setbox\fbox@tmpbox=\hbox{#1}%
  \fbox@tmpdim=2\fbox@linewidth
  \advance\fbox@tmpdim\wd\fbox@tmpbox
  \leavevmode\hbox{\vbox{\hrule height \fbox@linewidth width \fbox@tmpdim
  \hbox{\vrule width \fbox@linewidth height \ht\fbox@tmpbox
  #1\vrule width \fbox@linewidth height \ht\fbox@tmpbox}%
  \hrule height \fbox@linewidth width \fbox@tmpdim
  }}%
}
\fi