| 1 |
% |
| 2 |
% \iffalse meta-comment |
| 3 |
% |
| 4 |
% delimset.dtx Copyright (C) 2016-2026 Niklas Beisert |
| 5 |
% |
| 6 |
% This work may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 12 |
% version 2008 or later. |
| 13 |
% |
| 14 |
% This work has the LPPL maintenance status `maintained'. |
| 15 |
% |
| 16 |
% The Current Maintainer of this work is Niklas Beisert. |
| 17 |
% |
| 18 |
% This work consists of the files delimset.dtx and delimset.ins |
| 19 |
% and the derived files delimset.sty and delimset-samp.tex. |
| 20 |
% |
| 21 |
%<package|sample>\NeedsTeXFormat{LaTeX2e}[1996-12-01] |
| 22 |
%<package>\ProvidesPackage{delimset}[2026-03-26 v2.3.1 convenient size control for delimiter sets] |
| 23 |
%<sample>\ProvidesFile{delimset-samp.tex}[2026-03-26 v2.3.1 sample for delimset] |
| 24 |
%<source>\ProvidesFile{delimset-src.tex}[2026-03-26 v2.3.1 delimset source code documentation] |
| 25 |
%<manual>\ProvidesFile{delimset.tex}[2026-03-26 v2.3.1 delimset reference manual] |
| 26 |
%<*main|manual|source> |
| 27 |
\def\thepkg/{delimset}\def\thedate/{2026-03-26}\def\theversion/{v2.3.1} |
| 28 |
\def\thecopyright/{2016\texorpdfstring{--}{-}2026 Niklas Beisert} |
| 29 |
%<*main> |
| 30 |
\ProvidesFile{\thepkg/.dtx}[\thedate/ \theversion/ \thepkg/ package main file] |
| 31 |
%</main> |
| 32 |
\PassOptionsToClass{10pt,a4paper}{article} |
| 33 |
\documentclass{ltxdoc} |
| 34 |
|
| 35 |
\usepackage[margin=35mm]{geometry} |
| 36 |
\usepackage[hyperindex=false]{hyperref} |
| 37 |
\usepackage{hyperxmp} |
| 38 |
\usepackage[usenames]{color} |
| 39 |
\usepackage{longtable} |
| 40 |
|
| 41 |
\usepackage{amsmath,amsfonts} |
| 42 |
\usepackage{delimset} |
| 43 |
|
| 44 |
%<*main> |
| 45 |
\title{The \markpkg{\thepkg/} Package} |
| 46 |
\hypersetup{pdftitle={The \thepkg/ Package}} |
| 47 |
\hypersetup{pdfsubject={Documentation for the LaTeX2e Package \thepkg/}} |
| 48 |
%</main> |
| 49 |
%<manual>\title{The \markpkg{\thepkg/} Package\\Reference Manual} |
| 50 |
%<manual>\hypersetup{pdftitle={The \thepkg/ Package -- Reference Manual}} |
| 51 |
%<manual>\hypersetup{pdfsubject={Reference Manual for the LaTeX2e Package \thepkg/}} |
| 52 |
%<source>\title{The \markpkg{\thepkg/} Package\\Source Code Documentation} |
| 53 |
%<source>\hypersetup{pdftitle={The \thepkg/ Package -- Source Code Documentation}} |
| 54 |
%<source>\hypersetup{pdfsubject={Documented Source for the LaTeX2e Package \thepkg/}} |
| 55 |
\author{Niklas Beisert\\[2ex] |
| 56 |
Institut f\"ur Theoretische Physik\\ |
| 57 |
Eidgen\"ossische Technische Hochschule Z\"urich\\ |
| 58 |
Wolfgang-Pauli-Strasse 27, 8093 Z\"urich, Switzerland\\[1ex] |
| 59 |
\href{mailto:[email protected]} |
| 60 |
{\texttt{[email protected]}}} |
| 61 |
\hypersetup{pdfauthor={Niklas Beisert}} |
| 62 |
\date{\theversion/: \markdate{\thedate/}\\[1ex] |
| 63 |
\url{https://ctan.org/pkg/\thepkg/}\\[0.5ex] |
| 64 |
\url{https://github.com/nbeisert/latex-pkg-nb}} |
| 65 |
|
| 66 |
\hypersetup{pdflang={en-UK}} |
| 67 |
\hypersetup{pdfurl={https://ctan.org/pkg/\thepkg/}} |
| 68 |
\hypersetup{pdfcopyright={Copyright \thecopyright/. |
| 69 |
This work may be distributed and/or modified under the |
| 70 |
conditions of the LaTeX Project Public License, either version 1.3 |
| 71 |
of this license or (at your option) any later version.}} |
| 72 |
\hypersetup{pdflicenseurl={https://www.latex-project.org/lppl.txt}} |
| 73 |
\hypersetup{pdfcontactaddress={ETH Zurich, ITP, HIT K, |
| 74 |
Wolfgang-Pauli-Strasse 27}} |
| 75 |
\hypersetup{pdfcontactpostcode={8093}} |
| 76 |
\hypersetup{pdfcontactcity={Zurich}} |
| 77 |
\hypersetup{pdfcontactcountry={Switzerland}} |
| 78 |
\hypersetup{pdfcontactemail={[email protected]}} |
| 79 |
\hypersetup{pdfcontacturl={https://people.phys.ethz.ch/\xmptilde nbeisert/}} |
| 80 |
|
| 81 |
\hypersetup{keeppdfinfo=true} |
| 82 |
\hypersetup{pdfsource={}} |
| 83 |
\AddToHook{begindocument/before}{\hypersetup{colorlinks=false}} |
| 84 |
\hypersetup{urlbordercolor={.5 1 1}} |
| 85 |
\hypersetup{linkbordercolor={1 .7 .7}} |
| 86 |
\AddToHook{begindocument/before}{\hypersetup{pdfstartview=FitH}} |
| 87 |
|
| 88 |
\parskip1ex |
| 89 |
\parindent0pt |
| 90 |
\edef\itemize{\unexpanded\expandafter{\itemize}\parskip0pt} |
| 91 |
\def\longtablestr{\def\arraystretch{1.2}\tabcolsep1em\longtable} |
| 92 |
\def\endlongtablestr{\endlongtable\prevdepth\baselineskip\vskip-\parskip} |
| 93 |
|
| 94 |
\newcommand{\markpkg}[1]{\textsf{#1}} |
| 95 |
\newcommand{\markdate}[1]{\textsf{#1}} |
| 96 |
\newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}} |
| 97 |
\newcommand{\ctanref}[2]{\href{https://ctan.org/#1}{#2}} |
| 98 |
\newcommand{\ctanpkg}[1]{\ctanref{pkg/#1}{\markpkg{#1}}} |
| 99 |
|
| 100 |
\def\verbbar{\texttt{\char"7C}} |
| 101 |
\def\verbpkg{\texttt{\thepkg/}} |
| 102 |
\def\thepkgctan/{\ctanpkg{\thepkg/}} |
| 103 |
|
| 104 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 106 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 107 |
\begin{document} |
| 108 |
|
| 109 |
\maketitle |
| 110 |
|
| 111 |
\begin{abstract}\noindent |
| 112 |
\markpkg{delimset} is a \LaTeXe{} package |
| 113 |
to typeset and declare sets of delimiters in math mode |
| 114 |
whose size can be adjusted conveniently. |
| 115 |
\end{abstract} |
| 116 |
|
| 117 |
\begingroup |
| 118 |
\parskip0ex |
| 119 |
\tableofcontents |
| 120 |
\endgroup |
| 121 |
|
| 122 |
|
| 123 |
%<*main|manual> |
| 124 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 125 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 126 |
\section{Introduction} |
| 127 |
|
| 128 |
In ordinary \TeX{} and \LaTeX{}, delimiters in math and physics expressions |
| 129 |
(brackets such as parentheses, braces, but also |
| 130 |
absolute values, sets, pairings, bra-kets and quantum expectation values, |
| 131 |
commutators, \ldots) |
| 132 |
are typically coded by their respective symbols. |
| 133 |
For example: |
| 134 |
% |
| 135 |
\[ |
| 136 |
\begin{aligned} |
| 137 |
|[(ax+b)x+c]| &\to [(ax+b)x+c] |
| 138 |
\\ |
| 139 |
|\{1,2,3,\ldots\}| &\to \{1,2,3,\ldots\} |
| 140 |
\\ |
| 141 |
|(v,w)| &\to (v,w) |
| 142 |
\\ |
| 143 |
|\langle\psi|\verbbar|M|\verbbar|\psi\rangle| |
| 144 |
&\to \langle\psi\vert M\vert\psi\rangle |
| 145 |
\\ |
| 146 |
|(x^2+px+q)|\verbbar|_{-p/2}| &\to (x^2+px+q)\vert_{-p/2} |
| 147 |
\\&\ldots |
| 148 |
\end{aligned} |
| 149 |
\] |
| 150 |
% |
| 151 |
In order to adjust the size of delimiters, the modifiers |
| 152 |
|\big|, |\Big|, |\bigg|, |\Bigg| are used. |
| 153 |
More importantly the construct |
| 154 |
{|\left*| \ldots [|\middle*|] \ldots |\right*|} |
| 155 |
adjusts the size of delimiters to the contents: |
| 156 |
% |
| 157 |
\[ |
| 158 |
\Bigg[\bigg[\Big[\big[[*]\big]\Big]\bigg]\Bigg], |
| 159 |
\qquad |
| 160 |
\left\{\frac{p}{q} \middle\vert p,q\in\mathbb{Z}, q\neq 0 \right\} |
| 161 |
\] |
| 162 |
% |
| 163 |
These modifiers allow to construct expressions involving delimiters |
| 164 |
conveniently and with a large amount of flexibility. |
| 165 |
|
| 166 |
However, once an expression has been typeset in this way, |
| 167 |
it takes some efforts to modify, if needed. |
| 168 |
At least, one has to take care of both delimiters at the same time |
| 169 |
and change their size or type accordingly. |
| 170 |
For example, $\hat X$ in the expression |(A\hat{X}+B)| |
| 171 |
has an extended height that calls for bigger delimiters. |
| 172 |
Ideally, one would use |\left(...\right)| |
| 173 |
to find the correct size. |
| 174 |
Unfortunately, in this case, the smallest size of delimiters |
| 175 |
that covers the height of $\hat X$ is equivalent to |\Big|, |
| 176 |
which feels somewhat too big. For aesthetic reasons one might thus prefer |
| 177 |
the size |\big(...\big)|: |
| 178 |
% |
| 179 |
\[ |
| 180 |
\begin{aligned} |
| 181 |
|(A\hat{X}+B)| |
| 182 |
&\to(A\hat{X}+B) |
| 183 |
\\ |
| 184 |
|\left(A\hat{X}+B\right)| |
| 185 |
&\to\left(A\hat{X}+B\right) |
| 186 |
\\ |
| 187 |
|\Big(A\hat{X}+B\Big)| |
| 188 |
&\to\Big(A\hat{X}+B\Big) |
| 189 |
\\ |
| 190 |
|\big(A\hat{X}+B\big)| |
| 191 |
&\to\big(A\hat{X}+B\big) |
| 192 |
\end{aligned} |
| 193 |
\] |
| 194 |
|
| 195 |
The package \ctanpkg{delimset} provides mechanisms to declare sets of delimiters |
| 196 |
whose size can be adjusted conveniently by adding simple flag parameters. |
| 197 |
For example, it provides a general purpose bracket |\brk| |
| 198 |
which can be used as follows: |
| 199 |
% |
| 200 |
\[ |
| 201 |
\begin{aligned} |
| 202 |
|\brk{A\hat{X}+B}|&\to(A\hat{X}+B) |
| 203 |
\\ |
| 204 |
|\brk*{A\hat{X}+B}|&\to\mathopen{}\mathclose{\left(A\hat{X}+B\right)} |
| 205 |
\\ |
| 206 |
|\brk^2{A\hat{X}+B}|&\to\Bigl(A\hat{X}+B\Bigr) |
| 207 |
\\ |
| 208 |
|\brk!{A\hat{X}+B}|&\to\bigl(A\hat{X}+B\bigr) |
| 209 |
\end{aligned} |
| 210 |
\] |
| 211 |
% |
| 212 |
It also allows to change the type of bracket conveniently: |
| 213 |
% |
| 214 |
\[ |
| 215 |
\begin{aligned} |
| 216 |
|\brk{ax+b}| |
| 217 |
&\to(ax+b) |
| 218 |
\\ |
| 219 |
|\brk[s]{ax+b}| |
| 220 |
&\to[ax+b] |
| 221 |
\\ |
| 222 |
|\brk[c]{ax+b}| |
| 223 |
&\to\{ax+b\} |
| 224 |
\\ |
| 225 |
|\brk[a]{ax+b}| |
| 226 |
&\to\langle ax+b\rangle |
| 227 |
\end{aligned} |
| 228 |
\] |
| 229 |
% |
| 230 |
These features can be combined and used, e.g., in nested brackets |
| 231 |
in order to distinguish the levels by shape and size: |
| 232 |
% |
| 233 |
\[ |
| 234 |
|\brk[s]!{\brk{ax+b}x+c}| |
| 235 |
\to\bigl[(ax+b)x+c\bigr] |
| 236 |
\] |
| 237 |
% |
| 238 |
All of this can of course be achieved with the conventional |
| 239 |
tools of \TeX{} with comparable effort, |
| 240 |
but the more complicated and nested the expressions get, |
| 241 |
the more difficult it will be to adjust them |
| 242 |
to obtain a visually acceptable result. |
| 243 |
|
| 244 |
The main functionality of the package is based on a |
| 245 |
versatile mechanism to specify sets of delimiters, |
| 246 |
e.g.: |
| 247 |
% |
| 248 |
\[ |
| 249 |
\begin{aligned} |
| 250 |
|\delim<>{ax+b}| |
| 251 |
&\to \delim<>{ax+b} |
| 252 |
\\ |
| 253 |
|\delimpair[{[p]*,}[!{a}{b}| |
| 254 |
&\to \delimpair[{[p]*,}[!{a}{b} |
| 255 |
\\ |
| 256 |
|\delimtriple<|\verbbar\verbbar|>*{\psi}{A^\dagger}{\psi}| |
| 257 |
&\to \delimtriple<\vert\vert>*{\psi}{A^\dagger}{\psi} |
| 258 |
\end{aligned} |
| 259 |
\] |
| 260 |
% |
| 261 |
The command |\delim| can be used on the fly, but also |
| 262 |
in definitions of custom delimiter sets such as: |
| 263 |
% |
| 264 |
\[ |
| 265 |
|\newcommand{\comm}{\delimpair{[}{[p]*,}{]}}| |
| 266 |
\] |
| 267 |
% |
| 268 |
Note that the definition of |\comm| does not specify any arguments. |
| 269 |
They are nevertheless read by the incomplete definition of |\delimpair| |
| 270 |
from what follows |\comm|. |
| 271 |
In particular, this incomplete definition |
| 272 |
enables the correct parsing of the optional size specifier flag, |
| 273 |
e.g.: |
| 274 |
% |
| 275 |
\[ |
| 276 |
|\comm!{P}{\psi(x)}| \to \delimpair{[}{[p]*,}{]}!{P}{\psi(x)} |
| 277 |
\] |
| 278 |
% |
| 279 |
The package also provides a mechanism to declare |
| 280 |
delimited sets more flexibly. |
| 281 |
The above definition could be written as follows: |
| 282 |
% |
| 283 |
\begin{longtablestr}{l} |
| 284 |
|\DeclareMathDelimiterSet{\comm}[2]| |
| 285 |
\\ |
| 286 |
| {\selectdeliml{[}{#1},{#2}\selectdelimr{]}}| |
| 287 |
\end{longtablestr} |
| 288 |
|
| 289 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 290 |
\subsection{Delimiter Sizes for Math Styles} |
| 291 |
|
| 292 |
In plain \LaTeXe{} |
| 293 |
the size modifiers |\big|, |\Big|, |\bigg|, |\Bigg| have the shortcoming |
| 294 |
that they are based on a fixed font size of 10pt. |
| 295 |
More precisely, they use a vertical phantom of |
| 296 |
height 8.5pt, 11.5pt, 14.5pt or 17.5pt, respectively |
| 297 |
to set the height of the delimiter. |
| 298 |
The package \ctanpkg{amsmath} corrects for font size |
| 299 |
by instead placing a (centred) vertical phantom of |
| 300 |
height 1.2, 1.8, 2.4 or 3 times the size |
| 301 |
of the currently selected math font |
| 302 |
(height plus depth of |\Mathstrutbox@|). |
| 303 |
|
| 304 |
Unfortunately, it does not account for |
| 305 |
the currently selected math style. |
| 306 |
Therefore, the size of delimiters in sub/superscripts |
| 307 |
cannot be adjusted appropriately |
| 308 |
(an arguably better typesetting practice is |
| 309 |
to avoid complicated expressions in sub/superscripts in the first place), |
| 310 |
they come out way too big: |
| 311 |
% |
| 312 |
\[ |
| 313 |
\def\obig#1{\hbox{$\left#1\vbox to8.5pt{}\right.\nulldelimiterspace0pt$}} |
| 314 |
|e^{\big(ax+b\big)}| \to |
| 315 |
e^{\obig(ax+b\obig)} |
| 316 |
\] |
| 317 |
% |
| 318 |
This package modifies the definitions of |
| 319 |
the size modifiers (of \ctanpkg{amsmath}) |
| 320 |
to automatically adjust to sub/superscripts |
| 321 |
(subject to availability in the font): |
| 322 |
% |
| 323 |
\[ |
| 324 |
|e^{\big(ax+b\big)}| \to e^{\big(ax+b\big)} |
| 325 |
\] |
| 326 |
|
| 327 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 328 |
\subsection{Spacing and Math Classes} |
| 329 |
\label{sec:spacing} |
| 330 |
|
| 331 |
Another shortcoming of the variable-size delimiters is that |
| 332 |
the spacing is noticeably different from their fixed-size counterparts: |
| 333 |
% |
| 334 |
\[ |
| 335 |
\begin{aligned} |
| 336 |
|\square(ax+b)\square| |
| 337 |
&\to \square(ax+b)\square |
| 338 |
\\ |
| 339 |
|\square\bigl(ax+b\bigr)\square| |
| 340 |
&\to \square\bigl(ax+b\bigr)\square |
| 341 |
\\ |
| 342 |
|\square\left(ax+b\right)\square| |
| 343 |
&\to \square\left(ax+b\right)\square |
| 344 |
\\ |
| 345 |
|\square\left(ax+\big.b\right)\square| |
| 346 |
&\to \square\left(ax+\big.b\right)\square |
| 347 |
\end{aligned} |
| 348 |
\] |
| 349 |
% |
| 350 |
Often the construct |\left*| \ldots|\right*| |
| 351 |
leaves a large amount of space around it. |
| 352 |
A suitable way to fix this problem |
| 353 |
is to adjust the math class as follows: |
| 354 |
% |
| 355 |
\[ |
| 356 |
\begin{aligned} |
| 357 |
|\square(ax+b)\square| |
| 358 |
&\to \square(ax+b)\square |
| 359 |
\\ |
| 360 |
|\square\mathopen{}\mathclose{\left(ax+b\right)}\square| |
| 361 |
&\to \square\mathopen{}\mathclose{\left(ax+b\right)}\square |
| 362 |
\end{aligned} |
| 363 |
\] |
| 364 |
% |
| 365 |
This makes the expression look like |\mathopen| from the left |
| 366 |
and like |\mathclose| from the right. Importantly, |
| 367 |
the delimited expression should be contained in |
| 368 |
the |\mathclose| block so as to place any following |
| 369 |
sub/superscripts at the appropriate height. |
| 370 |
Unfortunately, the fix is too elaborate |
| 371 |
in comparison to the benefits of appropriate spacing. |
| 372 |
For practical purposes, consistent spacing can only be achieved |
| 373 |
by a more convenient mechanism. |
| 374 |
|
| 375 |
On a related note, it is important to correctly specify |
| 376 |
the math class (such as |\mathopen| or |\mathclose|) |
| 377 |
for the delimiters, for example: |
| 378 |
% |
| 379 |
\[ |
| 380 |
\begin{aligned} |
| 381 |
|\big(-1\big)| &\to \big(-1\big) |
| 382 |
\\ |
| 383 |
|\bigl(-1\bigr)| &\to \bigl(-1\bigr) |
| 384 |
\end{aligned} |
| 385 |
\] |
| 386 |
% |
| 387 |
The math class can also make a major difference for intermediate delimiters, |
| 388 |
e.g.: |
| 389 |
% |
| 390 |
\[ |
| 391 |
\begin{aligned} |
| 392 |
|\bigl<\psi\big|\verbbar|\psi\bigr>| |
| 393 |
&\to \bigl<\psi\big\vert\psi\bigr> |
| 394 |
\\ |
| 395 |
|\bigl<\psi\mathpunct\big|\verbbar|\psi\bigr>| |
| 396 |
&\to \bigl\langle\psi\mathpunct\big\vert\psi\bigr> |
| 397 |
\\ |
| 398 |
|\bigl<\psi\mathinner\big|\verbbar|\psi\bigr>| |
| 399 |
&\to \bigl\langle\psi\mathinner\big\vert\psi\bigr> |
| 400 |
\\ |
| 401 |
|\bigl<\psi\mathbin\big|\verbbar|\psi\bigr>| |
| 402 |
&\to \bigl\langle\psi\mathbin\big\vert\psi\bigr> |
| 403 |
\\ |
| 404 |
|\bigl<\psi\bigm|\verbbar|\psi\bigr>| |
| 405 |
&\to \bigl\langle\psi\bigm\vert\psi\bigr> |
| 406 |
\end{aligned} |
| 407 |
\] |
| 408 |
% |
| 409 |
Depending on the particular situation, |
| 410 |
any of these expressions may be the most appropriate representation. |
| 411 |
|
| 412 |
The package \ctanpkg{delimset} automatically takes care of the math classes |
| 413 |
of the left and right delimiters. It also offers several choices for |
| 414 |
intermediate delimiters to take the context into account. |
| 415 |
|
| 416 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 417 |
\subsection{Compounds and Broken Lines} |
| 418 |
|
| 419 |
The mechanism provided by the package requires the delimited expression |
| 420 |
to appear as an uninterrupted compound. In particular, the expression cannot |
| 421 |
span several lines in a multi-line equation or several columns in a matrix. |
| 422 |
The same restriction applies to the elementary |\left| and |\right| construct. |
| 423 |
In cases where delimited expressions are torn apart across several blocks, |
| 424 |
the delimiters have to be typeset individually. |
| 425 |
The package offers a mechanism to display individual delimiters |
| 426 |
of a given delimiter set. It also assists in maintaining |
| 427 |
the same type and size across blocks. |
| 428 |
Being able to display individual delimiters of defined delimiter sets |
| 429 |
offers a broad range of (ab)use. |
| 430 |
|
| 431 |
Individual delimiters of a set can be selected and displayed |
| 432 |
by specifying appropriate flags, |
| 433 |
for example: |
| 434 |
% |
| 435 |
\[ |
| 436 |
|\brk(|\to{\brk(},\qquad |
| 437 |
|\brk)|\to{\brk)} |
| 438 |
\] |
| 439 |
% |
| 440 |
These flags can be combined with the size specifier |
| 441 |
or other bracket modifiers, |
| 442 |
e.g.: |
| 443 |
% |
| 444 |
\[ |
| 445 |
|\brk^3(|\to{\brk^3(},\qquad |
| 446 |
|\brk[s]^2)|\to{\brk[s]^2)} |
| 447 |
\] |
| 448 |
% |
| 449 |
This enables to conveniently split delimited expressions over blocks of code, |
| 450 |
e.g.: |
| 451 |
% |
| 452 |
\[ |
| 453 |
|\brk[s]^3(\frac{A}{B}|\ldots\Big/\mkern-9mu\Big/\ldots|\frac{C}{D}\brk[s]^3)| |
| 454 |
\to |
| 455 |
\brk[s]^3(\frac{A}{B}\cdots\bigg/\mkern-12mu\bigg/\cdots\frac{C}{D}\brk[s]^3) |
| 456 |
\] |
| 457 |
% |
| 458 |
Here, the type and modifiers specifying the delimiter set |
| 459 |
are repeated for all individual delimiters. |
| 460 |
To simplify such expressions and their maintenance, |
| 461 |
the package provides global registers which store |
| 462 |
the type and size of delimiters. |
| 463 |
With those, the above expression can be abbreviated as: |
| 464 |
% |
| 465 |
\[ |
| 466 |
|\brk[s]^3[|\ldots\big/\mkern-6mu\big/\ldots|\usedelim]| |
| 467 |
\quad\text{or}\quad |
| 468 |
|\brk[s]^3[|\ldots\big/\mkern-6mu\big/\ldots|\brk]| |
| 469 |
\] |
| 470 |
% |
| 471 |
Here, |\usedelim]|, alternatively |\brk]|, |
| 472 |
closes the delimiter set with |
| 473 |
the type and options previously specified by |\brk...[|. |
| 474 |
This mechanism respects nesting, and for even broader control |
| 475 |
there exists a more elaborate solution using registers, see below. |
| 476 |
|
| 477 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 478 |
\subsection{Philosophy} |
| 479 |
|
| 480 |
Semantic typesetting is one of the philosophies behind \LaTeX{}: |
| 481 |
The author should focus on the content |
| 482 |
while the layout is taken care of by the engine. |
| 483 |
The (body of a) source file largely codes the contents of the document, |
| 484 |
while the layout is largely specified |
| 485 |
by the kernel, classes, styles and macro definitions |
| 486 |
(in the preamble). |
| 487 |
In order for the separation of content and layout to work well, |
| 488 |
the meaning of the content must be accurately specified by the source file |
| 489 |
so that the appropriate layout can be applied to it. |
| 490 |
For example, a left bracket `|(|' can have many meanings, |
| 491 |
which the engine could not possibly guess. |
| 492 |
Even a simple compound expression such as |[A,B]| could |
| 493 |
have different meanings depending on context |
| 494 |
such as a compact interval or a commutator. |
| 495 |
A semantic coding of the latter two concepts |
| 496 |
such as |\intv{A}{B}| vs.\ |\comm{A}{B}| |
| 497 |
clearly distinguishes between them. |
| 498 |
This allows the typesetting engine to represent them appropriately |
| 499 |
in every situation. |
| 500 |
It also allows to consistently define or adjust |
| 501 |
the typeset representation globally |
| 502 |
according to one's taste, such as $[A,B]$ vs.\ $[A;B]$. |
| 503 |
The price to pay is a larger number of abstract commands |
| 504 |
(which possibly evaluate to the same expression) |
| 505 |
and using them to specify the semantics throughout the source file |
| 506 |
(or at least where practical and useful). |
| 507 |
Conversely, the price to pay for an immediate typesetting scheme is that |
| 508 |
all notations need to be fixed at the start, and later adjustments require |
| 509 |
an elaborate search and replacement |
| 510 |
of (somewhat ambiguous) patterns like |[|$x$|,|$y$|]|. |
| 511 |
|
| 512 |
Another distinction between \TeX{} and \LaTeX{} is that the former |
| 513 |
frequently uses free-format expressions such as $|{x\over y}|$ |
| 514 |
whereas the latter normally uses structured commands with arguments |
| 515 |
such as $|\frac{x}{y}|$. |
| 516 |
In that sense, the construct {|\left(ax+b\right)|} |
| 517 |
belongs to the world of \TeX{}, whereas an expression like |
| 518 |
{|\delim()*{ax+b}|} fits the \LaTeX{} framework better. |
| 519 |
|
| 520 |
|
| 521 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 522 |
\subsection{Related CTAN Packages} |
| 523 |
|
| 524 |
There are at least three other packages which offer a similar functionality: |
| 525 |
% |
| 526 |
\begin{itemize} |
| 527 |
\item |
| 528 |
The package \ctanpkg{delim} supplies a command |
| 529 |
|\delimdef| to declare a set of delimiters |
| 530 |
which is similar to the present |\DeclareMathDelimiterSet|. |
| 531 |
The size of delimiters to be used in each case |
| 532 |
is then specified by a prefix command such as |\mbig| or |\mauto|. |
| 533 |
\item |
| 534 |
The package \ctanpkg{mathtools} |
| 535 |
supplies commands |\DeclarePairedDelimiter...| (among many other things) |
| 536 |
which are similar to the present |\DeclareMathDelimiterSet|. |
| 537 |
The size of delimiters to be used in each case |
| 538 |
is then specified by an optional argument |
| 539 |
such as `|*|' or |[\big]|. |
| 540 |
\item |
| 541 |
The package \ctanpkg{delimseasy} |
| 542 |
defines a collection of useful delimiters such as |\prn| for |
| 543 |
round parentheses or |\sqpr| square parentheses. |
| 544 |
Modifier letters can be prepended and appended to adjust their size. |
| 545 |
\end{itemize} |
| 546 |
% |
| 547 |
A functionality of the present package |
| 548 |
not offered by any of the above packages is |
| 549 |
to typeset delimiters on the fly, |
| 550 |
e.g.: |
| 551 |
% |
| 552 |
\[ |
| 553 |
|\delimpair<|\verbbar|>!{\psi}{\psi}| |
| 554 |
\to\delimpair<\vert>!{\psi}{\psi} |
| 555 |
\] |
| 556 |
% |
| 557 |
The mechanism to specify the size is leaner in the sense that it uses |
| 558 |
only a single character and a single command. |
| 559 |
|
| 560 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 561 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 562 |
\section{Usage} |
| 563 |
|
| 564 |
To use the package \ctanpkg{delimset} add the command |
| 565 |
% |
| 566 |
\[ |
| 567 |
|\usepackage{delimset}| |
| 568 |
\] |
| 569 |
% |
| 570 |
to the preamble of your \LaTeX{} document. |
| 571 |
If not yet present, |
| 572 |
the package \ctanpkg{amsmath} will be loaded automatically. |
| 573 |
|
| 574 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 575 |
\subsection{Delimiter Sets and Presentation Flags} |
| 576 |
\label{sec:flags} |
| 577 |
|
| 578 |
The package provides commands to represent various delimiter sets, |
| 579 |
see \secref{sec:inline} and \secref{sec:declare} below. |
| 580 |
Their display can be modified systematically by specifying flags. |
| 581 |
A delimiter set |\|\emph{name}, e.g.\ |\brk|, is typically invoked by |
| 582 |
a sequence like: |
| 583 |
% |
| 584 |
\[ |
| 585 |
|\|\emph{name}\ \emph{flags}\ |{|\emph{expr1}|}||{|\emph{expr2}|}|\ldots |
| 586 |
\] |
| 587 |
% |
| 588 |
where \emph{expr(n)} are the terms to be enclosed by the delimiters |
| 589 |
and the optional \emph{flags} adjust the presentation of delimiters. |
| 590 |
The \emph{flags} are described as follows: |
| 591 |
|
| 592 |
First, a size modifier flag controls the size of the delimiters |
| 593 |
to be displayed. It can take one of the following values: |
| 594 |
% |
| 595 |
\begin{longtablestr}{rl} |
| 596 |
|0|& default size (0.96 times default line height) |
| 597 |
\\ |
| 598 |
|!|, |+|& increase size by one step |
| 599 |
\\ |
| 600 |
|^1|& size |\big| (1.2 times default line height) |
| 601 |
\\ |
| 602 |
|^2|& size |\Big| (1.8 times default line height) |
| 603 |
\\ |
| 604 |
|^3|& size |\bigg| (2.4 times default line height) |
| 605 |
\\ |
| 606 |
|^4|& size |\Bigg| (3.0 times default line height) |
| 607 |
\\ |
| 608 |
|^|\emph{n}, |^{|\emph{x}|}|& flexible size adjustment |
| 609 |
(\emph{n}=|0|\ldots|9|; \emph{x}: decimal number) |
| 610 |
\\ |
| 611 |
|_{|\emph{h}|}|& adjustment to absolute height \emph{h} (centred) |
| 612 |
\\ |
| 613 |
|*|& variable size |\left|\ \ldots|\right| |
| 614 |
\end{longtablestr} |
| 615 |
% |
| 616 |
The intended delimiter size is stored as the dimension variable: |
| 617 |
% |
| 618 |
\[ |
| 619 |
|\delimsize| |
| 620 |
\] |
| 621 |
% |
| 622 |
It may be used to adjust spacing within the delimiter set |
| 623 |
proportional to the size of the delimiters. |
| 624 |
Note that the actual size of delimiters may deviate |
| 625 |
depending on availability within the given font. |
| 626 |
Note further that the size cannot be determined for variable-size delimiters |
| 627 |
(`|*|') and thus size |\Big| is assumed for this case. |
| 628 |
Note finally that the sub/superscript styles are not taken into |
| 629 |
account and |\delimsize| applies to the default case |\textstyle|. |
| 630 |
The package also supplies a macro to add horizontal glue |
| 631 |
proportional to the intended delimiter size: |
| 632 |
% |
| 633 |
\[ |
| 634 |
|\kerndelim{|\emph{width}|}| |
| 635 |
\] |
| 636 |
% |
| 637 |
Here, \emph{width} is the amount of horizontal glue |
| 638 |
in units of mu scaled by the ratio of |\delimsize| |
| 639 |
and the current math font height. |
| 640 |
The macro does adjust for the selected script style. |
| 641 |
|
| 642 |
Second, a delimiter selection flag is used to pick out |
| 643 |
and display just one individual delimiter within the set. |
| 644 |
It can take one of the following values: |
| 645 |
% |
| 646 |
\begin{longtablestr}{rl} |
| 647 |
|(|& left delimiter |
| 648 |
\\ |
| 649 |
\verbbar, |,|& first intermediate delimiter |
| 650 |
\\ |
| 651 |
|?|\emph{n}& \emph{n}-th delimiter (starting with |0|: left) |
| 652 |
\\ |
| 653 |
|)|& right delimiter |
| 654 |
\end{longtablestr} |
| 655 |
|
| 656 |
Third, register flags store and retrieve delimiter sets |
| 657 |
for splitting them across blocks or lines: |
| 658 |
% |
| 659 |
\begin{longtablestr}{@{}rl@{}} |
| 660 |
|[|& push delimiter type to register stack, display left delimiter |
| 661 |
(similar to `|>.(|') |
| 662 |
\\ |
| 663 |
|]|& pop delimiter type from stack, display right delimiter |
| 664 |
(similar to `|<.)|') |
| 665 |
\\ |
| 666 |
|>|\emph{r}, |>{|\emph{reg}|}|& store delimiter type |
| 667 |
to register \emph{r} or \emph{reg} |
| 668 |
\\ |
| 669 |
|<|\emph{r}, |<{|\emph{reg}|}|& retrieve delimiter type |
| 670 |
from register \emph{r} or \emph{reg} |
| 671 |
\end{longtablestr} |
| 672 |
% |
| 673 |
A register stores the type of delimiter set (|\|\emph{name}), |
| 674 |
the desired size (except for variable size `|*|') |
| 675 |
as well as the math class of the compound (`|'|' vs. `|"|', see below). |
| 676 |
The register stack enables convenient access to nested delimiter sets, |
| 677 |
and the special register `|.|' points to the top of the stack. |
| 678 |
A stored register can be retrieved and displayed by the macro: |
| 679 |
% |
| 680 |
\begin{longtablestr}{l} |
| 681 |
|\usedelim|\,\emph{r}\ \emph{flags}\ \emph{sel} |
| 682 |
\quad\text{or}\quad |
| 683 |
|\usedelim|\{\emph{reg}\}\,\emph{flags}\ \emph{sel} |
| 684 |
\quad\text{or}\quad |
| 685 |
|\usedelim|\,\emph{sel} |
| 686 |
\end{longtablestr} |
| 687 |
% |
| 688 |
Here, \emph{sel} |
| 689 |
is a flag to select an individual delimiter |
| 690 |
(`|(|', `\verbbar', `|,|', `|?|\emph{n}', `|)|' or `|]|'), see above. |
| 691 |
The abbreviated form without register specification operates |
| 692 |
on the top of the register stack. |
| 693 |
|
| 694 |
In addition, there are some general purpose flags: |
| 695 |
% |
| 696 |
\begin{longtablestr}{rl} |
| 697 |
|.|& terminates flag processing |
| 698 |
\\ |
| 699 |
|:|& enclose delimiter set in block (for using total box dimensions) |
| 700 |
\\ |
| 701 |
|'|& render delimiter set as |\mathopen| and |\mathclose| |
| 702 |
\\ |
| 703 |
|"|& render delimiter set as |\mathinner| |
| 704 |
\\ |
| 705 |
|-|& display phantom delimiters (for individual delimiters) |
| 706 |
\end{longtablestr} |
| 707 |
|
| 708 |
Please note the following: |
| 709 |
% |
| 710 |
\begin{itemize} |
| 711 |
\item |
| 712 |
A delimiter selector (including the combined flags `|[|' and `|]|') |
| 713 |
terminates flag processing, |
| 714 |
therefore all relevant flags must be specified before it. |
| 715 |
\item |
| 716 |
Parsing also stops with the opening of the first term argument |
| 717 |
by means of the opening brace `|{|'. |
| 718 |
\item |
| 719 |
Parsing can also be terminated manually by specifying the flag `|.|' |
| 720 |
(in case the opening brace `|{|' for arguments is missing for whatever reason). |
| 721 |
\item |
| 722 |
Any other letter or token at the location of \emph{flags} |
| 723 |
is interpreted as an unrecognised flag and triggers a compiler error. |
| 724 |
For instance, |\brk{x}| must not be abbreviated as |\brk x| |
| 725 |
because `|x|' would be interpreted as a flag |
| 726 |
(it might be abbreviated as |\brk.x|). |
| 727 |
\item |
| 728 |
The legacy size modifier flags `|1|' \ldots `|4|' |
| 729 |
provided for backward compatibility have the same effect as `|^1|'\ldots`|^4|'. |
| 730 |
\item |
| 731 |
The phantom delimiter flag `|-|' does not work for variable size. |
| 732 |
It is intended for reserving space for individual delimiters |
| 733 |
when they are composed manually into sets (e.g.\ across lines). |
| 734 |
\item |
| 735 |
Technically, individual delimiters can be produced in the variable size version |
| 736 |
(even though it may defeat the purpose of the delimiter selection mechanism). |
| 737 |
One has to pay attention when using |
| 738 |
only the opening or only the closing delimiters from the package |
| 739 |
and counterbalancing it by direct code for the opposite side. |
| 740 |
This is because `|*(|' and `|*)|' do not directly translate to |
| 741 |
|\left|\emph{delim} and |\right|\emph{delim} |
| 742 |
due to proper spacing, see \secref{sec:spacing}. |
| 743 |
Instead, they translate to: |
| 744 |
% |
| 745 |
\[ |
| 746 |
\begin{aligned} |
| 747 |
|*(|&\to|\mathopen{}\mathclose\bgroup\left|\emph{delim} |
| 748 |
\\ |
| 749 |
|*)|&\to|\right|\emph{delim}|\egroup| |
| 750 |
\end{aligned} |
| 751 |
\] |
| 752 |
% |
| 753 |
One should use analogous code to complete the manual variable size block. |
| 754 |
|
| 755 |
Note that similar restrictions apply to using the flag `|:|' |
| 756 |
for block enclosure which uses |\bgroup| and |\egroup| as well. |
| 757 |
|
| 758 |
As it does not make much sense to use variable-size (`|*|') |
| 759 |
and block (`|:|') compounds for individual delimiter selection, |
| 760 |
the state of these flags is not stored in the global registers. |
| 761 |
|
| 762 |
\item |
| 763 |
The delimiter selectors `|[|' and `|]|' implement a stack, |
| 764 |
and they must be properly balanced. |
| 765 |
Technically, they access the register `|.|\emph{n}' |
| 766 |
with the stack counter \emph{n}=1,2,3\ldots\ a global variable |
| 767 |
which is increased or decreased, respectively. |
| 768 |
The special register `|.|' points to the current top of the stack |
| 769 |
to enable access to intermediate delimiters. |
| 770 |
\end{itemize} |
| 771 |
|
| 772 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 773 |
\subsection{Inline Declarations} |
| 774 |
\label{sec:inline} |
| 775 |
|
| 776 |
The package provides three general purpose commands |
| 777 |
to compose delimiter sets with one, two or three encapsulated expressions: |
| 778 |
% |
| 779 |
\begin{longtablestr}{l} |
| 780 |
|\delim{|\emph{l}|}{|\emph{r}|}|\emph{flags}|{|\emph{expr}|}| |
| 781 |
\\ |
| 782 |
|\delimpair{|\emph{l}|}{|\emph{m}|}{|\emph{r}|}| |
| 783 |
\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| |
| 784 |
\\ |
| 785 |
|\delimtriple{|\emph{l}|}{|\emph{m}|}{|\emph{n}|}{|\emph{r}|}| |
| 786 |
\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}{|\emph{expr3}|}| |
| 787 |
\end{longtablestr} |
| 788 |
% |
| 789 |
The expression(s) \emph{expr(n)} will be surrounded by the |
| 790 |
delimiters \emph{l} and \emph{r} |
| 791 |
and, in the case of more than one expression, |
| 792 |
they will be separated by the delimiters \emph{m}, \emph{n}: |
| 793 |
% |
| 794 |
\begin{longtablestr}{l} |
| 795 |
\emph{l} \emph{expr} \emph{r}, |
| 796 |
\qquad |
| 797 |
\emph{l} \emph{expr1} \emph{m} \emph{expr2} \emph{r}, |
| 798 |
\qquad |
| 799 |
\emph{l} \emph{expr1} \emph{m} \emph{expr2} |
| 800 |
\emph{n} \emph{expr3} \emph{r} |
| 801 |
\end{longtablestr} |
| 802 |
|
| 803 |
Here, \emph{l}, \emph{r}, \emph{m}, \emph{n} |
| 804 |
should be math delimiters \emph{delim} |
| 805 |
(elementary symbols which can be used for |\left| and |\right|) |
| 806 |
or the dot `|.|' for the null delimiter. |
| 807 |
The delimiter set expression can be adjusted in two ways: |
| 808 |
|
| 809 |
First, size adjustment |
| 810 |
for the delimiters \emph{l}, \emph{r}, \emph{m}, \emph{n} |
| 811 |
can be suppressed by a starred variant: |
| 812 |
% |
| 813 |
\[ |
| 814 |
|{*|\emph{token}|}| |
| 815 |
\qquad\text{or}\qquad |
| 816 |
|{*{|\emph{expr}|}}| |
| 817 |
\] |
| 818 |
% |
| 819 |
This allows to use an arbitrary \emph{token} |
| 820 |
or a compound expression \emph{expr} in place of a delimiter \emph{delim}. |
| 821 |
This is useful when a delimiter character should not adjust in size |
| 822 |
(e.g.\ commas), or if a flexible-size version of the character |
| 823 |
is not available. |
| 824 |
Compounds can be used to design size-adjusting delimiters |
| 825 |
more flexibly using |\selectdelim| and |\doubledelim| (see below). |
| 826 |
One might also use a compound expression |
| 827 |
to create a null delimiter with non-zero width |
| 828 |
(the width may be specified by |\kerndelim| |
| 829 |
to make it proportional to the delimiter size). |
| 830 |
|
| 831 |
Second, the intended math class |
| 832 |
of the intermediate delimiters \emph{m}, \emph{n} |
| 833 |
may be adjusted in order to achieve a more appropriate automatic spacing |
| 834 |
by using |{[|\emph{class}|]|\emph{delim}|}|. |
| 835 |
Here, \emph{class} specifies |
| 836 |
the intended math class of the delimiter \emph{delim} |
| 837 |
according to: |
| 838 |
% |
| 839 |
\begin{longtablestr}{rl} |
| 840 |
$\left.\begin{tabular}[c]{r} |
| 841 |
\emph{delim}\\|{|\emph{delim}|}| |
| 842 |
\end{tabular}\right\}$ |
| 843 |
& |
| 844 |
$\left\{\begin{tabular}[c]{l} |
| 845 |
\text{no glue for size-adjusted delimiters (same as }|[o]|\text{)} |
| 846 |
\\ |
| 847 |
\text{determined by expression for unadjusted size (}|*|\text{ variant)} |
| 848 |
\end{tabular}\right.$ |
| 849 |
\\ |
| 850 |
|{[o]|\emph{delim}|}|& |
| 851 |
no glue, similar to |\big|, |\mathord|, |\mathopen|, |\mathclose| |
| 852 |
\\ |
| 853 |
|{[p]|\emph{delim}|}|& |
| 854 |
followed by |\thinmuskip|, similar to |\bigp|, |\mathpunct| |
| 855 |
\\ |
| 856 |
|{[i]|\emph{delim}|}|& |
| 857 |
surrounded by |\thinmuskip|, similar to |\bigi|, |\mathinner| |
| 858 |
\\ |
| 859 |
|{[b]|\emph{delim}|}|& |
| 860 |
surrounded by |\medmuskip|, similar to |\bigb|, |\mathbin| |
| 861 |
\\ |
| 862 |
|{[m]|\emph{delim}|}|& |
| 863 |
surrounded by |\thickmuskip|, similar to |\bigm|, |\mathrel| |
| 864 |
\end{longtablestr} |
| 865 |
|
| 866 |
Please note the following: |
| 867 |
% |
| 868 |
\begin{itemize} |
| 869 |
\item |
| 870 |
The left and right delimiters \emph{l} and \emph{r} |
| 871 |
are assigned to special classes: |
| 872 |
They leave no initial and final glue on the enclosed expressions |
| 873 |
(same as |\mathopen| and |\mathclose|). |
| 874 |
From the outside, the delimiter set appears |
| 875 |
either as a combination of |\mathopen|+|\mathclose| (flag `|'|') |
| 876 |
or as |\mathinner| (flag `|"|'). |
| 877 |
\item |
| 878 |
The legacy class |[.]| provided for backward compatibility |
| 879 |
specifies delimiters with unadjusted size: |
| 880 |
the compound |{[.]|\emph{expr}|}| has the same effect as |{*{|\emph{expr}|}}|. |
| 881 |
\item |
| 882 |
The legacy class |[c]| provided for backward compatibility |
| 883 |
has the same effect as |[o]|. |
| 884 |
\item |
| 885 |
Unadjusted-size delimiters can be combined with math classes as: |
| 886 |
% |
| 887 |
\[ |
| 888 |
|{[|\emph{class}|]*|\emph{token}|}| |
| 889 |
\qquad\text{or}\qquad |
| 890 |
|{[|\emph{class}|]*{|\emph{expr}|}}| |
| 891 |
\] |
| 892 |
% |
| 893 |
\item |
| 894 |
The opening square bracket `|[|' |
| 895 |
takes the dual role of indicating the optional |[|\emph{class}|]| argument. |
| 896 |
To avoid conflicts on intermediate delimiters, |
| 897 |
opening square bracket delimiters should be encoded as |
| 898 |
`|{{[}}|' (for |\delim...|) or `|{[}|' (for |\selectdelim|) |
| 899 |
rather than `|[|'. |
| 900 |
\end{itemize} |
| 901 |
|
| 902 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 903 |
\subsection{Declarations} |
| 904 |
\label{sec:declare} |
| 905 |
|
| 906 |
The above constructs can be used to define new delimiter commands via: |
| 907 |
% |
| 908 |
\begin{longtablestr}{l} |
| 909 |
|\newcommand{\|\emph{name}|}{\delim{|\emph{l}|}{|\emph{r}|}| |
| 910 |
\emph{flags}|}| |
| 911 |
\\ |
| 912 |
|\newcommand{\|\emph{name}|}{\delimpair{|\emph{l}|}{|\emph{m}|}{|\emph{r}|}| |
| 913 |
\emph{flags}|}| |
| 914 |
\\ |
| 915 |
|\newcommand{\|\emph{name}|}{\delimtriple{|\emph{l}|}{|\emph{m}|}| |
| 916 |
|{|\emph{n}|}{|\emph{r}|}|\emph{flags}|}| |
| 917 |
\end{longtablestr} |
| 918 |
% |
| 919 |
Here it makes sense to drop all arguments |
| 920 |
starting at the optional \emph{flags} argument from the definition. |
| 921 |
The \TeX{} parsing mechanism will then automatically |
| 922 |
use the tokens following |\|\emph{name} including the optional size modifier. |
| 923 |
If any of the encapsulated expression(s) are to be passed as |
| 924 |
explicit arguments to |\|\emph{name}, |
| 925 |
one will have to find an alternative way to pass \emph{flags}. |
| 926 |
However, it is possible to predefine \emph{flags} |
| 927 |
which can be overridden by further \emph{flags} specified by the user. |
| 928 |
|
| 929 |
The above declarations via |\delim...| |
| 930 |
should be sufficient for most situations. |
| 931 |
However, there is an even more flexible way to declare delimiter sets: |
| 932 |
% |
| 933 |
\[ |
| 934 |
|\DeclareMathDelimiterSet{\|\emph{name}|}[|\emph{narg}|]{|\emph{compositor}|}| |
| 935 |
\] |
| 936 |
% |
| 937 |
The syntax of this command is equivalent to the one of |\newcommand|. |
| 938 |
The difference is that the command |\|\emph{name} first looks |
| 939 |
for the \emph{flags} argument as |
| 940 |
described above in \secref{sec:inline}. |
| 941 |
It remembers the desired size for evaluating |
| 942 |
the macro expression \emph{compositor}. |
| 943 |
Then it parses the arguments as if the command |
| 944 |
was declared by |\newcommand|. |
| 945 |
|
| 946 |
As usual, the macro expression \emph{compositor} contains the command arguments |
| 947 |
specified by |#1|, |#2|, \ldots. Note that these should |
| 948 |
be encapsulated in groups |{#1}|, |{#2}|, \ldots, |
| 949 |
in order to prevent them from overwriting definitions |
| 950 |
at the level of the current group. |
| 951 |
It should also contain the desired math delimiters |
| 952 |
specified by: |
| 953 |
% |
| 954 |
\begin{longtablestr}{l} |
| 955 |
|\selectdeliml|[|*|]|{|\emph{delim}|}| |
| 956 |
\\ |
| 957 |
|\selectdelim[|\emph{class}|]|[|*|]|{|\emph{delim}|}| |
| 958 |
\\ |
| 959 |
|\selectdelimr|[|*|]|{|\emph{delim}|}| |
| 960 |
\end{longtablestr} |
| 961 |
% |
| 962 |
The three commands must be in proper sequence |
| 963 |
starting with |\selectdeliml| followed by arbitrarily many |
| 964 |
|\selectdelim| and terminated by |\selectdelimr|. |
| 965 |
The math classes \emph{class} and starred variants |
| 966 |
are defined analogously to \secref{sec:inline}. |
| 967 |
Here, the sizes are adjusted automatically |
| 968 |
according to the previously specified modifier. |
| 969 |
Note that the expressions for the starred forms may contain |
| 970 |
|\selectdelim| to produce delimiters in the desired size. |
| 971 |
Compounds of two identical delimiters |
| 972 |
with horizontal kerning adjustment \emph{width} (default |-2|) |
| 973 |
are produced by: |
| 974 |
% |
| 975 |
\[ |
| 976 |
|\doubledelim[|\emph{width}|]|\emph{delim} |
| 977 |
\] |
| 978 |
|
| 979 |
Picking out individual delimiters from a set |
| 980 |
declared by |\DeclareMathDelimiterSet| |
| 981 |
cannot be achieved automatically. |
| 982 |
Instead, a selector method may be specified manually (where needed) by: |
| 983 |
% |
| 984 |
\begin{longtablestr}{l} |
| 985 |
|\DeclareMathDelimiterSel{\|\emph{name}|}| |
| 986 |
\\ |
| 987 |
| {\selectdeliml{|\emph{l}|}|[|\||or\selectdelim{|\emph{m}|}|\ldots]|}| |
| 988 |
\\ |
| 989 |
| {\selectdelimr{|\emph{r}|}}| |
| 990 |
\end{longtablestr} |
| 991 |
% |
| 992 |
As many intermediate delimiters as needed can be specified |
| 993 |
at the end of the first argument; each one must start with `|\||or|'. |
| 994 |
|
| 995 |
For example, one might declare a set of double square brackets |
| 996 |
$\brk[S]{*}$ using: |
| 997 |
% |
| 998 |
\begin{longtablestr}{l} |
| 999 |
|\DeclareMathDelimiterSet{\dsb}[1]| |
| 1000 |
\\ |
| 1001 |
| {\selectdeliml{[}\kerndelim{-1.75}\selectdelim[o]{[}{#1}| |
| 1002 |
\\ |
| 1003 |
| \selectdelim[o]{]}\kerndelim{-1.75}\selectdelimr{]}}| |
| 1004 |
\end{longtablestr} |
| 1005 |
% |
| 1006 |
Here, the command |\kerndelim{-1.75}| reduces the spacing |
| 1007 |
between the two square brackets by approximately 1.75\,mu in default size. |
| 1008 |
This could be used for: |
| 1009 |
% |
| 1010 |
\[ |
| 1011 |
|\dsb^4{\dsb^3{\dsb^2{\dsb^1{\dsb{*}}}}}| |
| 1012 |
\to |
| 1013 |
\brk[S]^4{\brk[S]^3{\brk[S]^2{\brk[S]^1{\brk[S]{*}}}}} |
| 1014 |
\quad |
| 1015 |
|\dsb*|\ldots\to |
| 1016 |
\brk[S]*{\frac{x}{y}} |
| 1017 |
\] |
| 1018 |
% |
| 1019 |
An appropriate selector method for displaying individual |
| 1020 |
delimiters reads: |
| 1021 |
% |
| 1022 |
\begin{longtablestr}{l} |
| 1023 |
|\DeclareMathDelimiterSel{\dsb}| |
| 1024 |
\\ |
| 1025 |
| {\selectdeliml{[}\kerndelim{-1.75}\selectdelim[o]{[}}| |
| 1026 |
\\ |
| 1027 |
| {\selectdelim[o]]\kerndelim{-1.75}\selectdelimr{]}}| |
| 1028 |
\end{longtablestr} |
| 1029 |
% |
| 1030 |
An inline version of the above definitions |
| 1031 |
using compound expressions with manual resizing of the delimiters |
| 1032 |
(via |\selectdelim| and |\doubledelim|) is achieved by: |
| 1033 |
% |
| 1034 |
\[ |
| 1035 |
|\delim{*{\doubledelim[-1.75](}}{*{\doubledelim[-1.75])}}| |
| 1036 |
\] |
| 1037 |
|
| 1038 |
Finally, towards a very flexible manual composition |
| 1039 |
of delimiter sets, there is the macro: |
| 1040 |
% |
| 1041 |
\[ |
| 1042 |
|\parsedelimflags{|\emph{compositor}|}{|\emph{selector}|}|\emph{flags} |
| 1043 |
\] |
| 1044 |
% |
| 1045 |
It parses the modifier flags as described in \secref{sec:flags}. |
| 1046 |
The argument \emph{compositor} is code that displays the |
| 1047 |
composited delimiter set whereas \emph{selector} is a macro |
| 1048 |
that displays the delimiter number |\selecteddelim| of the set. |
| 1049 |
The \emph{flags} follow immediately and should be terminated by |
| 1050 |
an opening brace `|{|', the terminating flag `|.|' |
| 1051 |
or a delimiter selection flag. |
| 1052 |
|
| 1053 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1054 |
\subsection{Default Declarations} |
| 1055 |
\label{sec:defaultcommands} |
| 1056 |
|
| 1057 |
The package predefines four commonly used sets of delimiters: |
| 1058 |
% |
| 1059 |
\begin{itemize} |
| 1060 |
\item |
| 1061 |
|\brk[|\emph{type}|]|\emph{flags}|{|\emph{expr}|}| represents |
| 1062 |
a standard bracket around a single expression \emph{expr}. |
| 1063 |
The type of bracket can be specified by the optional |
| 1064 |
argument \emph{type} (default |r|): |
| 1065 |
% |
| 1066 |
\begin{longtablestr}{rc@{\ }cc@{\ }c} |
| 1067 |
& \multicolumn{2}{c}{single} & \multicolumn{2}{c}{double} \\ |
| 1068 |
round & |r|:& $\brk[r]{x}$ & |R|: & $\brk[R]{x}$ \\ |
| 1069 |
square & |s|:& $\brk[s]{x}$ & |S|: & $\brk[S]{x}$ \\ |
| 1070 |
curly & |c|:& $\brk[c]{x}$ & |C|: & $\brk[C]{x}$ \\ |
| 1071 |
angle & |a|:& $\brk[a]{x}$ & |A|: & $\brk[A]{x}$ \\ |
| 1072 |
bar & |v|:& $\brk[v]{x}$ & |V|: & $\brk[V]{x}$ \\ |
| 1073 |
\end{longtablestr} |
| 1074 |
% |
| 1075 |
\item |
| 1076 |
|\eval[|\emph{type}|]|\emph{flags}|{|\emph{expr}|}| represents |
| 1077 |
evaluation of a functional expression \emph{expr}. |
| 1078 |
The type of bracket can be specified by the optional |
| 1079 |
argument \emph{type}: |
| 1080 |
% |
| 1081 |
\begin{longtablestr}{l} |
| 1082 |
\emph{empty} or |[v]|: $\eval[v]{f(x)}_{a}$,\qquad |
| 1083 |
|[s]|: $\eval[s]{f(x)}_{a}^{b}$ |
| 1084 |
\end{longtablestr} |
| 1085 |
% |
| 1086 |
\item |
| 1087 |
|\abs|\emph{flags}|{|\emph{expr}|}| represents |
| 1088 |
the absolute value $\lvert\emph{expr}\rvert$. |
| 1089 |
\item |
| 1090 |
|\norm|\emph{flags}|{|\emph{expr}|}| represents |
| 1091 |
the norm $\lVert\emph{expr}\rVert$. |
| 1092 |
\end{itemize} |
| 1093 |
% |
| 1094 |
The above definitions can be suppressed by |
| 1095 |
setting the package option |stddef| to |false|, |
| 1096 |
see \secref{sec:packageoptions}. |
| 1097 |
The package also defines some extended sets of delimiters as follows: |
| 1098 |
% |
| 1099 |
\begin{itemize} |
| 1100 |
\item |
| 1101 |
|\pair[|\emph{type}\,\emph{sep}|]|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| |
| 1102 |
represents a pair(ing) $(\emph{expr1},\emph{expr2})$. |
| 1103 |
The type of bracket can be altered by the optional argument \emph{type} |
| 1104 |
as for |\brk|. |
| 1105 |
The separator \emph{sep} can be adjusted to `|,|' (default) for comma, |
| 1106 |
`|;|' for semi-colon and `\verbbar' for vertical bar. |
| 1107 |
% |
| 1108 |
\item |
| 1109 |
|\set|\emph{flags}|{|\emph{expr}|}| represents |
| 1110 |
the set $\{\emph{expr}\}$. |
| 1111 |
\item |
| 1112 |
|\setcond|\emph{flags}|{|\emph{expr}|}{|\emph{cond}|}| represents |
| 1113 |
a set with condition $\{\emph{expr}\vert\emph{cond}\}$. |
| 1114 |
\item |
| 1115 |
|\intv[|\emph{type}|]|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents |
| 1116 |
an interval from \emph{expr1} to \emph{expr2}. |
| 1117 |
The in/\hspace{0pt}exclusion of the bounds can be specified by the optional |
| 1118 |
argument \emph{type}: |
| 1119 |
% |
| 1120 |
\begin{longtablestr}{l} |
| 1121 |
\emph{empty} or |[c]|: closed $[a,b]$,\qquad |
| 1122 |
|[o]|: open $]a,b[$,\qquad |
| 1123 |
\begin{tabular}{l} |
| 1124 |
|[l]|: left-open $]a,b]$ |
| 1125 |
\\ |
| 1126 |
|[r]|: right-open $[a,b[$ |
| 1127 |
\end{tabular} |
| 1128 |
\end{longtablestr} |
| 1129 |
% |
| 1130 |
\item |
| 1131 |
|\avg|\emph{flags}|{|\emph{expr}|}| represents |
| 1132 |
some average $\langle\emph{expr}\rangle$. |
| 1133 |
\item |
| 1134 |
|\corr|\emph{flags}|{|\emph{expr}|}| represents |
| 1135 |
some correlator $\langle\emph{expr}\rangle$. |
| 1136 |
\item |
| 1137 |
|\comm|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents |
| 1138 |
the commutator $[\emph{expr1},\emph{expr2}]$. |
| 1139 |
\item |
| 1140 |
|\acomm|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents |
| 1141 |
the anti-commutator $\{\emph{expr1},\emph{expr2}\}$. |
| 1142 |
\item |
| 1143 |
|\bra|\emph{flags}|{|\emph{expr}|}| represents |
| 1144 |
a bra-vector $\langle\emph{expr}\rvert$ in quantum mechanics. |
| 1145 |
\item |
| 1146 |
|\ket|\emph{flags}|{|\emph{expr}|}| represents |
| 1147 |
a ket-vector $\lvert\emph{expr}\rangle$ in quantum mechanics. |
| 1148 |
\item |
| 1149 |
|\braket|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents |
| 1150 |
a bra-ket contraction $\langle\emph{expr1}\vert\emph{expr2}\rangle$. |
| 1151 |
\item |
| 1152 |
|\lfrac[|\emph{type}|]|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| describes |
| 1153 |
the linear representation $\emph{expr1}/\emph{expr2}$ of a fraction. |
| 1154 |
An optional argument \emph{type} taking values |[r]|, |[s]|, |[c]|, |[a]| |
| 1155 |
encloses the fraction in round, square, curly or angle brackets as for |\brk|. |
| 1156 |
\end{itemize} |
| 1157 |
% |
| 1158 |
The extended definitions need to be activated by |
| 1159 |
the package option |extdef|, see \secref{sec:packageoptions}. |
| 1160 |
|
| 1161 |
If the representations of the above delimiters do not suit the purpose |
| 1162 |
or taste of the user, they can be redefined with |\renewcommand|. |
| 1163 |
|
| 1164 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1165 |
\subsection{Auxiliary Commands} |
| 1166 |
\label{sec:auxcommands} |
| 1167 |
|
| 1168 |
In addition to the |\bigl|, |\bigr| and |\bigm| commands |
| 1169 |
(as well as their |\Big.|, |\bigg.| and |\Bigg.| counterparts), |
| 1170 |
the package defines three additional sets |\bigp|, |\bigb| and |\bigi| |
| 1171 |
(and counterparts). |
| 1172 |
Here |\bigp| implies the math class |\mathpunct|, |
| 1173 |
|\bigb| the class |\mathbin| and |\bigi| the class |\mathinner|. |
| 1174 |
|
| 1175 |
Furthermore, the package overloads the size calculation in the |\big...| |
| 1176 |
commands to properly account for the math styles in sub/superscripts |
| 1177 |
(|\scriptstyle|) and nested sub/\hspace{0pt}superscripts (|\scriptscriptstyle|). |
| 1178 |
The latter behaviour can be controlled by |
| 1179 |
the package option |scriptstyle|, see \secref{sec:packageoptions}. |
| 1180 |
|
| 1181 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1182 |
\subsection{Package Options} |
| 1183 |
\label{sec:packageoptions} |
| 1184 |
|
| 1185 |
Options can be passed to the package by: |
| 1186 |
% |
| 1187 |
\[ |
| 1188 |
|\usepackage[|\emph{opts}|]{delimset}| |
| 1189 |
\qquad |
| 1190 |
\text{or} |
| 1191 |
\qquad |
| 1192 |
|\PassOptionsToPackage{|\emph{opts}|}{delimset}| |
| 1193 |
\] |
| 1194 |
% |
| 1195 |
Here \emph{opts} is a comma-separated list of the available options: |
| 1196 |
% |
| 1197 |
\begin{itemize} |
| 1198 |
\item |
| 1199 |
|stddef|[|=true|\textbar|false|] |
| 1200 |
controls the activation of standard delimiter definitions specified in |
| 1201 |
\secref{sec:defaultcommands}. |
| 1202 |
If no value is given |true| is assumed; initially set to |true|. |
| 1203 |
\item |
| 1204 |
|extdef|[|=true|\textbar|false|] |
| 1205 |
controls the activation of extended delimiter definitions specified in |
| 1206 |
\secref{sec:defaultcommands}. |
| 1207 |
If no value is given |true| is assumed; initially set to |false|. |
| 1208 |
\item |
| 1209 |
|scriptstyle|[|=true|\textbar|false|] |
| 1210 |
controls the overwriting of size modifiers explained |
| 1211 |
in \secref{sec:auxcommands}. |
| 1212 |
If no value is given |true| is assumed; initially set to |true|. |
| 1213 |
\end{itemize} |
| 1214 |
|
| 1215 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1216 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1217 |
\section{Information} |
| 1218 |
|
| 1219 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1220 |
\subsection{Copyright} |
| 1221 |
|
| 1222 |
Copyright \copyright{} \thecopyright/ |
| 1223 |
|
| 1224 |
This work may be distributed and/or modified under the |
| 1225 |
conditions of the \LaTeX{} Project Public License, either version 1.3 |
| 1226 |
of this license or (at your option) any later version. |
| 1227 |
The latest version of this license is in |
| 1228 |
\url{https://www.latex-project.org/lppl.txt} |
| 1229 |
and version 1.3c or later is part of all distributions of \LaTeX{} |
| 1230 |
version 2008 or later. |
| 1231 |
|
| 1232 |
This work has the LPPL maintenance status `maintained'. |
| 1233 |
|
| 1234 |
The Current Maintainer of this work is Niklas Beisert. |
| 1235 |
|
| 1236 |
This work consists of the files |
| 1237 |
|README.txt|, \verbpkg|.ins| and \verbpkg|.dtx| |
| 1238 |
as well as the derived files listed below. |
| 1239 |
|
| 1240 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1241 |
\subsection{Files and Installation} |
| 1242 |
|
| 1243 |
The package consists of the files: |
| 1244 |
% |
| 1245 |
\begin{longtable}{ll} |
| 1246 |
|README.txt| & readme file \\ |
| 1247 |
\verbpkg|.ins| & installation file \\ |
| 1248 |
\verbpkg|.dtx| & source file \\ |
| 1249 |
\verbpkg|.sty| & package file \\ |
| 1250 |
\verbpkg|-samp.tex| & sample file \\ |
| 1251 |
\verbpkg|.pdf| & documentation \\ |
| 1252 |
\end{longtable} |
| 1253 |
% |
| 1254 |
The distribution consists of the files |
| 1255 |
|README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|. |
| 1256 |
% |
| 1257 |
\begin{itemize} |
| 1258 |
\item |
| 1259 |
Run \LaTeX{} on \verbpkg|.ins| to create the package \verbpkg|.sty| |
| 1260 |
and further documentation files. |
| 1261 |
\item |
| 1262 |
Copy the file \verbpkg|.sty| to an appropriate directory of your \LaTeX{} |
| 1263 |
distribution, e.g.\ \textit{texmf-root}|/tex/latex/|\verbpkg. |
| 1264 |
\item |
| 1265 |
Alternatively, you may copy \verbpkg|.sty| to your project directory. |
| 1266 |
\item |
| 1267 |
Run (pdf)\LaTeX{} on \verbpkg|.dtx| |
| 1268 |
to compile the documentation \verbpkg|.pdf| (this file). |
| 1269 |
\end{itemize} |
| 1270 |
|
| 1271 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1272 |
\subsection{Interaction with CTAN Packages} |
| 1273 |
|
| 1274 |
The package is related to other packages available at CTAN: |
| 1275 |
% |
| 1276 |
\begin{itemize} |
| 1277 |
\item |
| 1278 |
Compatibility with the \ctanpkg{amsmath} package |
| 1279 |
has been tested with v2.15d (\markdate{2016-06-28}) |
| 1280 |
and v2.17t (\markdate{2024-11-05}). |
| 1281 |
\item |
| 1282 |
This package uses the package \ctanpkg{keyval} from the |
| 1283 |
\ctanpkg{graphics} bundle to process optional arguments to the package options. |
| 1284 |
Compatibility with the \ctanpkg{keyval} package |
| 1285 |
has been tested with v1.15 (\markdate{2014-10-28}). |
| 1286 |
\item |
| 1287 |
The package \ctanpkg{icomma} modifies the spacing behaviour |
| 1288 |
of the comma character in math mode |
| 1289 |
which leads to inadequate spacing when it is used as a middle delimiter. |
| 1290 |
To achieve proper spacing in sample code, |
| 1291 |
use |{[p]*,}| rather than |{*,}|. |
| 1292 |
The extended commands |\intv|, |\comm|, |\acomm| and |\pair| |
| 1293 |
are compatible with the \ctanpkg{icomma} package |
| 1294 |
has been tested with v2.0 (\markdate{2002-03-10}). |
| 1295 |
\item |
| 1296 |
This package cooperates with the package \ctanpkg{beamer} |
| 1297 |
in not changing colours for delimiters. |
| 1298 |
Compatibility with the \ctanpkg{beamer} package |
| 1299 |
has been tested with v3.77 (\markdate{2026-01-22}). |
| 1300 |
\end{itemize} |
| 1301 |
|
| 1302 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1303 |
\iffalse |
| 1304 |
\subsection{Feature Suggestions} |
| 1305 |
|
| 1306 |
The following is a list of features which may be useful for future |
| 1307 |
versions of this package: |
| 1308 |
% |
| 1309 |
\begin{itemize} |
| 1310 |
\item parse flags without space |
| 1311 |
\item make optional arguments work for DeclareMathDelimiterSet? |
| 1312 |
(must go before parsing, but how to process and react?) |
| 1313 |
\item make unadjusted size have right height |
| 1314 |
\item automatic nesting of bracket types? -> depth stack? |
| 1315 |
\item handle cramped style properly (perhaps impossible in older tex engines) |
| 1316 |
\item semantic definition for () as argument of a function |
| 1317 |
\item more elaborate options for lfrac (brackets for numerator/denominator?!) |
| 1318 |
\end{itemize} |
| 1319 |
|
| 1320 |
\fi |
| 1321 |
|
| 1322 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1323 |
\subsection{Revision History} |
| 1324 |
|
| 1325 |
\iffalse |
| 1326 |
|
| 1327 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1328 |
\paragraph{vN.N.N+:} \markdate{20YY-MM-DD} |
| 1329 |
|
| 1330 |
\begin{itemize} |
| 1331 |
\item |
| 1332 |
\ldots |
| 1333 |
\end{itemize} |
| 1334 |
|
| 1335 |
\fi |
| 1336 |
|
| 1337 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1338 |
\paragraph{v2.3.1:} \markdate{2026-03-26} |
| 1339 |
|
| 1340 |
\begin{itemize} |
| 1341 |
\item |
| 1342 |
fixed vertical bars in conjunction with \ctanpkg{unicode-math} |
| 1343 |
(thanks to Ulrike Fischer for pointing out the issue) |
| 1344 |
\end{itemize} |
| 1345 |
|
| 1346 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1347 |
\paragraph{v2.3:} \markdate{2026-03-23} |
| 1348 |
|
| 1349 |
\begin{itemize} |
| 1350 |
\item |
| 1351 |
added more types to |\brk| and |\pair| including double delimiters |
| 1352 |
\item |
| 1353 |
added |\doubledelim| for compounds of two identical delimiters |
| 1354 |
\item |
| 1355 |
modifiers `|!|'/`|+|' can accumulate to increase size further |
| 1356 |
\item |
| 1357 |
provide new |\big|, |\Big|, |\bigg|, |\Bigg| if |scriptstyle| is active |
| 1358 |
\item |
| 1359 |
fix for not applying |math text| colour for delimiters in \ctanpkg{beamer} |
| 1360 |
\item |
| 1361 |
modifier `|[|' now throws an error when used with variable size |
| 1362 |
\item |
| 1363 |
package maintenance |
| 1364 |
\end{itemize} |
| 1365 |
|
| 1366 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1367 |
\paragraph{v2.2.2:} \markdate{2025-03-27} |
| 1368 |
|
| 1369 |
\begin{itemize} |
| 1370 |
\item |
| 1371 |
parameter fetching mechanism for |\usedelim| changed |
| 1372 |
\end{itemize} |
| 1373 |
|
| 1374 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1375 |
\paragraph{v2.2.1:} \markdate{2025-03-25} |
| 1376 |
|
| 1377 |
\begin{itemize} |
| 1378 |
\item |
| 1379 |
maintenance and manual update |
| 1380 |
\end{itemize} |
| 1381 |
|
| 1382 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1383 |
\paragraph{v2.2:} \markdate{2025-02-27} |
| 1384 |
|
| 1385 |
\begin{itemize} |
| 1386 |
\item |
| 1387 |
replicate the \ctanpkg{amsmath} mechanism for tracking the |
| 1388 |
vertical height of a default delimiter in order to |
| 1389 |
be independent of \ctanpkg{amsmath} |
| 1390 |
\end{itemize} |
| 1391 |
|
| 1392 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1393 |
\paragraph{v2.1:} \markdate{2025-01-05} |
| 1394 |
|
| 1395 |
\begin{itemize} |
| 1396 |
\item |
| 1397 |
the flags `|[|' and `|]|' now implement a register stack |
| 1398 |
for convenient individual access to nested delimiter sets |
| 1399 |
\item |
| 1400 |
syntax of |\usedelim| extended for direct access to top of register stack |
| 1401 |
\end{itemize} |
| 1402 |
|
| 1403 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1404 |
\paragraph{v2.0:} \markdate{2024-07-17} |
| 1405 |
|
| 1406 |
\begin{itemize} |
| 1407 |
\item |
| 1408 |
option to display individual delimiters |
| 1409 |
and to store them in global registers across blocks |
| 1410 |
(columns, lines, etc.) |
| 1411 |
\item |
| 1412 |
more general handling of unadjusted-size delimiters |
| 1413 |
\item |
| 1414 |
more general size adjustments |
| 1415 |
\item |
| 1416 |
added inner math class for intermediate delimiters |
| 1417 |
\item |
| 1418 |
added flag to enclose by open/close and inner math class |
| 1419 |
\item |
| 1420 |
added flag to display phantom delimiters |
| 1421 |
\item |
| 1422 |
selected size accessible by |\delimsize| |
| 1423 |
and add proportional kerning by |\kerndelim|. |
| 1424 |
\item |
| 1425 |
added extended definition |\lfrac| for plain inline fractions |
| 1426 |
\item |
| 1427 |
null delimiter now properly has zero width for variable size |
| 1428 |
\item |
| 1429 |
internal mechanisms revised |
| 1430 |
\item |
| 1431 |
compatibility with \ctanpkg{icomma} package |
| 1432 |
(thanks to Olivier Godin for pointing out the issue) |
| 1433 |
\end{itemize} |
| 1434 |
|
| 1435 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1436 |
\paragraph{v1.1:} \markdate{2018-12-30} |
| 1437 |
|
| 1438 |
\begin{itemize} |
| 1439 |
\item |
| 1440 |
classes added, class and size selection mechanism simplified |
| 1441 |
\end{itemize} |
| 1442 |
|
| 1443 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1444 |
\paragraph{v1.01:} \markdate{2018-01-17} |
| 1445 |
|
| 1446 |
\begin{itemize} |
| 1447 |
\item |
| 1448 |
manual rearranged |
| 1449 |
\end{itemize} |
| 1450 |
|
| 1451 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1452 |
\paragraph{v1.0:} \markdate{2016-11-01} |
| 1453 |
|
| 1454 |
\begin{itemize} |
| 1455 |
\item |
| 1456 |
extended standard definitions |
| 1457 |
\item |
| 1458 |
manual and installation package added |
| 1459 |
\item |
| 1460 |
first version published on CTAN |
| 1461 |
\end{itemize} |
| 1462 |
|
| 1463 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1464 |
\paragraph{v0.5--0.7:} \markdate{2016-05-08} -- \markdate{2016-09-04} |
| 1465 |
|
| 1466 |
\begin{itemize} |
| 1467 |
\item |
| 1468 |
basic functionality |
| 1469 |
\item |
| 1470 |
standard definitions |
| 1471 |
\end{itemize} |
| 1472 |
|
| 1473 |
%</main|manual> |
| 1474 |
%<*main> |
| 1475 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1476 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1477 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1478 |
|
| 1479 |
\appendix |
| 1480 |
%</main> |
| 1481 |
%<*main|source> |
| 1482 |
\raggedright |
| 1483 |
\settowidth\MacroIndent{\rmfamily\scriptsize 000\ } |
| 1484 |
|
| 1485 |
\DocInput{\thepkg/.dtx} |
| 1486 |
%</main|source> |
| 1487 |
|
| 1488 |
\end{document} |
| 1489 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1490 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1491 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1492 |
%</main|manual|source> |
| 1493 |
% \fi |
| 1494 |
% |
| 1495 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1496 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1497 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1498 |
% |
| 1499 |
% |
| 1500 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1501 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1502 |
% \section{Sample} |
| 1503 |
% \iffalse |
| 1504 |
%<*sample> |
| 1505 |
% \fi |
| 1506 |
% |
| 1507 |
% In this section we provide a \LaTeX{} example how to use |
| 1508 |
% some of the \ctanpkg{delimset} features. |
| 1509 |
% |
| 1510 |
% Preamble and beginning of document body: |
| 1511 |
% |
| 1512 |
% \begin{macrocode} |
| 1513 |
\documentclass[12pt]{article} |
| 1514 |
|
| 1515 |
\usepackage[margin=2cm]{geometry} |
| 1516 |
\usepackage{amsfonts} |
| 1517 |
\usepackage{delimset} |
| 1518 |
|
| 1519 |
\begin{document} |
| 1520 |
% \end{macrocode} |
| 1521 |
|
| 1522 |
sizes for default brackets: |
| 1523 |
% \begin{macrocode} |
| 1524 |
\[ |
| 1525 |
\brk^0{x},\quad |
| 1526 |
\brk^1{x},\quad |
| 1527 |
\brk^2{x},\quad |
| 1528 |
\brk^3{x},\quad |
| 1529 |
\brk^4{x} |
| 1530 |
\] |
| 1531 |
% \end{macrocode} |
| 1532 |
|
| 1533 |
styles for default brackets: |
| 1534 |
% \begin{macrocode} |
| 1535 |
\[ |
| 1536 |
\brk[r]{x},\quad |
| 1537 |
\brk[s]{x},\quad |
| 1538 |
\brk[c]{x},\quad |
| 1539 |
\brk[a]{x} |
| 1540 |
\] |
| 1541 |
% \end{macrocode} |
| 1542 |
|
| 1543 |
nested brackets: |
| 1544 |
% \begin{macrocode} |
| 1545 |
\[ |
| 1546 |
\brk[c]!!{\brk[s]!{\brk{ax+b}x+c}x+d} |
| 1547 |
\] |
| 1548 |
% \end{macrocode} |
| 1549 |
|
| 1550 |
default absolute value, norm and default evaluations: |
| 1551 |
% \begin{macrocode} |
| 1552 |
\[ |
| 1553 |
\abs*{\frac{ax+b}{cx+d}},\qquad |
| 1554 |
\norm*{\frac{ax+b}{cx+d}},\qquad |
| 1555 |
\eval*{\frac{ax+b}{cx+d}}_{x=0},\qquad |
| 1556 |
\eval[s]*{\frac{ax+b}{cx+d}}_{x=0}^{x=\infty} |
| 1557 |
\] |
| 1558 |
% \end{macrocode} |
| 1559 |
|
| 1560 |
outer delimiter spacing: |
| 1561 |
% \begin{macrocode} |
| 1562 |
\[\begin{array}{ll} |
| 1563 |
\square\brk^0{x}\square,&\square\brk^1{A^k}\square, |
| 1564 |
\\ |
| 1565 |
\square\brk*{x}\square,&\square\brk*{A^k}\square |
| 1566 |
\end{array}\] |
| 1567 |
% \end{macrocode} |
| 1568 |
|
| 1569 |
delimiter sizes in exponents: |
| 1570 |
% \begin{macrocode} |
| 1571 |
\[ |
| 1572 |
e^{\brk{ax+b}},\qquad |
| 1573 |
e^{\brk!{ax+b}} |
| 1574 |
\] |
| 1575 |
% \end{macrocode} |
| 1576 |
|
| 1577 |
delimiter declaration: |
| 1578 |
% \begin{macrocode} |
| 1579 |
\DeclareMathDelimiterSet{\braket}[2] |
| 1580 |
{\selectdeliml<#1\selectdelim|#2\selectdelimr>} |
| 1581 |
\[ |
| 1582 |
\braket!{\psi}{\psi}, |
| 1583 |
\quad |
| 1584 |
\braket*{\psi}{\psi\big.} |
| 1585 |
\] |
| 1586 |
% \end{macrocode} |
| 1587 |
|
| 1588 |
delimiter usage: |
| 1589 |
% \begin{macrocode} |
| 1590 |
\[ |
| 1591 |
\delimpair<|>!{\psi}{\psi} |
| 1592 |
\] |
| 1593 |
% \end{macrocode} |
| 1594 |
|
| 1595 |
conditional set, alternative layouts: |
| 1596 |
% \begin{macrocode} |
| 1597 |
\[ |
| 1598 |
\delimpair\{{[m]|}\}!{2n}{n\in\mathbb{Z}}, |
| 1599 |
\quad |
| 1600 |
\delimpair\{{[b]|}\}!{2n}{n\in\mathbb{Z}}, |
| 1601 |
\quad |
| 1602 |
\delimpair\{{[i]|}\}!{2n}{n\in\mathbb{Z}}, |
| 1603 |
\quad |
| 1604 |
\delimpair\{{[p]|}\}!{2n}{n\in\mathbb{Z}}, |
| 1605 |
\quad |
| 1606 |
\delimpair\{|\}!{2n}{n\in\mathbb{Z}}, |
| 1607 |
\quad |
| 1608 |
\delimpair\{{*;}\}!{2n}{n\in\mathbb{Z}} |
| 1609 |
\] |
| 1610 |
conditional set, alternative layouts with variable size: |
| 1611 |
\[ |
| 1612 |
\delimpair\{{[m]|}\}*{2n}{n\in\mathbb{Z}\big.}, |
| 1613 |
\quad |
| 1614 |
\delimpair\{{[b]|}\}*{2n}{n\in\mathbb{Z}\big.}, |
| 1615 |
\quad |
| 1616 |
\delimpair\{{[i]|}\}*{2n}{n\in\mathbb{Z}\big.}, |
| 1617 |
\quad |
| 1618 |
\delimpair\{{[p]|}\}*{2n}{n\in\mathbb{Z}\big.}, |
| 1619 |
\quad |
| 1620 |
\delimpair\{|\}*{2n}{n\in\mathbb{Z}\big.}, |
| 1621 |
\quad |
| 1622 |
\delimpair\{{*;}\}*{2n}{n\in\mathbb{Z}\big.} |
| 1623 |
\] |
| 1624 |
% \end{macrocode} |
| 1625 |
|
| 1626 |
delimiter definition: |
| 1627 |
% \begin{macrocode} |
| 1628 |
\newcommand{\comm}{\delimpair[{[p]*,}]} |
| 1629 |
\[ |
| 1630 |
\comm!{\comm{A}{B}}{C} |
| 1631 |
+\comm!{\comm{B}{C}}{A} |
| 1632 |
+\comm!{\comm{C}{A}}{B} |
| 1633 |
=0 |
| 1634 |
\] |
| 1635 |
% \end{macrocode} |
| 1636 |
|
| 1637 |
alternative representation: |
| 1638 |
% \begin{macrocode} |
| 1639 |
\renewcommand{\comm}{\delimpair[{[p]*;}]} |
| 1640 |
\[ |
| 1641 |
\comm!{\comm{A}{B}}{C} |
| 1642 |
+\comm!{\comm{B}{C}}{A} |
| 1643 |
+\comm!{\comm{C}{A}}{B} |
| 1644 |
=0 |
| 1645 |
\] |
| 1646 |
% \end{macrocode} |
| 1647 |
|
| 1648 |
display individual delimiters of a set with nesting: |
| 1649 |
% \begin{macrocode} |
| 1650 |
\renewcommand{\braket}{\delimpair<|>} |
| 1651 |
\[ |
| 1652 |
\braket{A}{B} |
| 1653 |
\to \braket( A \braket| B \braket), |
| 1654 |
\quad |
| 1655 |
\braket*( A\big. \braket*| B_{} \braket*), |
| 1656 |
\quad |
| 1657 |
\braket^1( A \braket^3| B \braket^2), |
| 1658 |
\quad |
| 1659 |
\braket^2[ \brk[s]^1[ A \brk] \usedelim| B \usedelim] |
| 1660 |
\] |
| 1661 |
% \end{macrocode} |
| 1662 |
|
| 1663 |
placing indices before a bracket |
| 1664 |
(does not work in variable-size mode because |
| 1665 |
the final size is not available for the enclosed expressions): |
| 1666 |
% \begin{macrocode} |
| 1667 |
\DeclareMathDelimiterSet{\quadindex}[5] |
| 1668 |
{\selectdeliml.^{#2}_{#3}\mathord{}\selectdelim[o][ |
| 1669 |
{#1}\selectdelim[o]]^{#4}_{#5}\selectdelimr.} |
| 1670 |
\[ |
| 1671 |
\quadindex^2{\frac{x}{y}}{1}{2}{3}{4} |
| 1672 |
\] |
| 1673 |
% \end{macrocode} |
| 1674 |
|
| 1675 |
% End of document body: |
| 1676 |
% \begin{macrocode} |
| 1677 |
\end{document} |
| 1678 |
% \end{macrocode} |
| 1679 |
% \iffalse |
| 1680 |
%</sample> |
| 1681 |
% \fi |
| 1682 |
% |
| 1683 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1684 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1685 |
% \section{Implementation} |
| 1686 |
% \iffalse |
| 1687 |
%<*package> |
| 1688 |
% \fi |
| 1689 |
% |
| 1690 |
% In this section we describe the package \verbpkg|.sty|. |
| 1691 |
|
| 1692 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1693 |
% \paragraph{Required Packages.} |
| 1694 |
% |
| 1695 |
% The package loads the package \ctanpkg{keyval} if not yet present. |
| 1696 |
% \ctanpkg{keyval} is used for extended options processing. |
| 1697 |
% |
| 1698 |
% \begin{macrocode} |
| 1699 |
\RequirePackage{keyval} |
| 1700 |
% \end{macrocode} |
| 1701 |
|
| 1702 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1703 |
% \paragraph{Package Options.} |
| 1704 |
% |
| 1705 |
% The package has some boolean \ctanpkg{keyval} options |
| 1706 |
% which can be set to |true| or |false|. |
| 1707 |
% |
| 1708 |
% \begin{macrocode} |
| 1709 |
\newif\ifdlm@std\dlm@stdtrue |
| 1710 |
\newif\ifdlm@ext\dlm@extfalse |
| 1711 |
\newif\ifdlm@script\dlm@scripttrue |
| 1712 |
|
| 1713 |
\def\dlm@group{dlm@} |
| 1714 |
\define@key{\dlm@group}{stddef}[true]{\csname dlm@std#1\endcsname} |
| 1715 |
\define@key{\dlm@group}{extdef}[true]{\csname dlm@ext#1\endcsname} |
| 1716 |
\define@key{\dlm@group}{scriptstyle}[true]{\csname dlm@script#1\endcsname} |
| 1717 |
|
| 1718 |
\DeclareOption*{\expandafter\setkeys\expandafter\dlm@group |
| 1719 |
\expandafter{\CurrentOption}} |
| 1720 |
\ProcessOptions |
| 1721 |
% \end{macrocode} |
| 1722 |
|
| 1723 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1724 |
% \paragraph{Interaction with \markpkg{beamerbasecolor}.} |
| 1725 |
% |
| 1726 |
% Suppress changing colors in inner math structures |
| 1727 |
% when \ctanpkg{beamer} is loaded: |
| 1728 |
% \begin{macrocode} |
| 1729 |
\let\dlm@beamerbasecolor@fix\@empty |
| 1730 |
\AddToHook{package/beamerbasecolor/after}{% |
| 1731 |
\def\dlm@beamerbasecolor@fix{\donotcoloroutermaths}} |
| 1732 |
% \end{macrocode} |
| 1733 |
|
| 1734 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1735 |
% \paragraph{Improved Size Adjustments.} |
| 1736 |
% |
| 1737 |
% Overwrite the macros |\big|, |\Big|, |\bigg|, |\Bigg| |
| 1738 |
% and the \ctanpkg{amsmath} command |\bBigg@| |
| 1739 |
% to select the size according to the present math style |
| 1740 |
% (uses the \ctanpkg{amsmath} definitions |\@mathmeasure| and |\big@size|). |
| 1741 |
% This code is activated only if |
| 1742 |
% the package option |scriptstyle| is set to |true|. |
| 1743 |
% |
| 1744 |
% \begin{macrocode} |
| 1745 |
\ifdlm@script |
| 1746 |
\def\dlm@big@s#1#2{{\delimsize#1\dlm@size\dlm@big@{#2}}} |
| 1747 |
\DeclareRobustCommand{\big}{\dlm@big@s{}} |
| 1748 |
\DeclareRobustCommand{\Big}{\dlm@big@s{1.5}} |
| 1749 |
\DeclareRobustCommand{\bigg}{\dlm@big@s{2}} |
| 1750 |
\DeclareRobustCommand{\Bigg}{\dlm@big@s{2.5}} |
| 1751 |
\ifdefined\bBigg@ |
| 1752 |
\def\bBigg@choice#1#2#3#4{% |
| 1753 |
{\dlm@beamerbasecolor@fix\@mathmeasure\z@{\nulldelimiterspace\z@}% |
| 1754 |
{#1\left#4\vcenter to#3\dimexpr#2\big@size\relax{}\right.}% |
| 1755 |
\box\z@}} |
| 1756 |
\def\bBigg@#1#2{\leavevmode@ifvmode{\mathchoice |
| 1757 |
{\bBigg@choice{\displaystyle}{1}{#1}{#2}}% |
| 1758 |
{\bBigg@choice{\textstyle}{1}{#1}{#2}}% |
| 1759 |
{\bBigg@choice{\scriptstyle}{0.7}{#1}{#2}}% |
| 1760 |
{\bBigg@choice{\scriptscriptstyle}{0.5}{#1}{#2}}}} |
| 1761 |
\fi |
| 1762 |
\fi |
| 1763 |
% \end{macrocode} |
| 1764 |
|
| 1765 |
% Define punctuation marks (|\bigp|, etc.), |
| 1766 |
% binary operators (|\bigb|, etc.) |
| 1767 |
% and inner class (|\bigi|, etc.). |
| 1768 |
% |
| 1769 |
% \begin{macrocode} |
| 1770 |
\DeclareRobustCommand{\bigp}{\mathpunct\big} |
| 1771 |
\DeclareRobustCommand{\Bigp}{\mathpunct\Big} |
| 1772 |
\DeclareRobustCommand{\biggp}{\mathpunct\bigg} |
| 1773 |
\DeclareRobustCommand{\Biggp}{\mathpunct\Bigg} |
| 1774 |
\DeclareRobustCommand{\bigb}{\mathbin\big} |
| 1775 |
\DeclareRobustCommand{\Bigb}{\mathbin\Big} |
| 1776 |
\DeclareRobustCommand{\biggb}{\mathbin\bigg} |
| 1777 |
\DeclareRobustCommand{\Biggb}{\mathbin\Bigg} |
| 1778 |
\DeclareRobustCommand{\bigi}{\mathinner\big} |
| 1779 |
\DeclareRobustCommand{\Bigi}{\mathinner\Big} |
| 1780 |
\DeclareRobustCommand{\biggi}{\mathinner\bigg} |
| 1781 |
\DeclareRobustCommand{\Biggi}{\mathinner\Bigg} |
| 1782 |
% \end{macrocode} |
| 1783 |
|
| 1784 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1785 |
% \paragraph{Size Adjustment Definitions.} |
| 1786 |
% |
| 1787 |
% Replicate the \ctanpkg{amsmath} implementation for |
| 1788 |
% tracking the vertical size of a default delimiter in the current font. |
| 1789 |
% Our |\dlm@size| matches with |\big@size| in \ctanpkg{amsmath} |
| 1790 |
% which is 1.2 times the vertical size of `(': |
| 1791 |
% \begin{macrocode} |
| 1792 |
\newlength\dlm@size |
| 1793 |
% \end{macrocode} |
| 1794 |
% The macros |\dlm@size@setchar| and |\dlm@size@scan| |
| 1795 |
% scan the font and code point |
| 1796 |
% in unicode (xetex/luatex) vs.\ \TeX\ (etex) engines: |
| 1797 |
% \begin{macrocode} |
| 1798 |
\ifdefined\Umathcharnumdef |
| 1799 |
\def\dlm@size@setchar{\Umathcharnumdef\dlm@size@char\Umathcodenum`\(\relax} |
| 1800 |
\def\dlm@size@scan#1"#2"#3"#4\relax{\dlm@size@get{#3}{#4}} |
| 1801 |
\else |
| 1802 |
\def\dlm@size@setchar{\mathchardef\dlm@size@char\mathcode`\(\relax} |
| 1803 |
\def\dlm@size@scan#1"#2#3#4\relax{\dlm@size@get{#3}{#4}} |
| 1804 |
\fi |
| 1805 |
% \end{macrocode} |
| 1806 |
% The macro |\dlm@size@get| computes 1.2 times the vertical height of `(': |
| 1807 |
% \begin{macrocode} |
| 1808 |
\def\dlm@size@get#1#2{% |
| 1809 |
\dlm@size\fontcharht\textfont"#1"#2\relax |
| 1810 |
\advance\dlm@size\fontchardp\textfont"#1"#2\relax |
| 1811 |
\global\[email protected]\dlm@size} |
| 1812 |
% \end{macrocode} |
| 1813 |
% The macro |\dlm@size@reset| updates |\dlm@size|: |
| 1814 |
% \begin{macrocode} |
| 1815 |
\newcommand{\dlm@size@reset}{% |
| 1816 |
\dlm@size@setchar\expandafter\dlm@size@scan\meaning\dlm@size@char\relax} |
| 1817 |
% \end{macrocode} |
| 1818 |
% We can hook onto the \ctanpkg{amsmath} mechanism if already present: |
| 1819 |
% \begin{macrocode} |
| 1820 |
\ifdefined\big@size |
| 1821 |
\def\dlm@size{\big@size} |
| 1822 |
\else |
| 1823 |
\addto@hook\every@math@size{\dlm@size@reset} |
| 1824 |
\fi |
| 1825 |
% \end{macrocode} |
| 1826 |
|
| 1827 |
% The macro |\dlm@setvar| enables variable size, |
| 1828 |
% the macro |\dlm@setsize| sets a fixed size. |
| 1829 |
% Delimiter sizes are implented by |\dlm@big@|. |
| 1830 |
% The macro |\kerndelim| adds some kerning proportional |
| 1831 |
% to the chosen fixed size of the delimiters |
| 1832 |
% (the spacing is merely an approximation, |
| 1833 |
% and it does not actually scale for flexible size). |
| 1834 |
% |
| 1835 |
% \begin{macrocode} |
| 1836 |
\newlength\delimsize |
| 1837 |
\newcommand{\dlm@setvar}{\let\dlm@ifvar\@firstoftwo\delimsize1.5\dlm@size} |
| 1838 |
\newcommand{\dlm@resetsize}{\let\dlm@ifvar\@secondoftwo\delimsize0.8\dlm@size} |
| 1839 |
\newcommand{\dlm@setsize}[1]{\let\dlm@ifvar\@secondoftwo |
| 1840 |
\delimsize\dimexpr(#1\dlm@size+\dlm@size)/2\relax} |
| 1841 |
\newcommand{\dlm@addsize}[1]{% |
| 1842 |
\ifx\dlm@ifvar\@firstoftwo\delimsize0.8\dlm@size\fi |
| 1843 |
\ifdim\delimsize=0.8\dlm@size\delimsize0.5\dlm@size\fi |
| 1844 |
\advance\delimsize\dimexpr(#1\dlm@size)/2\relax} |
| 1845 |
\newcommand{\dlm@setabssize}[1]{\let\dlm@ifvar\@secondoftwo |
| 1846 |
\delimsize\glueexpr#1\relax} |
| 1847 |
\newcommand{\dlm@big@}[1]{{\mathchoice |
| 1848 |
{\dlm@big@choice\displaystyle{1}{#1}}% |
| 1849 |
{\dlm@big@choice\textstyle{1}{#1}}% |
| 1850 |
{\dlm@big@choice\scriptstyle{0.7}{#1}}% |
| 1851 |
{\dlm@big@choice\scriptscriptstyle{0.5}{#1}}}} |
| 1852 |
\newcommand{\dlm@big@choice}[3]{\hbox{\dlm@beamerbasecolor@fix% |
| 1853 |
$\m@th\nulldelimiterspace\z@ |
| 1854 |
#1\left#3\vcenter to#2\delimsize{}\right.$}} |
| 1855 |
\newcommand{\kerndelim}[1]{\mkern#1\muexpr\ifdim\delimsize>2.5\dlm@size3mu% |
| 1856 |
\else1.2mu*\delimsize/\dlm@size\fi\relax} |
| 1857 |
% \end{macrocode} |
| 1858 |
|
| 1859 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1860 |
% \paragraph{Math Classes Processing.} |
| 1861 |
% |
| 1862 |
% Define class selectors for fixed and unadjusted sizes. |
| 1863 |
% |
| 1864 |
% \begin{macrocode} |
| 1865 |
\newcommand{\dlm@big}[2]{\dlm@plain{#1}{\dlm@big@#2}} |
| 1866 |
\newcommand{\dlm@plain}[2]{\dlm@class{#1}{\dlm@phantom{#2}}} |
| 1867 |
\newcommand{\dlm@class}[1]{\csname dlm@class@#1\endcsname} |
| 1868 |
\let\dlm@class@\@firstofone |
| 1869 |
\let\dlm@class@o\mathord |
| 1870 |
\let\dlm@class@c\mathord |
| 1871 |
\let\dlm@class@p\mathpunct |
| 1872 |
\let\dlm@class@i\mathinner |
| 1873 |
\let\dlm@class@b\mathbin |
| 1874 |
\let\dlm@class@m\mathrel |
| 1875 |
% \end{macrocode} |
| 1876 |
|
| 1877 |
% Define class selector for variable size. |
| 1878 |
% The macro |\dlm@var@null| removes the extra space from |
| 1879 |
% variable-size null delimiters |
| 1880 |
% (|\left.|, |\middle.| and |\right.| apply the value |
| 1881 |
% of |\nulldelimiterspace| only at the end of math processing, |
| 1882 |
% even across blocks). |
| 1883 |
% The macro |\dlm@var@kern| applies kerning unless in the script styles. |
| 1884 |
% |
| 1885 |
% \begin{macrocode} |
| 1886 |
\newcommand{\dlm@var@null}[1]{\if.#1\kern-\nulldelimiterspace\fi} |
| 1887 |
\newcommand{\dlm@var@kern}[1]{\nonscript\mkern#1} |
| 1888 |
\newcommand{\dlm@var}[1]{\csname dlm@var@#1\endcsname} |
| 1889 |
\newcommand{\dlm@var@}[1]{\dlm@var@null#1\middle#1} |
| 1890 |
\let\dlm@var@o\dlm@var@ |
| 1891 |
\let\dlm@var@c\dlm@var@ |
| 1892 |
\newcommand{\dlm@var@p}[1]{\dlm@var@#1\dlm@var@kern\thinmuskip} |
| 1893 |
\newcommand{\dlm@var@i}[1]{\dlm@var@kern\thinmuskip |
| 1894 |
\dlm@var@#1\dlm@var@kern\thinmuskip} |
| 1895 |
\newcommand{\dlm@var@b}[1]{\dlm@var@kern\medmuskip |
| 1896 |
\dlm@var@#1\dlm@var@kern\medmuskip} |
| 1897 |
\newcommand{\dlm@var@m}[1]{\dlm@var@kern\thickmuskip |
| 1898 |
\dlm@var@#1\dlm@var@kern\thickmuskip} |
| 1899 |
% \end{macrocode} |
| 1900 |
|
| 1901 |
% Definitions for selecting outer math class |
| 1902 |
% |\mathopen|+|\mathclose| vs. |\mathinner|. |
| 1903 |
% |
| 1904 |
% \begin{macrocode} |
| 1905 |
\newcommand{\dlm@open@i}{\mathinner{}\mathclose{}\mathopen} |
| 1906 |
\newcommand{\dlm@close@i}{\mathclose{}\mathopen{}\mathinner} |
| 1907 |
\newcommand{\dlm@inner@oc}{\mathopen{}\mathclose} |
| 1908 |
\newcommand{\dlm@enclose@openclose}{% |
| 1909 |
\let\dlm@open\mathopen\let\dlm@close\mathclose\let\dlm@inner\dlm@inner@oc} |
| 1910 |
\newcommand{\dlm@enclose@inner}{% |
| 1911 |
\let\dlm@open\dlm@open@i\let\dlm@close\dlm@close@i\let\dlm@inner\mathinner} |
| 1912 |
% \end{macrocode} |
| 1913 |
|
| 1914 |
% Definitions for selecting inline vs. block insertion. |
| 1915 |
% |
| 1916 |
% \begin{macrocode} |
| 1917 |
\newcommand{\dlm@inline@l}[1]{\dlm@open{#1}} |
| 1918 |
\newcommand{\dlm@inline@r}[1]{\dlm@close{#1}} |
| 1919 |
\newcommand{\dlm@block@l}[1]{\dlm@inner\bgroup\mathopen{#1}} |
| 1920 |
\newcommand{\dlm@block@r}[1]{\mathclose{#1}\egroup} |
| 1921 |
\newcommand{\dlm@enclose@inline}{% |
| 1922 |
\let\dlm@class@l\dlm@inline@l\let\dlm@class@r\dlm@inline@r} |
| 1923 |
\newcommand{\dlm@enclose@block}{% |
| 1924 |
\let\dlm@class@l\dlm@block@l\let\dlm@class@r\dlm@block@r} |
| 1925 |
% \end{macrocode} |
| 1926 |
|
| 1927 |
% Opening and closing definitions. |
| 1928 |
% |
| 1929 |
% \begin{macrocode} |
| 1930 |
\newcommand{\dlm@plain@l}[1]{\dlm@class@l{\dlm@phantom{#1}}} |
| 1931 |
\newcommand{\dlm@plain@r}[1]{\dlm@class@r{\dlm@phantom{#1}}} |
| 1932 |
\newcommand{\dlm@big@l}[1]{\dlm@plain@l{\dlm@big@#1}} |
| 1933 |
\newcommand{\dlm@big@r}[1]{\dlm@plain@r{\dlm@big@#1}} |
| 1934 |
\newcommand{\dlm@var@l}[1]{\dlm@inner\bgroup\dlm@var@null#1\left#1} |
| 1935 |
\newcommand{\dlm@var@r}[1]{\right#1\dlm@var@null#1\egroup} |
| 1936 |
\newcommand{\dlm@var@pl}[1]{\dlm@var@l.#1\mathclose{}\mathopen{}} |
| 1937 |
\newcommand{\dlm@var@pr}[1]{\mathclose{}\mathopen{}#1\dlm@var@r.} |
| 1938 |
% \end{macrocode} |
| 1939 |
|
| 1940 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1941 |
% \paragraph{Delimiter Storage.} |
| 1942 |
% |
| 1943 |
% Macros for storing and retrieving delimiter types using global registers. |
| 1944 |
% |
| 1945 |
% \begin{macrocode} |
| 1946 |
\newcount\dlm@reg@lvl |
| 1947 |
\dlm@reg@lvl\z@ |
| 1948 |
\def\dlm@reg@dot{.} |
| 1949 |
\newcommand{\dlm@reg@set}[1]{\edef\dlm@reg@cur{#1}\ifx\dlm@reg@cur\dlm@reg@dot |
| 1950 |
\edef\dlm@reg@cur{\dlm@reg@dot\the\dlm@reg@lvl}\fi} |
| 1951 |
\newcommand{\dlm@reg@step}[1]{\global\advance\dlm@reg@lvl#1% |
| 1952 |
\ifnum\dlm@reg@lvl<\z@\PackageError{delimset}{register stack exhausted}{}% |
| 1953 |
\dlm@reg@lvl\z@\fi} |
| 1954 |
\newcommand{\dlm@reg@save@init}[1]{% |
| 1955 |
\xdef#1{\delimsize\the\delimsize}\ifx\dlm@inner\mathinner |
| 1956 |
\expandafter\gdef\expandafter#1\expandafter{#1\dlm@enclose@inner}\fi} |
| 1957 |
\newcommand{\dlm@reg@save}[2]{\dlm@reg@set{#1}% |
| 1958 |
\expandafter\dlm@reg@save@init\csname dlm@reg@init@\dlm@reg@cur\endcsname |
| 1959 |
\expandafter\gdef\csname dlm@reg@sel@\dlm@reg@cur\endcsname{#2}} |
| 1960 |
\newcommand{\dlm@reg@init}[1]{\dlm@reg@set{#1}% |
| 1961 |
\csname dlm@reg@init@\dlm@reg@cur\endcsname} |
| 1962 |
\newcommand{\dlm@reg@sel}{\csname dlm@reg@sel@\dlm@reg@cur\endcsname} |
| 1963 |
% \end{macrocode} |
| 1964 |
|
| 1965 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1966 |
% \paragraph{Flags Processing.} |
| 1967 |
% |
| 1968 |
% The macro |\parsedelimflags| parses the optional argument(s) |
| 1969 |
% following |\delim|\ldots\ commands to adjust the presentation. |
| 1970 |
% Parsing is terminated if the next character in line begins a group (`|{|') |
| 1971 |
% and the delimiter set is composed by executing argument |#1|. |
| 1972 |
% A size flag is stored and parsing continues. |
| 1973 |
% A delimiter selector flag immediately displays the desired delimiter |
| 1974 |
% by executing argument |#2|. |
| 1975 |
% Unknown flags produce an error message. |
| 1976 |
% |
| 1977 |
% \begin{macrocode} |
| 1978 |
\newcommand{\parsedelimflags}{\dlm@resetsize\let\dlm@phantom\@firstofone |
| 1979 |
\dlm@enclose@openclose\dlm@enclose@inline\dlm@parseflags} |
| 1980 |
\newcommand{\dlm@parseflags}[2]{% |
| 1981 |
\@ifnextchar\bgroup{#1}{\dlm@parseflag{#1}{#2}}} |
| 1982 |
\newcommand{\dlm@parseflag}[3]{\begingroup |
| 1983 |
\ifcsname dlm@parseflag@\string#3\endcsname |
| 1984 |
\def\dlm@do{\csname dlm@parseflag@\string#3\endcsname{#1}{#2}}\else |
| 1985 |
\def\dlm@do{\PackageError{delimset}% |
| 1986 |
{unknown delimiter set flag `\string#3'}{}#1}% |
| 1987 |
\fi\expandafter\endgroup\dlm@do} |
| 1988 |
\newcommand{\dlm@parsedef}[3]{% |
| 1989 |
\expandafter\def\csname dlm@parseflag@\string#1\endcsname ##1##2#2{#3}} |
| 1990 |
% \end{macrocode} |
| 1991 |
% |
| 1992 |
% Note that the delimited expression should be contained within a group |
| 1993 |
% such that nested delimiters will not overwrite the outer size definition. |
| 1994 |
|
| 1995 |
% Flags to adjust size. |
| 1996 |
% Note that sizes 0 and 1 amount to 0.96 and 1.2 times |
| 1997 |
% the current empty math box height. |
| 1998 |
% |
| 1999 |
% \begin{macrocode} |
| 2000 |
\dlm@parsedef{!}{}{\dlm@addsize{1}\dlm@parseflags{#1}{#2}} |
| 2001 |
\dlm@parsedef{+}{}{\dlm@addsize{1}\dlm@parseflags{#1}{#2}} |
| 2002 |
\dlm@parsedef{0}{}{\dlm@resetsize\dlm@parseflags{#1}{#2}} |
| 2003 |
\dlm@parsedef{1}{}{\dlm@setsize{1}\dlm@parseflags{#1}{#2}} |
| 2004 |
\dlm@parsedef{2}{}{\dlm@setsize{2}\dlm@parseflags{#1}{#2}} |
| 2005 |
\dlm@parsedef{3}{}{\dlm@setsize{3}\dlm@parseflags{#1}{#2}} |
| 2006 |
\dlm@parsedef{4}{}{\dlm@setsize{4}\dlm@parseflags{#1}{#2}} |
| 2007 |
\dlm@parsedef{^}{#3}{\dlm@setsize{#3}\dlm@parseflags{#1}{#2}} |
| 2008 |
\dlm@parsedef{_}{#3}{\dlm@setabssize{#3}\dlm@parseflags{#1}{#2}} |
| 2009 |
\dlm@parsedef{*}{}{\dlm@setvar\dlm@parseflags{#1}{#2}} |
| 2010 |
% \end{macrocode} |
| 2011 |
|
| 2012 |
% Flags to select individual delimiters. |
| 2013 |
% |
| 2014 |
% \begin{macrocode} |
| 2015 |
\dlm@parsedef{(}{}{\def\selecteddelim{0}#2} |
| 2016 |
\dlm@parsedef{|}{}{\def\selecteddelim{1}#2} |
| 2017 |
\dlm@parsedef{,}{}{\def\selecteddelim{1}#2} |
| 2018 |
\dlm@parsedef{)}{}{\def\selecteddelim{9}#2} |
| 2019 |
\dlm@parsedef{?}{#3}{\def\selecteddelim{#3}#2} |
| 2020 |
% \end{macrocode} |
| 2021 |
|
| 2022 |
% Flags to access registers. |
| 2023 |
% |
| 2024 |
% \begin{macrocode} |
| 2025 |
\dlm@parsedef{[}{}{\dlm@ifvar{% |
| 2026 |
\PackageError{delimset}{cannot use variable size with '['}{}}{% |
| 2027 |
\dlm@reg@step\@ne\dlm@reg@save\dlm@reg@dot{#2}\def\selecteddelim{0}#2}} |
| 2028 |
\dlm@parsedef{]}{}{\dlm@reg@init\dlm@reg@dot\dlm@reg@step\m@ne |
| 2029 |
\def\selecteddelim{9}\dlm@reg@sel} |
| 2030 |
\dlm@parsedef{>}{#3}{\dlm@reg@save{#3}{#2}} |
| 2031 |
\dlm@parsedef{<}{#3}{\dlm@reg@init{#3}\dlm@parseflags |
| 2032 |
{\PackageError{delimset}{must select delimiter}{}}{\dlm@reg@sel}} |
| 2033 |
% \end{macrocode} |
| 2034 |
|
| 2035 |
% Further flags. |
| 2036 |
% |
| 2037 |
% \begin{macrocode} |
| 2038 |
\dlm@parsedef{.}{}{#1} |
| 2039 |
\dlm@parsedef{:}{}{\dlm@enclose@block\dlm@parseflags{#1}{#2}} |
| 2040 |
\dlm@parsedef{'}{}{\dlm@enclose@openclose\dlm@parseflags{#1}{#2}} |
| 2041 |
\dlm@parsedef{"}{}{\dlm@enclose@inner\dlm@parseflags{#1}{#2}} |
| 2042 |
\dlm@parsedef{-}{}{\let\dlm@phantom\phantom\dlm@parseflags{#1}{#2}} |
| 2043 |
% \end{macrocode} |
| 2044 |
|
| 2045 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2046 |
% \paragraph{Choice Processing.} |
| 2047 |
% |
| 2048 |
% Delimiter definitions may accommodate different representations |
| 2049 |
% via optional argument. The following commands define the options |
| 2050 |
% and select the chosen one. |
| 2051 |
% |
| 2052 |
% \begin{macrocode} |
| 2053 |
\newcommand{\dlm@choicedef}[3]{% |
| 2054 |
\expandafter\def\csname dlm@#1@\string#2@\endcsname{#3}} |
| 2055 |
\newcommand{\dlm@choicelet}[3]{% |
| 2056 |
\expandafter\let\csname dlm@#1@\string#2@\expandafter\endcsname |
| 2057 |
\csname dlm@#1@\string#3@\endcsname} |
| 2058 |
\newcommand{\dlm@choice}[1]{% |
| 2059 |
\@ifnextchar[{\dlm@choice@opt{#1}}{\csname dlm@#1@@@\endcsname}} |
| 2060 |
\def\dlm@choice@opt#1[#2]{\csname dlm@#1@% |
| 2061 |
\ifcsname dlm@#1@\string#2@\endcsname\string#2@\else @@\fi\endcsname} |
| 2062 |
\newcommand{\dlm@choice@arg}[2]{\begingroup |
| 2063 |
\expandafter\let\expandafter\dlm@do\csname dlm@#1@\string#2@\endcsname |
| 2064 |
\ifx\dlm@do\relax\def\dlm@do{\csname dlm@#1@@@\endcsname{#2}}\fi |
| 2065 |
\expandafter\endgroup\dlm@do} |
| 2066 |
% \end{macrocode} |
| 2067 |
|
| 2068 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2069 |
% \paragraph{Delimiter Display.} |
| 2070 |
% |
| 2071 |
% The command |\selectdelim| reproduces the delimiter in argument |#2| |
| 2072 |
% using the math class given in argument |#1| and the previously stored size. |
| 2073 |
% If the class identifier is `|.|', just return the delimiter argument as is. |
| 2074 |
% The commands |\selectdeliml| and |\selectdelimr| |
| 2075 |
% implement the left and right delimiter classes, respectively. |
| 2076 |
% The command |\doubledelim| displays a compound |
| 2077 |
% of two identical delimiters with optional kerning adjustment. |
| 2078 |
% |
| 2079 |
% \begin{macrocode} |
| 2080 |
\newcommand{\selectdelim}[1][]{\begingroup\def\dlm@do{\@ifstar{\dlm@plain{#1}}% |
| 2081 |
{\dlm@ifvar{\dlm@var{#1}}{\dlm@big{#1}}}}% |
| 2082 |
\if.#1\let\dlm@do\@empty\fi\expandafter\endgroup\dlm@do} |
| 2083 |
\newcommand{\selectdeliml}{\@ifstar |
| 2084 |
{\dlm@ifvar\dlm@var@pl\dlm@plain@l}{\dlm@ifvar\dlm@var@l\dlm@big@l}} |
| 2085 |
\newcommand{\selectdelimr}{\@ifstar |
| 2086 |
{\dlm@ifvar\dlm@var@pr\dlm@plain@r}{\dlm@ifvar\dlm@var@r\dlm@big@r}} |
| 2087 |
\newcommand{\doubledelim}[2][-2]{% |
| 2088 |
\selectdelim{#2}\kerndelim{#1}\selectdelim{#2}} |
| 2089 |
% \end{macrocode} |
| 2090 |
|
| 2091 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2092 |
% \paragraph{Declaration of New Delimiter Commands.} |
| 2093 |
% |
| 2094 |
% The macro |\DeclareMathDelimiterSet| declares a new set of delimiters |
| 2095 |
% as the macro `|\|\emph{name}'. |
| 2096 |
% This macro checks for optional flags and stores the desired size. |
| 2097 |
% It then passes on to a second macro `|\dlm@dcl@|\emph{name}', |
| 2098 |
% which takes the actual code. |
| 2099 |
% If the flags select an individual delimiter, |
| 2100 |
% the macro `|\dlm@sel@|\emph{name}' is called instead. |
| 2101 |
% The latter macro should be defined via |\DeclareMathDelimiterSel| |
| 2102 |
% such that it produces the desired delimiter number |\selecteddelim|. |
| 2103 |
% |
| 2104 |
% \begin{macrocode} |
| 2105 |
\newcommand{\DeclareMathDelimiterSet}[1]{\expandafter\dlm@declare |
| 2106 |
\csname dlm@dcl@\expandafter\@gobble\string#1\endcsname{#1}} |
| 2107 |
\def\dlm@declare#1#2{\expandafter\dlm@declare@ |
| 2108 |
\csname dlm@sel@\expandafter\@gobble\string#2\endcsname{#1}{#2}} |
| 2109 |
\def\dlm@declare@#1#2#3{\newcommand{#3}{\parsedelimflags{#2}{#1}}% |
| 2110 |
\providecommand{#1}{}\newcommand{#2}} |
| 2111 |
\newcommand{\DeclareMathDelimiterSel}[3]{\expandafter\def |
| 2112 |
\csname dlm@sel@\expandafter\@gobble\string#1\endcsname |
| 2113 |
{\ifcase\selecteddelim#2\else#3\fi}} |
| 2114 |
% \end{macrocode} |
| 2115 |
|
| 2116 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2117 |
% \paragraph{Inline Delimiter Declarations.} |
| 2118 |
% |
| 2119 |
% Inline declaration for delimiters via |\delim...|. |
| 2120 |
% The following code is similar to the one produced by |
| 2121 |
% |\DeclareMathDelimiterSet|, but the delimiter arguments |
| 2122 |
% are processed \emph{before} the optional size modifier. |
| 2123 |
% |
| 2124 |
% |\delim| is used for a single delimited expression. |
| 2125 |
% |
| 2126 |
% \begin{macrocode} |
| 2127 |
\newcommand{\delim}[2]{% |
| 2128 |
\parsedelimflags{\dlm@dcl@delim{#1}{#2}}{\dlm@sel@delim{#1}{#2}}} |
| 2129 |
\newcommand{\dlm@dcl@delim}[3]{% |
| 2130 |
\selectdeliml#1{#3}\selectdelimr#2} |
| 2131 |
\newcommand{\dlm@sel@delim}[2]{\ifcase\selecteddelim\selectdeliml#1% |
| 2132 |
\else\selectdelimr#2\fi} |
| 2133 |
% \end{macrocode} |
| 2134 |
|
| 2135 |
% |\delimpair| is used for two delimited expressions separated |
| 2136 |
% by an intermediate delimiter. |
| 2137 |
% |
| 2138 |
% \begin{macrocode} |
| 2139 |
\newcommand{\delimpair}[3]{% |
| 2140 |
\parsedelimflags{\dlm@dcl@delimpair{#1}{#2}{#3}}% |
| 2141 |
{\dlm@sel@delimpair{#1}{#2}{#3}}} |
| 2142 |
\newcommand{\dlm@dcl@delimpair}[5]{% |
| 2143 |
\selectdeliml#1{#4}\selectdelim#2{#5}\selectdelimr#3} |
| 2144 |
\newcommand{\dlm@sel@delimpair}[3]{\ifcase\selecteddelim\selectdeliml#1% |
| 2145 |
\or\selectdelim#2\else\selectdelimr#3\fi} |
| 2146 |
% \end{macrocode} |
| 2147 |
|
| 2148 |
% |\delimtriple| is used for three delimited expressions separated |
| 2149 |
% by two intermediate delimiters. |
| 2150 |
% |
| 2151 |
% \begin{macrocode} |
| 2152 |
\newcommand{\delimtriple}[4]{% |
| 2153 |
\parsedelimflags{\dlm@dcl@delimtriple{#1}{#2}{#3}{#4}}% |
| 2154 |
{\dlm@sel@delimtriple{#1}{#2}{#3}{#4}}} |
| 2155 |
\newcommand{\dlm@dcl@delimtriple}[7]{% |
| 2156 |
\selectdeliml#1{#5}\selectdelim#2{#6}\selectdelim#3{#7}\selectdelimr#4} |
| 2157 |
\newcommand{\dlm@sel@delimtriple}[4]{\ifcase\selecteddelim\selectdeliml#1% |
| 2158 |
\or\selectdelim#2\or\selectdelim#3\else\selectdelimr#4\fi} |
| 2159 |
% \end{macrocode} |
| 2160 |
|
| 2161 |
% |\usedelim| retrieves a stored delimiter type. |
| 2162 |
% The arguments `|]|', `|(|', `\verbbar', `|,|', `|?|\emph{n}', `|)|' |
| 2163 |
% immediately select the delimiter using the stack register. |
| 2164 |
% Otherwise the desired register must be followed |
| 2165 |
% by the delimiter selection flag. |
| 2166 |
% |
| 2167 |
% \begin{macrocode} |
| 2168 |
\dlm@choicedef{usedelim}{]}{\parsedelimflags{}{}]} |
| 2169 |
\dlm@choicedef{usedelim}{(}{\parsedelimflags{}{}<.(} |
| 2170 |
\dlm@choicedef{usedelim}{|}{\parsedelimflags{}{}<.|} |
| 2171 |
\dlm@choicedef{usedelim}{,}{\parsedelimflags{}{}<.,} |
| 2172 |
\dlm@choicedef{usedelim}{)}{\parsedelimflags{}{}<.)} |
| 2173 |
\dlm@choicedef{usedelim}{?}{\parsedelimflags{}{}<.?} |
| 2174 |
\dlm@choicedef{usedelim}{@}{\parsedelimflags{}{}<} |
| 2175 |
\newcommand{\usedelim}{\dlm@choice@arg{usedelim}} |
| 2176 |
% \end{macrocode} |
| 2177 |
|
| 2178 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2179 |
% \paragraph{Vertical Bar Definitions.} |
| 2180 |
% |
| 2181 |
% Define basic macros for left/right vertical bars |
| 2182 |
% and overwrite them later if defined otherwise. |
| 2183 |
% |
| 2184 |
% \begin{macrocode} |
| 2185 |
\def\dlm@lvert{\vert}\let\dlm@rvert\dlm@lvert |
| 2186 |
\def\dlm@lVert{\Vert}\let\dlm@rVert\dlm@lVert |
| 2187 |
\AddToHook{begindocument/end}{% |
| 2188 |
\ifdefined\lvert\def\dlm@lvert{\lvert}\fi |
| 2189 |
\ifdefined\rvert\def\dlm@rvert{\rvert}\fi |
| 2190 |
\ifdefined\lVert\def\dlm@lVert{\lVert}\fi |
| 2191 |
\ifdefined\rVert\def\dlm@rVert{\rVert}\fi |
| 2192 |
} |
| 2193 |
% \end{macrocode} |
| 2194 |
|
| 2195 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2196 |
% \paragraph{Standard Definitions.} |
| 2197 |
% |
| 2198 |
% Define some common delimiters (by |providecommand| so as not to |
| 2199 |
% overwrite previously existing commands). |
| 2200 |
% This code is activated only if the package option |stddef| is set to |true|. |
| 2201 |
% |
| 2202 |
% \begin{macrocode} |
| 2203 |
\ifdlm@std |
| 2204 |
\dlm@choicedef{brk}{r}{\delim()} |
| 2205 |
\dlm@choicedef{brk}{s}{\delim[]} |
| 2206 |
\dlm@choicedef{brk}{c}{\delim\{\}} |
| 2207 |
\dlm@choicedef{brk}{a}{\delim<>} |
| 2208 |
\dlm@choicedef{brk}{v}{\delim\dlm@lvert\dlm@rvert} |
| 2209 |
\dlm@choicedef{brk}{R}{\delim{*{\doubledelim(}}{*{\doubledelim)}}} |
| 2210 |
\dlm@choicedef{brk}{S}{% |
| 2211 |
\delim{*{\doubledelim[-1.75][}}{*{\doubledelim[-1.75]]}}} |
| 2212 |
\ifdefined\llbracket\dlm@choicedef{brk}{S}{\delim\llbracket\rrbracket}\fi |
| 2213 |
\dlm@choicedef{brk}{C}{% |
| 2214 |
\delim{*{\doubledelim[-2.5]\{}}{*{\doubledelim[-2.5]\}}}} |
| 2215 |
\dlm@choicedef{brk}{A}{\delim{*{\doubledelim<}}{*{\doubledelim>}}} |
| 2216 |
\dlm@choicedef{brk}{V}{\delim\dlm@lVert\dlm@rVert} |
| 2217 |
\dlm@choicelet{brk}{@}{r} |
| 2218 |
\providecommand{\brk}{\dlm@choice{brk}} |
| 2219 |
\dlm@choicedef{eval}{v}{\delim.\dlm@rvert} |
| 2220 |
\dlm@choicedef{eval}{s}{\delim[]} |
| 2221 |
\dlm@choicelet{eval}{@}{v} |
| 2222 |
\providecommand{\eval}{\dlm@choice{eval}} |
| 2223 |
\providecommand{\abs}{\delim\dlm@lvert\dlm@rvert} |
| 2224 |
\providecommand{\norm}{\delim\dlm@lVert\dlm@rVert} |
| 2225 |
\fi |
| 2226 |
% \end{macrocode} |
| 2227 |
|
| 2228 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2229 |
% \paragraph{Extended Definitions.} |
| 2230 |
% |
| 2231 |
% Define some extended delimiters. |
| 2232 |
% This code is activated only if the package option |extdef| is set to |true|. |
| 2233 |
% |
| 2234 |
% \begin{macrocode} |
| 2235 |
\ifdlm@ext |
| 2236 |
\dlm@choicedef{pair}{r,}{\delimpair({[p]*,})} |
| 2237 |
\dlm@choicedef{pair}{r;}{\delimpair({[p]*;})} |
| 2238 |
\dlm@choicedef{pair}{r|}{\delimpair(|)} |
| 2239 |
\dlm@choicedef{pair}{s,}{\delimpair[{[p]*,}]} |
| 2240 |
\dlm@choicedef{pair}{s;}{\delimpair[{[p]*;}]} |
| 2241 |
\dlm@choicedef{pair}{s|}{\delimpair[|]} |
| 2242 |
\dlm@choicedef{pair}{c,}{\delimpair\{{[p]*,}\}} |
| 2243 |
\dlm@choicedef{pair}{c;}{\delimpair\{{[p]*;}\}} |
| 2244 |
\dlm@choicedef{pair}{c|}{\delimpair\{|\}} |
| 2245 |
\dlm@choicedef{pair}{a,}{\delimpair<{[p]*,}>} |
| 2246 |
\dlm@choicedef{pair}{a;}{\delimpair<{[p]*;}>} |
| 2247 |
\dlm@choicedef{pair}{a|}{\delimpair<|>} |
| 2248 |
\dlm@choicedef{pair}{v,}{\delimpair\dlm@lvert{[p]*,}\dlm@rvert} |
| 2249 |
\dlm@choicedef{pair}{v;}{\delimpair\dlm@lvert{[p]*;}\dlm@rvert} |
| 2250 |
\dlm@choicedef{pair}{v|}{\delimpair\dlm@lvert|\dlm@rvert} |
| 2251 |
\dlm@choicedef{pair}{R,}{\delimpair{*{\doubledelim(}}{[p]*,}{*{\doubledelim)}}} |
| 2252 |
\dlm@choicedef{pair}{R;}{\delimpair{*{\doubledelim(}}{[p]*;}{*{\doubledelim)}}} |
| 2253 |
\dlm@choicedef{pair}{R|}{\delimpair{*{\doubledelim(}}\Vert{*{\doubledelim)}}} |
| 2254 |
\dlm@choicedef{pair}{S,}{% |
| 2255 |
\delimpair{*{\doubledelim[-1.75][}}{[p]*,}{*{\doubledelim[-1.75]]}}} |
| 2256 |
\dlm@choicedef{pair}{S;}{% |
| 2257 |
\delimpair{*{\doubledelim[-1.75][}}{[p]*;}{*{\doubledelim[-1.75]]}}} |
| 2258 |
\dlm@choicedef{pair}{S|}{% |
| 2259 |
\delimpair{*{\doubledelim[-1.75][}}\Vert{*{\doubledelim[-1.75]]}}} |
| 2260 |
\ifdefined\llbracket |
| 2261 |
\dlm@choicedef{pair}{S,}{\delimpair\llbracket{[p]*,}\rrbracket} |
| 2262 |
\dlm@choicedef{pair}{S;}{\delimpair\llbracket{[p]*;}\rrbracket} |
| 2263 |
\dlm@choicedef{pair}{S|}{\delimpair\llbracket\Vert\rrbracket} |
| 2264 |
\fi |
| 2265 |
\dlm@choicedef{pair}{C,}{% |
| 2266 |
\delimpair{*{\doubledelim[-2.5]\{}}{[p]*,}{*{\doubledelim[-2.5]\}}}} |
| 2267 |
\dlm@choicedef{pair}{C;}{% |
| 2268 |
\delimpair{*{\doubledelim[-2.5]\{}}{[p]*;}{*{\doubledelim[-2.5]\}}}} |
| 2269 |
\dlm@choicedef{pair}{C|}{% |
| 2270 |
\delimpair{*{\doubledelim[-2.5]\{}}\Vert{*{\doubledelim[-2.5]\}}}} |
| 2271 |
\dlm@choicedef{pair}{A,}{\delimpair{*{\doubledelim<}}{[p]*,}{*{\doubledelim>}}} |
| 2272 |
\dlm@choicedef{pair}{A;}{\delimpair{*{\doubledelim<}}{[p]*;}{*{\doubledelim>}}} |
| 2273 |
\dlm@choicedef{pair}{A|}{\delimpair{*{\doubledelim<}}\Vert{*{\doubledelim>}}} |
| 2274 |
\dlm@choicedef{pair}{V,}{\delimpair\dlm@lVert{[p]*,}\dlm@rVert} |
| 2275 |
\dlm@choicedef{pair}{V;}{\delimpair\dlm@lVert{[p]*;}\dlm@rVert} |
| 2276 |
\dlm@choicedef{pair}{V|}{\delimpair\dlm@lVert\Vert\dlm@rVert} |
| 2277 |
\dlm@choicelet{pair}{r}{r,} |
| 2278 |
\dlm@choicelet{pair}{s}{s,} |
| 2279 |
\dlm@choicelet{pair}{c}{c,} |
| 2280 |
\dlm@choicelet{pair}{a}{a,} |
| 2281 |
\dlm@choicelet{pair}{v}{v,} |
| 2282 |
\dlm@choicelet{pair}{R}{R,} |
| 2283 |
\dlm@choicelet{pair}{S}{S,} |
| 2284 |
\dlm@choicelet{pair}{C}{C,} |
| 2285 |
\dlm@choicelet{pair}{A}{A,} |
| 2286 |
\dlm@choicelet{pair}{V}{V,} |
| 2287 |
\dlm@choicelet{pair}{,}{r,} |
| 2288 |
\dlm@choicelet{pair}{;}{r;} |
| 2289 |
\dlm@choicelet{pair}{|}{r|} |
| 2290 |
\dlm@choicelet{pair}{@}{r} |
| 2291 |
\providecommand{\pair}{\dlm@choice{pair}} |
| 2292 |
\providecommand{\set}{\delim\{\}} |
| 2293 |
\providecommand{\setcond}{\delimpair\{|\}} |
| 2294 |
\dlm@choicedef{intv}{c}{\delimpair[{[p]*,}]} |
| 2295 |
\dlm@choicedef{intv}{l}{\delimpair]{[p]*,}]} |
| 2296 |
\dlm@choicedef{intv}{r}{\delimpair[{[p]*,}[} |
| 2297 |
\dlm@choicedef{intv}{o}{\delimpair]{[p]*,}[} |
| 2298 |
\dlm@choicelet{intv}{@}{c} |
| 2299 |
\providecommand{\intv}{\dlm@choice{intv}} |
| 2300 |
\providecommand{\avg}{\delim<>} |
| 2301 |
\providecommand{\corr}{\delim<>} |
| 2302 |
\providecommand{\comm}{\delimpair[{[p]*,}]} |
| 2303 |
\providecommand{\acomm}{\delimpair\{{[p]*,}\}} |
| 2304 |
\providecommand{\bra}{\delim<\dlm@rvert} |
| 2305 |
\providecommand{\ket}{\delim\dlm@lvert>} |
| 2306 |
\providecommand{\braket}{\delimpair<|>} |
| 2307 |
\dlm@choicedef{lfrac}{.}{\delimpair./.} |
| 2308 |
\dlm@choicedef{lfrac}{r}{\delimpair(/)} |
| 2309 |
\dlm@choicedef{lfrac}{s}{\delimpair[/]} |
| 2310 |
\dlm@choicedef{lfrac}{c}{\delimpair\{/\}} |
| 2311 |
\dlm@choicedef{lfrac}{a}{\delimpair</>} |
| 2312 |
\dlm@choicelet{lfrac}{}{.} |
| 2313 |
\dlm@choicelet{lfrac}{@}{.} |
| 2314 |
\providecommand{\lfrac}{\dlm@choice{lfrac}} |
| 2315 |
\fi |
| 2316 |
% \end{macrocode} |
| 2317 |
|
| 2318 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2319 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2320 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2321 |
% \iffalse |
| 2322 |
%</package> |
| 2323 |
% \fi |
| 2324 |
% |
| 2325 |
\endinput |