Debian Codegraph @

texmf-dist/tex/latex/oberdiek/enparen.sty

raw
1 %%
2 %% This is file `enparen.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% enparen.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% Project: enparen
12 %% Version: 2024-08-07 v1.2
13 %%
14 %% Copyright (C)
15 %% 2012 Heiko Oberdiek
16 %% 2016-2024 Oberdiek Package Support Group
17 %%
18 %% This work may be distributed and/or modified under the
19 %% conditions of the LaTeX Project Public License, either
20 %% version 1.3c of this license or (at your option) any later
21 %% version. This version of this license is in
22 %% https://www.latex-project.org/lppl/lppl-1-3c.txt
23 %% and the latest version of this license is in
24 %% https://www.latex-project.org/lppl.txt
25 %% and version 1.3 or later is part of all distributions of
26 %% LaTeX version 2005/12/01 or later.
27 %%
28 %% This work has the LPPL maintenance status "maintained".
29 %%
30 %% The Current Maintainers of this work are
31 %% Heiko Oberdiek and the Oberdiek Package Support Group
32 %% https://github.com/ho-tex/oberdiek/issues
33 %%
34 %%
35 %% This work consists of the main source file enparen.dtx
36 %% and the derived files
37 %% enparen.sty, enparen.pdf, enparen.ins, enparen.drv.
38 %%
39 \NeedsTeXFormat{LaTeX2e}
40 \ProvidesPackage{enparen}
41 [2024-08-07 v1.2 Parentheses nesting (HO)]%
42 \RequirePackage{ltxcmds}[2011/11/09]
43 \ltx@IfUndefined{numexpr}{%
44 \PackageError{enparen}{%
45 Missing e-TeX's \ltx@backslashchar numexpr.\MessageBreak
46 The package will continue with emergency definitions%
47 }\@ehc
48 \def\enparenLeft{(}%
49 \def\enparenRight{)}%
50 \long\def\enparen#1{\enparenLeft#1\enparenRight}%
51 \let\enparenSetup\ltx@gobble
52 \let\enparenSetSymbols\ltx@gobblethree
53 \let\enparenUnsetSymbols\ltx@gobble
54 \endinput
55 }{}
56 \RequirePackage{protecteddef}[2011/01/31]
57 \RequirePackage{atveryend}[2011/06/30]
58 \RequirePackage{uniquecounter}[2011/01/30]
59 \RequirePackage{zref-base}[2011/03/18]
60 \RequirePackage{kvoptions}[2011/06/30]
61 \RequirePackage{kvsetkeys}[2011/10/18]
62 \providecommand{\zref@wrapper@mainaux}[1]{%
63 \ifx\@auxout\@mainaux
64 #1%
65 \else
66 \begingroup
67 \let\@auxout\@mainaux
68 #1%
69 \endgroup
70 \fi
71 }
72 \UniqueCounterNew{enparen}
73 \zref@newprop{enparen}[0]{}
74 \def\enparenContextDefault{main}
75 \let\enparen@ctx\ltx@empty
76 \let\enparen@stack\ltx@empty
77 \global\let\enparen@CtxStack\ltx@empty
78 \def\enparen@CtxStackPush#1{%
79 \xdef\enparen@CtxStack{%
80 {\enparen@ctx}{\enparen@stack}%
81 \enparen@CtxStack
82 }%
83 \xdef\enparen@ctx{#1}%
84 \global\let\enparen@stack\ltx@empty
85 }
86 \def\enparen@CtxStackPop{%
87 \ifx\enparen@CtxStack\ltx@empty
88 \PackageWarning{enparen}{%
89 Pop request for empty context stack%
90 }%
91 \global\let\enparen@ctx\enparenContextDefault
92 \global\let\enparen@stack\ltx@empty
93 \else
94 \xdef\enparen@ctx{%
95 \expandafter\ltx@car\enparen@CtxStack\@nil
96 }%
97 \xdef\enparen@stack{%
98 \expandafter\ltx@carsecond\enparen@CtxStack\@nil
99 }%
100 \xdef\enparen@CtxStack{%
101 \expandafter\ltx@cdrtwo\enparen@CtxStack\@nil
102 }%
103 \fi
104 }
105 \ProtectedDef*{\enparenBeginContext}[1]{%
106 \enparen@CtxStackPush{#1}%
107 }
108 \ProtectedDef*{\enparenEndContext}[1]{%
109 \edef\enparen@temp{#1}%
110 \ifx\enparen@temp\enparen@ctx
111 \else
112 \PackageWarning{enparen}{%
113 Context mismatch in end request.\MessageBreak
114 `#1' should be ended, but current context\MessageBreak
115 is `\enparen@ctx'%
116 }%
117 \fi
118 \enparenCheckEmptyStack
119 \enparen@CtxStackPop
120 }
121 \ProtectedDef*{\enparenCheckEmptyStack}[0]{%
122 \ifx\enparen@stack\ltx@empty
123 \else
124 \PackageWarning{enparen}{%
125 Ending non-empty stack `\enparen@ctx':\MessageBreak
126 \enparen@PrintStack\MessageBreak
127 }%
128 \fi
129 }
130 \def\enparen@PrintStack{%
131 \expandafter\enparen@PrintStackAux
132 \enparen@stack\ltx@empty\ltx@empty
133 }
134 \def\enparen@PrintStackAux#1#2{%
135 \ifx\ltx@empty#1%
136 \else
137 {#1:#2}%
138 \expandafter\enparen@PrintStackAux
139 \fi
140 }
141 \ProtectedDef*{\enparenSetSymbols}[3]{%
142 \expandafter
143 \def\csname enparen@symbol\the\numexpr#1L\endcsname{#2}%
144 \expandafter
145 \def\csname enparen@symbol\the\numexpr#1R\endcsname{#3}%
146 }
147 \ProtectedDef*{\enparenUnsetSymbols}[1]{%
148 \expandafter
149 \let\csname enparen@symbol\the\numexpr#1L\endcsname\ltx@undefined
150 \expandafter
151 \let\csname enparen@symbol\the\numexpr#1R\endcsname\ltx@undefined
152 }
153 \enparenSetSymbols{0}{(}{)}
154 \enparenSetSymbols{1}{(}{)}
155 \enparenSetSymbols{2}{[}{]}
156 \enparenSetSymbols{3}{\{}{\}}
157 \enparenSetSymbols{4}{\ensuremath{\langle}}{\ensuremath{\rangle}}
158 \ProtectedDef{\enparen}[1]{%
159 \enparenLeft#1\enparenRight
160 }
161 \ProtectedDef*{\enparenLeft}[0]{%
162 \UniqueCounterCall{enparen}\enparen@Left
163 }
164 \def\enparen@Left#1{%
165 \xdef\enparen@stack{%
166 {#1}{1}%
167 \expandafter\enparen@Inc\expandafter2\expandafter!%
168 \enparen@stack\ltx@empty\ltx@empty
169 }%
170 \edef\enparen@tmp{\zref@extract{enparen#1}{enparen}}%
171 \ltx@IfUndefined{enparen@symbol\enparen@tmp L}{%
172 \PackageWarning{enparen}{%
173 Undefined symbols for level \enparen@tmp
174 }%
175 \csname enparen@symbol0L\endcsname
176 }{%
177 \csname enparen@symbol\enparen@tmp L\endcsname
178 }%
179 }
180 \def\enparen@Inc#1!#2#3{%
181 \ifx\ltx@empty#2%
182 \else
183 \ifnum#3<#1 %
184 {#2}{#1}%
185 \expandafter\enparen@Inc
186 \the\numexpr#1+1\expandafter\expandafter\expandafter!%
187 \else
188 {#2}{#3}%
189 \fi
190 \fi
191 }
192 \ProtectedDef*{\enparenRight}[0]{%
193 \ifx\enparen@stack\ltx@empty
194 \PackageWarning{enparen}{%
195 Missing left symbol for right symbol%
196 }%
197 \csname enparen@symbol0R\endcsname
198 \else
199 \expandafter\enparen@Right\enparen@stack\@nil
200 \fi
201 }
202 \def\enparen@Right#1#2#3\@nil{%
203 \ltx@IfUndefined{%
204 enparen@symbol%
205 \zref@extract{enparen#1}{enparen}%
206 R%
207 }{%
208 \csname enparen@symbol0R\endcsname
209 }{%
210 \csname
211 enparen@symbol%
212 \zref@extract{enparen#1}{enparen}%
213 R%
214 \endcsname
215 }%
216 \zref@wrapper@mainaux{%
217 \zref@setcurrent{enparen}{#2}%
218 \zref@labelbyprops{enparen#1}{enparen}%
219 }%
220 \xdef\enparen@stack{#3}%
221 }
222 \SetupKeyvalOptions{%
223 family=enparen,%
224 prefix=enparen@,%
225 }
226 \ProtectedDef*{\enparenSetup}[0]{%
227 \kvsetkeys{enparen}%
228 }
229 \DeclareBoolOption[true]{footnote}
230 \DeclareBoolOption[true]{caption}
231 \ProcessKeyvalOptions*
232 \def\enparen@AtBegin{%
233 \ifenparen@footnote
234 \let\enparen@org@makefntext\@makefntext
235 \long\def\@makefntext##1{%
236 \enparen@org@makefntext{%
237 \enparenBeginContext{footnote}%
238 ##1%
239 \enparenEndContext{footnote}%
240 }%
241 }%
242 \fi
243 \enparen@Disable{footnote}%
244 \ifenparen@caption
245 \let\enparen@org@makecaption\@makecaption
246 \long\def\@makecaption##1##2{%
247 \enparen@org@makecaption{##1}{%
248 \enparenBeginContext{caption}%
249 ##2%
250 \enparenEndContext{caption}%
251 }%
252 }%
253 \fi
254 \enparen@Disable{caption}%
255 }
256 \def\enparen@Disable#1{%
257 \DisableKeyvalOption[%
258 action=warning,%
259 package=enparen,%
260 ]{enparen}{#1}%
261 }
262 \AtBeginDocument{\enparen@AtBegin}
263 \def\enparen@AtEnd{%
264 \enparenCheckEmptyStack
265 \ifx\enparen@CtxStack\ltx@empty
266 \else
267 \PackageWarningNoLine{enparen}{%
268 Context stack is not empty at end of document.\MessageBreak
269 Current stack and contents of context stack:\MessageBreak
270 [\enparen@ctx]:[\enparen@PrintStack]%
271 \expandafter
272 \enparen@PrintContextStack\enparen@CtxStack\relax\relax
273 }%
274 \fi
275 }
276 \def\enparen@PrintContextStack#1#2{%
277 \ifx\relax#1\ltx@empty
278 \else
279 \MessageBreak
280 [#1]:[\enparen@PrintStackAux#2\ltx@empty\ltx@empty]% hash-ok
281 \expandafter\enparen@PrintContextStack
282 \fi
283 }
284 \AtVeryEndDocument{\enparen@AtEnd}
285 \endinput
286 %%
287 %% End of file `enparen.sty'.