| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: enparen.dtx |
| 4 |
% Version: 2024-08-07 v1.2 |
| 5 |
% Info: Parentheses nesting |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2012 Heiko Oberdiek |
| 9 |
% 2016-2024 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/oberdiek/issues |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either |
| 14 |
% version 1.3c of this license or (at your option) any later |
| 15 |
% version. This version of this license is in |
| 16 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 17 |
% and the latest version of this license is in |
| 18 |
% https://www.latex-project.org/lppl.txt |
| 19 |
% and version 1.3 or later is part of all distributions of |
| 20 |
% LaTeX version 2005/12/01 or later. |
| 21 |
% |
| 22 |
% This work has the LPPL maintenance status "maintained". |
| 23 |
% |
| 24 |
% The Current Maintainers of this work are |
| 25 |
% Heiko Oberdiek and the Oberdiek Package Support Group |
| 26 |
% https://github.com/ho-tex/oberdiek/issues |
| 27 |
% |
| 28 |
% This work consists of the main source file enparen.dtx |
| 29 |
% and the derived files |
| 30 |
% enparen.sty, enparen.pdf, enparen.ins, enparen.drv. |
| 31 |
% |
| 32 |
% Distribution: |
| 33 |
% CTAN:macros/latex/contrib/oberdiek/enparen.dtx |
| 34 |
% CTAN:macros/latex/contrib/oberdiek/enparen.pdf |
| 35 |
% |
| 36 |
% Unpacking: |
| 37 |
% (a) If enparen.ins is present: |
| 38 |
% tex enparen.ins |
| 39 |
% (b) Without enparen.ins: |
| 40 |
% tex enparen.dtx |
| 41 |
% (c) If you insist on using LaTeX |
| 42 |
% latex \let\install=y\input{enparen.dtx} |
| 43 |
% (quote the arguments according to the demands of your shell) |
| 44 |
% |
| 45 |
% Documentation: |
| 46 |
% (a) If enparen.drv is present: |
| 47 |
% latex enparen.drv |
| 48 |
% (b) Without enparen.drv: |
| 49 |
% latex enparen.dtx; ... |
| 50 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 51 |
% if available. Here you can specify further options, e.g. |
| 52 |
% use A4 as paper format: |
| 53 |
% \PassOptionsToClass{a4paper}{article} |
| 54 |
% |
| 55 |
% Program calls to get the documentation (example): |
| 56 |
% pdflatex enparen.dtx |
| 57 |
% makeindex -s gind.ist enparen.idx |
| 58 |
% pdflatex enparen.dtx |
| 59 |
% makeindex -s gind.ist enparen.idx |
| 60 |
% pdflatex enparen.dtx |
| 61 |
% |
| 62 |
% Installation: |
| 63 |
% TDS:tex/latex/oberdiek/enparen.sty |
| 64 |
% TDS:doc/latex/oberdiek/enparen.pdf |
| 65 |
% TDS:source/latex/oberdiek/enparen.dtx |
| 66 |
% |
| 67 |
%<*ignore> |
| 68 |
\begingroup |
| 69 |
\catcode123=1 % |
| 70 |
\catcode125=2 % |
| 71 |
\def\x{LaTeX2e}% |
| 72 |
\expandafter\endgroup |
| 73 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 74 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 75 |
\ifx\fmtname\x\else 1\fi\relax |
| 76 |
\else\csname fi\endcsname |
| 77 |
%</ignore> |
| 78 |
%<*install> |
| 79 |
\input docstrip.tex |
| 80 |
\Msg{************************************************************************} |
| 81 |
\Msg{* Installation} |
| 82 |
\Msg{* Package: enparen 2024-08-07 v1.2 Parentheses nesting (HO)} |
| 83 |
\Msg{************************************************************************} |
| 84 |
|
| 85 |
\keepsilent |
| 86 |
\askforoverwritefalse |
| 87 |
|
| 88 |
\let\MetaPrefix\relax |
| 89 |
\preamble |
| 90 |
|
| 91 |
This is a generated file. |
| 92 |
|
| 93 |
Project: enparen |
| 94 |
Version: 2024-08-07 v1.2 |
| 95 |
|
| 96 |
Copyright (C) |
| 97 |
2012 Heiko Oberdiek |
| 98 |
2016-2024 Oberdiek Package Support Group |
| 99 |
|
| 100 |
This work may be distributed and/or modified under the |
| 101 |
conditions of the LaTeX Project Public License, either |
| 102 |
version 1.3c of this license or (at your option) any later |
| 103 |
version. This version of this license is in |
| 104 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 105 |
and the latest version of this license is in |
| 106 |
https://www.latex-project.org/lppl.txt |
| 107 |
and version 1.3 or later is part of all distributions of |
| 108 |
LaTeX version 2005/12/01 or later. |
| 109 |
|
| 110 |
This work has the LPPL maintenance status "maintained". |
| 111 |
|
| 112 |
The Current Maintainers of this work are |
| 113 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 114 |
https://github.com/ho-tex/oberdiek/issues |
| 115 |
|
| 116 |
|
| 117 |
This work consists of the main source file enparen.dtx |
| 118 |
and the derived files |
| 119 |
enparen.sty, enparen.pdf, enparen.ins, enparen.drv. |
| 120 |
|
| 121 |
\endpreamble |
| 122 |
\let\MetaPrefix\DoubleperCent |
| 123 |
|
| 124 |
\generate{% |
| 125 |
\file{enparen.ins}{\from{enparen.dtx}{install}}% |
| 126 |
\file{enparen.drv}{\from{enparen.dtx}{driver}}% |
| 127 |
\usedir{tex/latex/oberdiek}% |
| 128 |
\file{enparen.sty}{\from{enparen.dtx}{package}}% |
| 129 |
} |
| 130 |
|
| 131 |
\catcode32=13\relax% active space |
| 132 |
\let =\space% |
| 133 |
\Msg{************************************************************************} |
| 134 |
\Msg{*} |
| 135 |
\Msg{* To finish the installation you have to move the following} |
| 136 |
\Msg{* file into a directory searched by TeX:} |
| 137 |
\Msg{*} |
| 138 |
\Msg{* enparen.sty} |
| 139 |
\Msg{*} |
| 140 |
\Msg{* To produce the documentation run the file `enparen.drv'} |
| 141 |
\Msg{* through LaTeX.} |
| 142 |
\Msg{*} |
| 143 |
\Msg{* Happy TeXing!} |
| 144 |
\Msg{*} |
| 145 |
\Msg{************************************************************************} |
| 146 |
|
| 147 |
\endbatchfile |
| 148 |
%</install> |
| 149 |
%<*ignore> |
| 150 |
\fi |
| 151 |
%</ignore> |
| 152 |
%<*driver> |
| 153 |
\NeedsTeXFormat{LaTeX2e} |
| 154 |
\ProvidesFile{enparen.drv}% |
| 155 |
[2024-08-07 v1.2 Parentheses nesting (HO)]% |
| 156 |
\documentclass{ltxdoc} |
| 157 |
\usepackage{holtxdoc}[2011/11/22] |
| 158 |
\usepackage{enparen}[2016/05/16] |
| 159 |
\begin{document} |
| 160 |
\DocInput{enparen.dtx}% |
| 161 |
\end{document} |
| 162 |
%</driver> |
| 163 |
% \fi |
| 164 |
% |
| 165 |
% |
| 166 |
% |
| 167 |
% \GetFileInfo{enparen.drv} |
| 168 |
% |
| 169 |
% \title{The \xpackage{enparen} package} |
| 170 |
% \date{2024-08-07 v1.2} |
| 171 |
% \author{Heiko Oberdiek\thanks |
| 172 |
% {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}} |
| 173 |
% |
| 174 |
% \maketitle |
| 175 |
% |
| 176 |
% \begin{abstract} |
| 177 |
% The package defines macros to set parentheses that automatically |
| 178 |
% change the symbols from inner to outer fences. |
| 179 |
% \end{abstract} |
| 180 |
% |
| 181 |
% \tableofcontents |
| 182 |
% |
| 183 |
% \section{Documentation} |
| 184 |
% |
| 185 |
% The \hologo{LaTeX} package provides macros for automatically changed |
| 186 |
% parentheses symbols depending on the fence order. |
| 187 |
% The innermost parentheses are always using the same |
| 188 |
% parentheses. The symbols changes for the outer fences. |
| 189 |
% |
| 190 |
% Example: |
| 191 |
% \begin{quote} |
| 192 |
% \enparen{a \enparen{b} \enparen{c \enparen{d}} \enparen{e}} |
| 193 |
% \end{quote} |
| 194 |
% is generated by |
| 195 |
%\begin{quote} |
| 196 |
%\begin{verbatim} |
| 197 |
%\documentclass{article} |
| 198 |
%\usepackage{enparen} |
| 199 |
%\begin{document} |
| 200 |
% \enparen{a \enparen{b} \enparen{c \enparen{d}} \enparen{e}} |
| 201 |
%\end{document} |
| 202 |
%\end{verbatim} |
| 203 |
%\end{quote} |
| 204 |
% |
| 205 |
% The package is the result of a newsgroup thread. Dan gives |
| 206 |
% the following specification \cite{dan}: |
| 207 |
% \begin{quote} |
| 208 |
% ``On the other hand, the rules for fences are usually the reverse: |
| 209 |
% innermost fences are always |()|, next outer are |[]|, etc. This means |
| 210 |
% the opening fence has to wait until all the fences between it and |
| 211 |
% the matching close have been detected before it can decide whether |
| 212 |
% to be |(| or |[| or |{|.'' |
| 213 |
% \end{quote} |
| 214 |
% |
| 215 |
% The fence level counting starts from innermost parentheses with one. |
| 216 |
% For the next outer fences the level is increased by one. |
| 217 |
% The example above with level indexes: |
| 218 |
% \begin{quote} |
| 219 |
% \def\1{\ensuremath{_{1}}} |
| 220 |
% \def\2{\ensuremath{_{2}}} |
| 221 |
% \def\3{\ensuremath{_{3}}} |
| 222 |
% \enparen{\3a \enparen{\1b}\1 \enparen{\2c \enparen{\1d}\1}\2 \enparen{e}}\3 |
| 223 |
% \end{quote} |
| 224 |
% The correct level is only known at the closing symbol. Therefore the |
| 225 |
% correct value is remembered in the main \xext{aux} file and used |
| 226 |
% in the second \hologo{LaTeX} run. |
| 227 |
% |
| 228 |
% \subsection{User macros} |
| 229 |
% |
| 230 |
% \begin{declcs}{enparen} \M{text} |
| 231 |
% \end{declcs} |
| 232 |
% The macro \cs{enparen} puts its argument \meta{text} in parentheses. |
| 233 |
% If the macro is nested, the used fence symbols change for the |
| 234 |
% outer fences. |
| 235 |
% |
| 236 |
% \begin{declcs}{enparenLeft}\\ |
| 237 |
% \cs{enparenRight} |
| 238 |
% \end{declcs} |
| 239 |
% Instead of |\enparen{text}| the left and right symbol can be |
| 240 |
% used separately, but in pairs: |
| 241 |
% \begin{quote} |
| 242 |
% |\enparenLeft text\enparenRight| |
| 243 |
% \end{quote} |
| 244 |
% \cs{enparenLeft} and \cs{enparenRight} may be used at different |
| 245 |
% group levels, but they must be properly nested. |
| 246 |
% |
| 247 |
% \begin{declcs}{enparenSetSymbols} \M{level} \M{opening symbol} \M{closing symbol} |
| 248 |
% \end{declcs} |
| 249 |
% Macro \cs{enparenSetSymbols} configures the \meta{opening symbol} and |
| 250 |
% \meta{closing symbol} for the \meta{level}. The \meta{level} |
| 251 |
% is a number and the counting starts with one. Level zero is used, |
| 252 |
% if the correct level is not known (e.g. in the first \hologo{LaTeX} run). |
| 253 |
% The package defines the following sets: |
| 254 |
%\begin{quote} |
| 255 |
%\begin{verbatim} |
| 256 |
%\enparenSetSymbols{0}{(}{)} |
| 257 |
%\enparenSetSymbols{1}{(}{)} |
| 258 |
%\enparenSetSymbols{2}{[}{]} |
| 259 |
%\enparenSetSymbols{3}{\{}{\}} |
| 260 |
%\end{verbatim} |
| 261 |
%\end{quote} |
| 262 |
% Example for changing the third and adding a fourth level: |
| 263 |
%\begin{quote} |
| 264 |
%\begin{verbatim} |
| 265 |
%\enparenSetSymbols{3}{\ensuremath{\langle}}{\ensuremath{\rangle}} |
| 266 |
%\enparenSetSymbols{4}{\{}{\}} |
| 267 |
%\end{verbatim} |
| 268 |
%\end{quote} |
| 269 |
% |
| 270 |
% \begin{declcs}{enparenUnsetSymbols} \M{level} |
| 271 |
% \end{declcs} |
| 272 |
% The symbols for level \meta{level} are removed. |
| 273 |
% Example scenario: Only two nesting levels must be used, |
| 274 |
% the package defines more, then the third level can be |
| 275 |
% disabled by |\enparenUnsetSymbols{3}| and the user |
| 276 |
% gets warnings if parentheses at level 3 are needed. |
| 277 |
% |
| 278 |
% \subsection{Contexts} |
| 279 |
% |
| 280 |
% \begin{declcs}{enparenBeginContext} \M{name}\\ |
| 281 |
% \cs{enparenEndContext} \M{name} |
| 282 |
% \end{declcs} |
| 283 |
% If the current text is interrupted by footnotes, floats |
| 284 |
% with captions, then the parentheses inside the text of footnotes, |
| 285 |
% captions, \dots should restart from scratch. This can be achieved |
| 286 |
% by embedding the text inside macros \cs{enparenBeginContext} |
| 287 |
% and \cs{enparenEndContext}. These macros must be properly nested. |
| 288 |
% The \meta{name} for the begin and end macro must be the same. |
| 289 |
% It is a help for debugging problems, because the warning messages |
| 290 |
% show the context name. But it is not necessary that the |
| 291 |
% begin\slash end pairs have different names. Example: |
| 292 |
%\begin{quote} |
| 293 |
%\begin{verbatim} |
| 294 |
%\enparenLeft text before table ... |
| 295 |
%\begin{table} |
| 296 |
% \caption{Table caption} |
| 297 |
% \enparenBeginContext{table} |
| 298 |
% Other text \enparen{foobar}. |
| 299 |
% \enparenEndContext{table} |
| 300 |
%\end{table} |
| 301 |
%text after table ... |
| 302 |
%\enparenRight |
| 303 |
%\end{verbatim} |
| 304 |
%\end{quote} |
| 305 |
% The parentheses inside the table environment and context `table' |
| 306 |
% are not nested inside other parentheses: \enparen{foobar}. |
| 307 |
% In case of captions and footnotes the contexts are automatically |
| 308 |
% added, see next section about options. |
| 309 |
% |
| 310 |
% \subsection{Options} |
| 311 |
% |
| 312 |
% \begin{declcs}{enparenSetup} \M{key value list} |
| 313 |
% \end{declcs} |
| 314 |
% Some options (currently all) can also be set after the |
| 315 |
% package is loaded. They can be set in the argument |
| 316 |
% \meta{key value list} of \cs{enparenSetup}. Options are disabled |
| 317 |
% after they are used the last time. Currently all options are boolean |
| 318 |
% options and are disabled in |\begin{document}|. |
| 319 |
% |
| 320 |
% \begin{description} |
| 321 |
% \item[\xoption{caption}:] The caption text is put in a |
| 322 |
% context |caption|. |
| 323 |
% \item[\xoption{footnote}:] The footnote text is put in a |
| 324 |
% context |footnote|. |
| 325 |
% \end{description} |
| 326 |
% |
| 327 |
% Example for disabling the two options at different places: |
| 328 |
%\begin{quote} |
| 329 |
%\begin{verbatim} |
| 330 |
%\usepackage[caption=false]{enparen} |
| 331 |
%\enparenSetup{footnote=false} |
| 332 |
%\end{verbatim} |
| 333 |
%\end{quote} |
| 334 |
% |
| 335 |
% \subsection{Notes} |
| 336 |
% |
| 337 |
% \begin{description} |
| 338 |
% \item[Implicit kerning:] |
| 339 |
% Unexpandable stuff might affect the implicit kerning. |
| 340 |
% The package cannot avoid this, because it need to define |
| 341 |
% and redefine macros at the occurrence of each symbol. |
| 342 |
% This is done before the opening and after the closing |
| 343 |
% symbol, thus that the implicit kerning inside |
| 344 |
% is not affected. |
| 345 |
% \end{description} |
| 346 |
% |
| 347 |
% \StopEventually{ |
| 348 |
% } |
| 349 |
% |
| 350 |
% \section{Implementation} |
| 351 |
% |
| 352 |
% \begin{macrocode} |
| 353 |
%<*package> |
| 354 |
\NeedsTeXFormat{LaTeX2e} |
| 355 |
\ProvidesPackage{enparen} |
| 356 |
[2024-08-07 v1.2 Parentheses nesting (HO)]% |
| 357 |
% \end{macrocode} |
| 358 |
% |
| 359 |
% \subsection{Resources} |
| 360 |
% |
| 361 |
% \begin{macrocode} |
| 362 |
\RequirePackage{ltxcmds}[2011/11/09] |
| 363 |
% \end{macrocode} |
| 364 |
% |
| 365 |
% \begin{macrocode} |
| 366 |
\ltx@IfUndefined{numexpr}{% |
| 367 |
\PackageError{enparen}{% |
| 368 |
Missing e-TeX's \ltx@backslashchar numexpr.\MessageBreak |
| 369 |
The package will continue with emergency definitions% |
| 370 |
}\@ehc |
| 371 |
\def\enparenLeft{(}% |
| 372 |
\def\enparenRight{)}% |
| 373 |
\long\def\enparen#1{\enparenLeft#1\enparenRight}% |
| 374 |
\let\enparenSetup\ltx@gobble |
| 375 |
\let\enparenSetSymbols\ltx@gobblethree |
| 376 |
\let\enparenUnsetSymbols\ltx@gobble |
| 377 |
\endinput |
| 378 |
}{} |
| 379 |
% \end{macrocode} |
| 380 |
% |
| 381 |
% \begin{macrocode} |
| 382 |
\RequirePackage{protecteddef}[2011/01/31] |
| 383 |
\RequirePackage{atveryend}[2011/06/30] |
| 384 |
\RequirePackage{uniquecounter}[2011/01/30] |
| 385 |
\RequirePackage{zref-base}[2011/03/18] |
| 386 |
\RequirePackage{kvoptions}[2011/06/30] |
| 387 |
\RequirePackage{kvsetkeys}[2011/10/18] |
| 388 |
% \end{macrocode} |
| 389 |
% |
| 390 |
% \begin{macro}{\zref@wrapper@mainaux} |
| 391 |
% \begin{macrocode} |
| 392 |
\providecommand{\zref@wrapper@mainaux}[1]{% |
| 393 |
\ifx\@auxout\@mainaux |
| 394 |
#1% |
| 395 |
\else |
| 396 |
\begingroup |
| 397 |
\let\@auxout\@mainaux |
| 398 |
#1% |
| 399 |
\endgroup |
| 400 |
\fi |
| 401 |
} |
| 402 |
% \end{macrocode} |
| 403 |
% \end{macro} |
| 404 |
% |
| 405 |
% \begin{macrocode} |
| 406 |
\UniqueCounterNew{enparen} |
| 407 |
% \end{macrocode} |
| 408 |
% |
| 409 |
% \begin{macrocode} |
| 410 |
\zref@newprop{enparen}[0]{} |
| 411 |
% \end{macrocode} |
| 412 |
% |
| 413 |
% \subsection{Contexts} |
| 414 |
% |
| 415 |
% \begin{macro}{\enparenContextDefault} |
| 416 |
% \begin{macrocode} |
| 417 |
\def\enparenContextDefault{main} |
| 418 |
% \end{macrocode} |
| 419 |
% \end{macro} |
| 420 |
% |
| 421 |
% \begin{macro}{\enparen@ctx} |
| 422 |
% \begin{macrocode} |
| 423 |
\let\enparen@ctx\ltx@empty |
| 424 |
% \end{macrocode} |
| 425 |
% \end{macro} |
| 426 |
% |
| 427 |
% \begin{macro}{\enparen@stack} |
| 428 |
% \begin{macrocode} |
| 429 |
\let\enparen@stack\ltx@empty |
| 430 |
% \end{macrocode} |
| 431 |
% \end{macro} |
| 432 |
% |
| 433 |
% \subsubsection{Stack for contexts} |
| 434 |
% |
| 435 |
% \begin{macro}{\enparen@CtxStack} |
| 436 |
% \begin{macrocode} |
| 437 |
\global\let\enparen@CtxStack\ltx@empty |
| 438 |
% \end{macrocode} |
| 439 |
% \end{macro} |
| 440 |
% |
| 441 |
% \begin{macro}{\enparen@CtxStackPush} |
| 442 |
% \begin{macrocode} |
| 443 |
\def\enparen@CtxStackPush#1{% |
| 444 |
\xdef\enparen@CtxStack{% |
| 445 |
{\enparen@ctx}{\enparen@stack}% |
| 446 |
\enparen@CtxStack |
| 447 |
}% |
| 448 |
\xdef\enparen@ctx{#1}% |
| 449 |
\global\let\enparen@stack\ltx@empty |
| 450 |
} |
| 451 |
% \end{macrocode} |
| 452 |
% \end{macro} |
| 453 |
% |
| 454 |
% \begin{macro}{\enparen@CtxStackPop} |
| 455 |
% \begin{macrocode} |
| 456 |
\def\enparen@CtxStackPop{% |
| 457 |
\ifx\enparen@CtxStack\ltx@empty |
| 458 |
\PackageWarning{enparen}{% |
| 459 |
Pop request for empty context stack% |
| 460 |
}% |
| 461 |
\global\let\enparen@ctx\enparenContextDefault |
| 462 |
\global\let\enparen@stack\ltx@empty |
| 463 |
\else |
| 464 |
\xdef\enparen@ctx{% |
| 465 |
\expandafter\ltx@car\enparen@CtxStack\@nil |
| 466 |
}% |
| 467 |
\xdef\enparen@stack{% |
| 468 |
\expandafter\ltx@carsecond\enparen@CtxStack\@nil |
| 469 |
}% |
| 470 |
\xdef\enparen@CtxStack{% |
| 471 |
\expandafter\ltx@cdrtwo\enparen@CtxStack\@nil |
| 472 |
}% |
| 473 |
\fi |
| 474 |
} |
| 475 |
% \end{macrocode} |
| 476 |
% \end{macro} |
| 477 |
% |
| 478 |
% \subsubsection{Context user macros} |
| 479 |
% |
| 480 |
% \begin{macro}{\enparenBeginContext} |
| 481 |
% \begin{macrocode} |
| 482 |
\ProtectedDef*{\enparenBeginContext}[1]{% |
| 483 |
\enparen@CtxStackPush{#1}% |
| 484 |
} |
| 485 |
% \end{macrocode} |
| 486 |
% \end{macro} |
| 487 |
% \begin{macro}{\enparenEndContext} |
| 488 |
% \begin{macrocode} |
| 489 |
\ProtectedDef*{\enparenEndContext}[1]{% |
| 490 |
\edef\enparen@temp{#1}% |
| 491 |
\ifx\enparen@temp\enparen@ctx |
| 492 |
\else |
| 493 |
\PackageWarning{enparen}{% |
| 494 |
Context mismatch in end request.\MessageBreak |
| 495 |
`#1' should be ended, but current context\MessageBreak |
| 496 |
is `\enparen@ctx'% |
| 497 |
}% |
| 498 |
\fi |
| 499 |
\enparenCheckEmptyStack |
| 500 |
\enparen@CtxStackPop |
| 501 |
} |
| 502 |
% \end{macrocode} |
| 503 |
% \end{macro} |
| 504 |
% |
| 505 |
% \begin{macro}{\enparenCheckEmptyStack} |
| 506 |
% \begin{macrocode} |
| 507 |
\ProtectedDef*{\enparenCheckEmptyStack}[0]{% |
| 508 |
\ifx\enparen@stack\ltx@empty |
| 509 |
\else |
| 510 |
\PackageWarning{enparen}{% |
| 511 |
Ending non-empty stack `\enparen@ctx':\MessageBreak |
| 512 |
\enparen@PrintStack\MessageBreak |
| 513 |
}% |
| 514 |
\fi |
| 515 |
} |
| 516 |
% \end{macrocode} |
| 517 |
% \end{macro} |
| 518 |
% |
| 519 |
% \begin{macro}{\enparen@PrintStack} |
| 520 |
% \begin{macrocode} |
| 521 |
\def\enparen@PrintStack{% |
| 522 |
\expandafter\enparen@PrintStackAux |
| 523 |
\enparen@stack\ltx@empty\ltx@empty |
| 524 |
} |
| 525 |
% \end{macrocode} |
| 526 |
% \end{macro} |
| 527 |
% \begin{macro}{\enparen@PrintStackAux} |
| 528 |
% \begin{macrocode} |
| 529 |
\def\enparen@PrintStackAux#1#2{% |
| 530 |
\ifx\ltx@empty#1% |
| 531 |
\else |
| 532 |
{#1:#2}% |
| 533 |
\expandafter\enparen@PrintStackAux |
| 534 |
\fi |
| 535 |
} |
| 536 |
% \end{macrocode} |
| 537 |
% \end{macro} |
| 538 |
% |
| 539 |
% \subsection{Symbols} |
| 540 |
% |
| 541 |
% \begin{macro}{\enparenSetSymbols} |
| 542 |
% \begin{macrocode} |
| 543 |
\ProtectedDef*{\enparenSetSymbols}[3]{% |
| 544 |
\expandafter |
| 545 |
\def\csname enparen@symbol\the\numexpr#1L\endcsname{#2}% |
| 546 |
\expandafter |
| 547 |
\def\csname enparen@symbol\the\numexpr#1R\endcsname{#3}% |
| 548 |
} |
| 549 |
% \end{macrocode} |
| 550 |
% \end{macro} |
| 551 |
% \begin{macro}{\enparenUnsetSymbols} |
| 552 |
% \begin{macrocode} |
| 553 |
\ProtectedDef*{\enparenUnsetSymbols}[1]{% |
| 554 |
\expandafter |
| 555 |
\let\csname enparen@symbol\the\numexpr#1L\endcsname\ltx@undefined |
| 556 |
\expandafter |
| 557 |
\let\csname enparen@symbol\the\numexpr#1R\endcsname\ltx@undefined |
| 558 |
} |
| 559 |
% \end{macrocode} |
| 560 |
% \end{macro} |
| 561 |
% |
| 562 |
% \begin{macrocode} |
| 563 |
\enparenSetSymbols{0}{(}{)} |
| 564 |
\enparenSetSymbols{1}{(}{)} |
| 565 |
\enparenSetSymbols{2}{[}{]} |
| 566 |
\enparenSetSymbols{3}{\{}{\}} |
| 567 |
\enparenSetSymbols{4}{\ensuremath{\langle}}{\ensuremath{\rangle}} |
| 568 |
% \end{macrocode} |
| 569 |
% |
| 570 |
% \subsection{Main user macros} |
| 571 |
% |
| 572 |
% \begin{macro}{\enparen} |
| 573 |
% \begin{macrocode} |
| 574 |
\ProtectedDef{\enparen}[1]{% |
| 575 |
\enparenLeft#1\enparenRight |
| 576 |
} |
| 577 |
% \end{macrocode} |
| 578 |
% \end{macro} |
| 579 |
% |
| 580 |
% \begin{macro}{\enparenLeft} |
| 581 |
% \begin{macrocode} |
| 582 |
\ProtectedDef*{\enparenLeft}[0]{% |
| 583 |
\UniqueCounterCall{enparen}\enparen@Left |
| 584 |
} |
| 585 |
% \end{macrocode} |
| 586 |
% \end{macro} |
| 587 |
% \begin{macro}{\enparen@Left} |
| 588 |
% \begin{macrocode} |
| 589 |
\def\enparen@Left#1{% |
| 590 |
\xdef\enparen@stack{% |
| 591 |
{#1}{1}% |
| 592 |
\expandafter\enparen@Inc\expandafter2\expandafter!% |
| 593 |
\enparen@stack\ltx@empty\ltx@empty |
| 594 |
}% |
| 595 |
\edef\enparen@tmp{\zref@extract{enparen#1}{enparen}}% |
| 596 |
\ltx@IfUndefined{enparen@symbol\enparen@tmp L}{% |
| 597 |
\PackageWarning{enparen}{% |
| 598 |
Undefined symbols for level \enparen@tmp |
| 599 |
}% |
| 600 |
\csname enparen@symbol0L\endcsname |
| 601 |
}{% |
| 602 |
\csname enparen@symbol\enparen@tmp L\endcsname |
| 603 |
}% |
| 604 |
} |
| 605 |
% \end{macrocode} |
| 606 |
% \end{macro} |
| 607 |
% \begin{macro}{\enparen@Inc} |
| 608 |
% \begin{macrocode} |
| 609 |
\def\enparen@Inc#1!#2#3{% |
| 610 |
\ifx\ltx@empty#2% |
| 611 |
\else |
| 612 |
\ifnum#3<#1 % |
| 613 |
{#2}{#1}% |
| 614 |
\expandafter\enparen@Inc |
| 615 |
\the\numexpr#1+1\expandafter\expandafter\expandafter!% |
| 616 |
\else |
| 617 |
{#2}{#3}% |
| 618 |
\fi |
| 619 |
\fi |
| 620 |
} |
| 621 |
% \end{macrocode} |
| 622 |
% \end{macro} |
| 623 |
% |
| 624 |
% \begin{macro}{\enparenRight} |
| 625 |
% \begin{macrocode} |
| 626 |
\ProtectedDef*{\enparenRight}[0]{% |
| 627 |
\ifx\enparen@stack\ltx@empty |
| 628 |
\PackageWarning{enparen}{% |
| 629 |
Missing left symbol for right symbol% |
| 630 |
}% |
| 631 |
\csname enparen@symbol0R\endcsname |
| 632 |
\else |
| 633 |
\expandafter\enparen@Right\enparen@stack\@nil |
| 634 |
\fi |
| 635 |
} |
| 636 |
% \end{macrocode} |
| 637 |
% \end{macro} |
| 638 |
% |
| 639 |
% \begin{macro}{\enparen@Right} |
| 640 |
% \begin{macrocode} |
| 641 |
\def\enparen@Right#1#2#3\@nil{% |
| 642 |
\ltx@IfUndefined{% |
| 643 |
enparen@symbol% |
| 644 |
\zref@extract{enparen#1}{enparen}% |
| 645 |
R% |
| 646 |
}{% |
| 647 |
\csname enparen@symbol0R\endcsname |
| 648 |
}{% |
| 649 |
\csname |
| 650 |
enparen@symbol% |
| 651 |
\zref@extract{enparen#1}{enparen}% |
| 652 |
R% |
| 653 |
\endcsname |
| 654 |
}% |
| 655 |
\zref@wrapper@mainaux{% |
| 656 |
\zref@setcurrent{enparen}{#2}% |
| 657 |
\zref@labelbyprops{enparen#1}{enparen}% |
| 658 |
}% |
| 659 |
\xdef\enparen@stack{#3}% |
| 660 |
} |
| 661 |
% \end{macrocode} |
| 662 |
% \end{macro} |
| 663 |
% |
| 664 |
% \subsection{Options} |
| 665 |
% |
| 666 |
% \begin{macrocode} |
| 667 |
\SetupKeyvalOptions{% |
| 668 |
family=enparen,% |
| 669 |
prefix=enparen@,% |
| 670 |
} |
| 671 |
% \end{macrocode} |
| 672 |
% |
| 673 |
% \begin{macro}{\enparenSetup} |
| 674 |
% \begin{macrocode} |
| 675 |
\ProtectedDef*{\enparenSetup}[0]{% |
| 676 |
\kvsetkeys{enparen}% |
| 677 |
} |
| 678 |
% \end{macrocode} |
| 679 |
% \end{macro} |
| 680 |
% |
| 681 |
% \begin{macrocode} |
| 682 |
\DeclareBoolOption[true]{footnote} |
| 683 |
\DeclareBoolOption[true]{caption} |
| 684 |
\ProcessKeyvalOptions* |
| 685 |
% \end{macrocode} |
| 686 |
% |
| 687 |
% \subsection{Context settings} |
| 688 |
% |
| 689 |
% \begin{macro}{\enparen@AtBegin} |
| 690 |
% \begin{macrocode} |
| 691 |
\def\enparen@AtBegin{% |
| 692 |
\ifenparen@footnote |
| 693 |
\let\enparen@org@makefntext\@makefntext |
| 694 |
\long\def\@makefntext##1{% |
| 695 |
\enparen@org@makefntext{% |
| 696 |
\enparenBeginContext{footnote}% |
| 697 |
##1% |
| 698 |
\enparenEndContext{footnote}% |
| 699 |
}% |
| 700 |
}% |
| 701 |
\fi |
| 702 |
\enparen@Disable{footnote}% |
| 703 |
\ifenparen@caption |
| 704 |
\let\enparen@org@makecaption\@makecaption |
| 705 |
\long\def\@makecaption##1##2{% |
| 706 |
\enparen@org@makecaption{##1}{% |
| 707 |
\enparenBeginContext{caption}% |
| 708 |
##2% |
| 709 |
\enparenEndContext{caption}% |
| 710 |
}% |
| 711 |
}% |
| 712 |
\fi |
| 713 |
\enparen@Disable{caption}% |
| 714 |
} |
| 715 |
% \end{macrocode} |
| 716 |
% \end{macro} |
| 717 |
% |
| 718 |
% \begin{macro}{\enparen@Disable} |
| 719 |
% \begin{macrocode} |
| 720 |
\def\enparen@Disable#1{% |
| 721 |
\DisableKeyvalOption[% |
| 722 |
action=warning,% |
| 723 |
package=enparen,% |
| 724 |
]{enparen}{#1}% |
| 725 |
} |
| 726 |
% \end{macrocode} |
| 727 |
% \end{macro} |
| 728 |
% |
| 729 |
% \begin{macrocode} |
| 730 |
\AtBeginDocument{\enparen@AtBegin} |
| 731 |
% \end{macrocode} |
| 732 |
% |
| 733 |
% \subsection{At end of document} |
| 734 |
% |
| 735 |
% \begin{macro}{\enparen@AtEnd} |
| 736 |
% \begin{macrocode} |
| 737 |
\def\enparen@AtEnd{% |
| 738 |
\enparenCheckEmptyStack |
| 739 |
\ifx\enparen@CtxStack\ltx@empty |
| 740 |
\else |
| 741 |
\PackageWarningNoLine{enparen}{% |
| 742 |
Context stack is not empty at end of document.\MessageBreak |
| 743 |
Current stack and contents of context stack:\MessageBreak |
| 744 |
[\enparen@ctx]:[\enparen@PrintStack]% |
| 745 |
\expandafter |
| 746 |
\enparen@PrintContextStack\enparen@CtxStack\relax\relax |
| 747 |
}% |
| 748 |
\fi |
| 749 |
} |
| 750 |
% \end{macrocode} |
| 751 |
% \end{macro} |
| 752 |
% \begin{macro}{\enparen@PrintContextStack} |
| 753 |
% \begin{macrocode} |
| 754 |
\def\enparen@PrintContextStack#1#2{% |
| 755 |
\ifx\relax#1\ltx@empty |
| 756 |
\else |
| 757 |
\MessageBreak |
| 758 |
[#1]:[\enparen@PrintStackAux#2\ltx@empty\ltx@empty]% hash-ok |
| 759 |
\expandafter\enparen@PrintContextStack |
| 760 |
\fi |
| 761 |
} |
| 762 |
% \end{macrocode} |
| 763 |
% \end{macro} |
| 764 |
% \begin{macrocode} |
| 765 |
\AtVeryEndDocument{\enparen@AtEnd} |
| 766 |
% \end{macrocode} |
| 767 |
% |
| 768 |
% \begin{macrocode} |
| 769 |
%</package> |
| 770 |
% \end{macrocode} |
| 771 |
% |
| 772 |
% \section{Installation} |
| 773 |
% |
| 774 |
% \subsection{Download} |
| 775 |
% |
| 776 |
% \paragraph{Package.} This package is available on |
| 777 |
% CTAN\footnote{\CTANpkg{enparen}}: |
| 778 |
% \begin{description} |
| 779 |
% \item[\CTAN{macros/latex/contrib/oberdiek/enparen.dtx}] The source file. |
| 780 |
% \item[\CTAN{macros/latex/contrib/oberdiek/enparen.pdf}] Documentation. |
| 781 |
% \end{description} |
| 782 |
% |
| 783 |
% |
| 784 |
% \paragraph{Bundle.} All the packages of the bundle `oberdiek' |
| 785 |
% are also available in a TDS compliant ZIP archive. There |
| 786 |
% the packages are already unpacked and the documentation files |
| 787 |
% are generated. The files and directories obey the TDS standard. |
| 788 |
% \begin{description} |
| 789 |
% \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}] |
| 790 |
% \end{description} |
| 791 |
% \emph{TDS} refers to the standard ``A Directory Structure |
| 792 |
% for \TeX\ Files'' (\CTANpkg{tds}). Directories |
| 793 |
% with \xfile{texmf} in their name are usually organized this way. |
| 794 |
% |
| 795 |
% \subsection{Bundle installation} |
| 796 |
% |
| 797 |
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the |
| 798 |
% TDS tree (also known as \xfile{texmf} tree) of your choice. |
| 799 |
% Example (linux): |
| 800 |
% \begin{quote} |
| 801 |
% |unzip oberdiek.tds.zip -d ~/texmf| |
| 802 |
% \end{quote} |
| 803 |
% |
| 804 |
% \subsection{Package installation} |
| 805 |
% |
| 806 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 807 |
% \docstrip\ archive. The files are extracted by running the |
| 808 |
% \xfile{.dtx} through \plainTeX: |
| 809 |
% \begin{quote} |
| 810 |
% \verb|tex enparen.dtx| |
| 811 |
% \end{quote} |
| 812 |
% |
| 813 |
% \paragraph{TDS.} Now the different files must be moved into |
| 814 |
% the different directories in your installation TDS tree |
| 815 |
% (also known as \xfile{texmf} tree): |
| 816 |
% \begin{quote} |
| 817 |
% \def\t{^^A |
| 818 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 819 |
% enparen.sty & tex/latex/oberdiek/enparen.sty\\ |
| 820 |
% enparen.pdf & doc/latex/oberdiek/enparen.pdf\\ |
| 821 |
% enparen.dtx & source/latex/oberdiek/enparen.dtx\\ |
| 822 |
% \end{tabular}^^A |
| 823 |
% }^^A |
| 824 |
% \sbox0{\t}^^A |
| 825 |
% \ifdim\wd0>\linewidth |
| 826 |
% \begingroup |
| 827 |
% \advance\linewidth by\leftmargin |
| 828 |
% \advance\linewidth by\rightmargin |
| 829 |
% \edef\x{\endgroup |
| 830 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 831 |
% }\x |
| 832 |
% \def\lwbox{^^A |
| 833 |
% \leavevmode |
| 834 |
% \hbox to \linewidth{^^A |
| 835 |
% \kern-\leftmargin\relax |
| 836 |
% \hss |
| 837 |
% \usebox0 |
| 838 |
% \hss |
| 839 |
% \kern-\rightmargin\relax |
| 840 |
% }^^A |
| 841 |
% }^^A |
| 842 |
% \ifdim\wd0>\lw |
| 843 |
% \sbox0{\small\t}^^A |
| 844 |
% \ifdim\wd0>\linewidth |
| 845 |
% \ifdim\wd0>\lw |
| 846 |
% \sbox0{\footnotesize\t}^^A |
| 847 |
% \ifdim\wd0>\linewidth |
| 848 |
% \ifdim\wd0>\lw |
| 849 |
% \sbox0{\scriptsize\t}^^A |
| 850 |
% \ifdim\wd0>\linewidth |
| 851 |
% \ifdim\wd0>\lw |
| 852 |
% \sbox0{\tiny\t}^^A |
| 853 |
% \ifdim\wd0>\linewidth |
| 854 |
% \lwbox |
| 855 |
% \else |
| 856 |
% \usebox0 |
| 857 |
% \fi |
| 858 |
% \else |
| 859 |
% \lwbox |
| 860 |
% \fi |
| 861 |
% \else |
| 862 |
% \usebox0 |
| 863 |
% \fi |
| 864 |
% \else |
| 865 |
% \lwbox |
| 866 |
% \fi |
| 867 |
% \else |
| 868 |
% \usebox0 |
| 869 |
% \fi |
| 870 |
% \else |
| 871 |
% \lwbox |
| 872 |
% \fi |
| 873 |
% \else |
| 874 |
% \usebox0 |
| 875 |
% \fi |
| 876 |
% \else |
| 877 |
% \lwbox |
| 878 |
% \fi |
| 879 |
% \else |
| 880 |
% \usebox0 |
| 881 |
% \fi |
| 882 |
% \end{quote} |
| 883 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 884 |
% TDS installing feature, then some files can already be in the right |
| 885 |
% place, see the documentation of \docstrip. |
| 886 |
% |
| 887 |
% \subsection{Refresh file name databases} |
| 888 |
% |
| 889 |
% If your \TeX~distribution |
| 890 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 891 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 892 |
% \verb|mktexlsr|. |
| 893 |
% |
| 894 |
% \subsection{Some details for the interested} |
| 895 |
% |
| 896 |
% \paragraph{Unpacking with \LaTeX.} |
| 897 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 898 |
% \begin{description} |
| 899 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 900 |
% \item[\LaTeX:] Generate the documentation. |
| 901 |
% \end{description} |
| 902 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 903 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 904 |
% about your intention: |
| 905 |
% \begin{quote} |
| 906 |
% \verb|latex \let\install=y\input{enparen.dtx}| |
| 907 |
% \end{quote} |
| 908 |
% Do not forget to quote the argument according to the demands |
| 909 |
% of your shell. |
| 910 |
% |
| 911 |
% \paragraph{Generating the documentation.} |
| 912 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 913 |
% the documentation. The process can be configured by the |
| 914 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 915 |
% line into this file, if you want to have A4 as paper format: |
| 916 |
% \begin{quote} |
| 917 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 918 |
% \end{quote} |
| 919 |
% An example follows how to generate the |
| 920 |
% documentation with pdf\LaTeX: |
| 921 |
% \begin{quote} |
| 922 |
%\begin{verbatim} |
| 923 |
%pdflatex enparen.dtx |
| 924 |
%makeindex -s gind.ist enparen.idx |
| 925 |
%pdflatex enparen.dtx |
| 926 |
%makeindex -s gind.ist enparen.idx |
| 927 |
%pdflatex enparen.dtx |
| 928 |
%\end{verbatim} |
| 929 |
% \end{quote} |
| 930 |
% |
| 931 |
% \begin{thebibliography}{9} |
| 932 |
% \raggedright |
| 933 |
% \bibitem{dan} |
| 934 |
% Dan Luecking: \textit{Re: bracket order}; |
| 935 |
% newsgroup \xnewsgroup{comp.text.tex}; |
| 936 |
% message id \texttt{\small$\langle$9b07c9c8-ff92-4cbf-b3a9-84efecfeb506@l24g2000yqm.googlegroups.com$\rangle$} |
| 937 |
% 2012-01-05. |
| 938 |
% \url{https://groups.google.com/group/comp.text.tex/msg/8774519da31c2352} |
| 939 |
% \end{thebibliography} |
| 940 |
% |
| 941 |
% \begin{History} |
| 942 |
% \begin{Version}{2012/01/07 v1.0} |
| 943 |
% \item |
| 944 |
% First version. |
| 945 |
% \end{Version} |
| 946 |
% \begin{Version}{2016/05/16 v1.1} |
| 947 |
% \item |
| 948 |
% Documentation updates. |
| 949 |
% \end{Version} |
| 950 |
% \begin{Version}{2024-08-07 v1.2} |
| 951 |
% \item Updated |
| 952 |
% \end{Version} |
| 953 |
% \end{History} |
| 954 |
% |
| 955 |
% \PrintIndex |
| 956 |
% |
| 957 |
% \Finale |
| 958 |
\endinput |