diff options
Diffstat (limited to 'macros')
19 files changed, 1565 insertions, 444 deletions
diff --git a/macros/latex/contrib/delimset/README.txt b/macros/latex/contrib/delimset/README.txt index 729b73fbbf..9094d59624 100644 --- a/macros/latex/contrib/delimset/README.txt +++ b/macros/latex/contrib/delimset/README.txt @@ -1,5 +1,5 @@ -delimset v1.1 -Copyright 2016-2018 Niklas Beisert +delimset v2.0 +Copyright 2016-2024 Niklas Beisert delimset is a LaTeX2e package to typeset and declare sets of delimiters in math mode whose size can be adjusted conveniently. diff --git a/macros/latex/contrib/delimset/delimset.dtx b/macros/latex/contrib/delimset/delimset.dtx index 9bd070b5ea..337f1a4271 100644 --- a/macros/latex/contrib/delimset/delimset.dtx +++ b/macros/latex/contrib/delimset/delimset.dtx @@ -1,6 +1,6 @@ % \iffalse % -% delimset.dtx Copyright (C) 2016-2018 Niklas Beisert +% delimset.dtx Copyright (C) 2016-2024 Niklas Beisert % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -18,15 +18,15 @@ % and the derived files delimset.sty and dlmssamp.tex % %<package|sample>\NeedsTeXFormat{LaTeX2e}[1996/12/01] -%<package>\ProvidesPackage{delimset}[2018/12/30 v1.1 convenient size control for delimiter sets] -%<sample>\ProvidesFile{dlmssamp.tex}[2018/12/30 v1.1 sample for delimset] +%<package>\ProvidesPackage{delimset}[2024/07/17 v2.0 convenient size control for delimiter sets] +%<sample>\ProvidesFile{dlmssamp.tex}[2024/07/17 v2.0 sample for delimset] %<*driver> -%\ProvidesFile{delimset.drv}[2018/12/30 v1.1 delimset Reference Manual file] +%\ProvidesFile{delimset.drv}[2024/07/17 v2.0 delimset Reference Manual file] \PassOptionsToClass{10pt,a4paper}{article} \documentclass{ltxdoc} \usepackage[margin=35mm]{geometry} -\usepackage{hyperref} +\usepackage[hyperindex=false]{hyperref} \usepackage{hyperxmp} \usepackage[usenames]{color} \usepackage{amsmath,amsfonts} @@ -36,7 +36,7 @@ \hypersetup{pdfpagemode=UseNone} \hypersetup{pdfsource={}} \hypersetup{pdflang={en-UK}} -\hypersetup{pdfcopyright={Copyright 2016-2018 Niklas Beisert. +\hypersetup{pdfcopyright={Copyright 2016-2024 Niklas Beisert. This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version.}} @@ -50,6 +50,8 @@ \newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}} +\def\textvert{\texttt{\char"7C}} + \parskip1ex \parindent0pt \let\olditemize\itemize @@ -67,7 +69,7 @@ {\texttt{nbeisert@itp.phys.ethz.ch}}} \hypersetup{pdfauthor={Niklas Beisert}} \hypersetup{pdfsubject={Manual for the LaTeX2e Package delimset}} -\date{30 December 2018, \textsf{v1.1}} +\date{17 July 2024, \textsf{v2.0}} \maketitle \begin{abstract}\noindent @@ -99,9 +101,10 @@ For example: \\ |(v,w)| &\to (v,w) \\ -|\langle\psi\vert M\vert\psi\rangle| &\to \langle\psi\vert M\vert\psi\rangle +|\langle\psi|\textvert|M|\textvert|\psi\rangle| +&\to \langle\psi\vert M\vert\psi\rangle \\ -|(x^2+px+q)\vert_{-p/2}| &\to (x^2+px+q)\vert_{-p/2} +|(x^2+px+q)|\textvert|_{-p/2}| &\to (x^2+px+q)\vert_{-p/2} \\&\ldots \end{aligned} \] @@ -109,8 +112,9 @@ For example: In order to adjust the size of delimiters, the modifiers |\big|, |\Big|, |\bigg|, |\Bigg| are used. More importantly the construct -{|\left*| \ldots [|\middle*|] \ldots |\right*|} +{|\left*| \ldots [|\middle*|] \ldots |\right*|} adjusts the size of delimiters to the contents: +% \[ \Bigg[\bigg[\Big[\big[[*]\big]\Big]\bigg]\Bigg], \qquad @@ -150,16 +154,17 @@ the size |\big(...\big)|: \] The package \textsf{delimset} provides mechanisms to declare sets of delimiters -whose size can be adjusted conveniently by simple optional parameters. +whose size can be adjusted conveniently by adding simple flag parameters. For example, it provides a general purpose bracket |\brk| which can be used as follows: +% \[ \begin{aligned} |\brk{A\hat{X}+B}|&\to(A\hat{X}+B) \\ |\brk*{A\hat{X}+B}|&\to\mathopen{}\mathclose{\left(A\hat{X}+B\right)} \\ -|\brk2{A\hat{X}+B}|&\to\Bigl(A\hat{X}+B\Bigr) +|\brk^2{A\hat{X}+B}|&\to\Bigl(A\hat{X}+B\Bigr) \\ |\brk!{A\hat{X}+B}|&\to\bigl(A\hat{X}+B\bigr) \end{aligned} @@ -198,16 +203,18 @@ the more difficult it will be to adjust them to obtain a visually acceptable result. The main functionality of the package is based on a -versatile mechanism to specify sets of delimiters, e.g.: +versatile mechanism to specify sets of delimiters, +e.g.: +% \[ \begin{aligned} |\delim<>{ax+b}| &\to\langle ax+b\rangle \\ -|\delimpair{[}{[.],}{[}!{a}{b}| +|\delimpair[{*,}[!{a}{b}| &\to \bigl[a, b\bigr[ \\ -|\delimtriple<\vert\vert>*{\psi}{A^\dagger}{\psi}| +|\delimtriple<|\textvert\textvert|>*{\psi}{A^\dagger}{\psi}| &\to\left\langle\psi\middle\vert A^\dagger\middle\vert \psi\right\rangle \end{aligned} \] @@ -216,14 +223,14 @@ The command |\delim| can be used on the fly, but also in definitions of custom delimiter sets such as: % \[ -|\newcommand{\comm}{\delimpair{[}{[.],}{]}}| +|\newcommand{\comm}{\delimpair{[}{*,}{]}}| \] % Note that the definition of |\comm| does not specify any arguments. They are nevertheless read by the incomplete definition of |\delimpair| -from the what follows |\comm|. +from what follows |\comm|. In particular, this incomplete definition -enables the correct parsing of the optional size specifier, +enables the correct parsing of the optional size specifier flag, e.g.: % \[ @@ -238,7 +245,7 @@ The above definition could be written as follows: \begin{aligned} &|\DeclareMathDelimiterSet{\comm}[2]| \\ -&\qquad |{\selectdelim[l]{[}{#1},{#2}\selectdelim[r]{]}}| +&\qquad |{\selectdeliml{[}{#1},{#2}\selectdelimr{]}}| \end{aligned} \] @@ -260,9 +267,9 @@ of the currently selected math font Unfortunately, it does not account for the currently selected math style. Therefore, the size of delimiters in sub/superscripts -cannot be adjusted appropriately, -\unskip\footnote{Arguably, it is bad typesetting practice -to have too complicated expressions in sub/superscripts.} +cannot be adjusted appropriately +(an arguably better typesetting practice is +to avoid complicated expressions in sub/superscripts in the first place), they come out way too big: % \[ @@ -272,7 +279,7 @@ they come out way too big: This package modifies the definitions of the size modifiers (of \textsf{amsmath}) to automatically adjust to sub/superscripts -(subject to availability): +(subject to availability in the font): % \[ \makeatletter @@ -282,6 +289,7 @@ to automatically adjust to sub/superscripts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Spacing and Math Classes} +\label{sec:spacing} Another shortcoming of the variable-size delimiters is that the spacing is noticeably different from their fixed-size counterparts: @@ -291,12 +299,12 @@ the spacing is noticeably different from their fixed-size counterparts: |\square(ax+b)\square| &\to \square(ax+b)\square \\ -|\square\left(ax+b\right)\square| -&\to \square\left(ax+b\right)\square -\\ |\square\bigl(ax+b\bigr)\square| &\to \square\bigl(ax+b\bigr)\square \\ +|\square\left(ax+b\right)\square| +&\to \square\left(ax+b\right)\square +\\ |\square\left(ax+\big.b\right)\square| &\to \square\left(ax+\big.b\right)\square \end{aligned} @@ -328,8 +336,9 @@ For practical purposes, consistent spacing can only be achieved by a more convenient mechanism. On a related note, it is important to correctly specify -the math class (|\mathopen|\hspace{0pt}/\hspace{0pt}|\mathclose|) +the math class (such as |\mathopen| or |\mathclose|) for the delimiters, for example: +% \[ \begin{aligned} |\big(-1\big)| &\to \big(-1\big) @@ -340,19 +349,23 @@ for the delimiters, for example: % The math class can also make a major difference for intermediate delimiters, e.g.: +% \[ \begin{aligned} -|\bigl\langle\psi\big\vert\psi\bigr\rangle| -&\to \bigl\langle\psi\big\vert\psi\bigr\rangle +|\bigl<\psi\big|\textvert|\psi\bigr>| +&\to \bigl<\psi\big\vert\psi\bigr> \\ -|\bigl\langle\psi\bigm\vert\psi\bigr\rangle| -&\to \bigl\langle\psi\bigm\vert\psi\bigr\rangle +|\bigl<\psi\mathpunct\big|\textvert|\psi\bigr>| +&\to \bigl\langle\psi\mathpunct\big\vert\psi\bigr> \\ -|\bigl\langle\psi\mathbin\big\vert\psi\bigr\rangle| -&\to \bigl\langle\psi\mathbin\big\vert\psi\bigr\rangle +|\bigl<\psi\mathinner\big|\textvert|\psi\bigr>| +&\to \bigl\langle\psi\mathinner\big\vert\psi\bigr> \\ -|\bigl\langle\psi\mathpunct\big\vert\psi\bigr\rangle| -&\to \bigl\langle\psi\mathpunct\big\vert\psi\bigr\rangle +|\bigl<\psi\mathbin\big|\textvert|\psi\bigr>| +&\to \bigl\langle\psi\mathbin\big\vert\psi\bigr> +\\ +|\bigl<\psi\bigm|\textvert|\psi\bigr>| +&\to \bigl\langle\psi\bigm\vert\psi\bigr> \end{aligned} \] % @@ -364,6 +377,67 @@ of the left and right delimiters. It also offers several choices for intermediate delimiters to take the context into account. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Compounds and Broken Lines} + +The mechanism provided by the package requires the delimited expression +to appear as an uninterrupted compound. In particular, the expression cannot +span several lines in a multi-line equation or several columns in a matrix. +The same restriction applies to the elementary |\left| and |\right| construct. +In cases where delimited expressions are torn apart across several blocks, +the delimiters have to be typeset individually. +The package offers a mechanism to display individual delimiters +of a given delimiter set. It also assists in maintaining +the same type and size across blocks. +Being able to display individual delimiters of defined delimiter sets +offers a broad range of (ab)use. + +Individual delimiters of a set can be selected and displayed +by specifying appropriate flags, +for example: +% +\[ +|\brk(|\to{(},\qquad +|\brk)|\to{)} +\] +% +These flags can be combined with the size specifier +or other bracket modifiers, +e.g.: +% +\[ +|\brk^3(|\to{\biggl(},\qquad +|\brk[s]^2)|\to{\Bigr]} +\] +% +This enables to conveniently split delimited expressions over blocks of code, +e.g.: +% +\[ +|\brk[s]^3(\frac{A}{B}|\ldots\Big/\mkern-9mu\Big/\ldots|\frac{C}{D}\brk[s]^3)| +\to +\biggl[\frac{A}{B}\cdots\bigg/\mkern-12mu\bigg/\cdots\frac{C}{D}\biggr] +\] +% +Here, the type and modifiers specifying the delimiter set +are repeated for all individual delimiters. +To simplify such expressions and their maintenance, +the package provides global registers which store +the type and size of delimiters. +With those, the above expression can be abbreviated as: +% +\[ +|\brk[s]^3[|\ldots\big/\mkern-6mu\big/\ldots|\usedelim]| +\quad\text{or}\quad +|\brk[s]^3[|\ldots\big/\mkern-6mu\big/\ldots|\brk]| +\] +% +Here, |\usedelim]|, alternatively |\brk]|, +closes the delimiter set with +the type and options previously specified by |\brk...[|. +For nesting purposes, there also exists a more elaborate +solution using registers, see below. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Philosophy} Semantic typesetting is one of the philosophies behind \LaTeX{}: @@ -435,17 +509,17 @@ Modifier letters can be prepended and appended to adjust their size. % A functionality of the present package not offered by any of the above packages is -to typeset delimiters on the fly, e.g.: +to typeset delimiters on the fly, +e.g.: % \[ -|\delim<\vert>!{\psi}{\psi}| -\to\bigl\langle\psi\big\vert\psi\bigr\rangle +|\delim<|\textvert|>!{\psi}{\psi}| +\to\bigl<\psi\big\vert\psi\bigr> \] % The mechanism to specify the size is leaner in the sense that it uses only a single character and a single command. - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Usage} @@ -457,139 +531,377 @@ If not yet present, the package \textsf{amsmath} will be loaded automatically. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Inline Usage} -\label{sec:delimcommands} +\subsection{Delimiter Sets and Presentation Flags} +\label{sec:flags} + +The package provides commands to represent various delimiter sets, +see \secref{sec:inline} and \secref{sec:declare} below. +Their display can be modified systematically by specifying flags. +A delimiter set |\|\emph{name}, e.g.\ |\brk|, is typically invoked by +a sequence like: +% +\[ +|\|\emph{name}\ \emph{flags}\ |{|\emph{expr1}|}||{|\emph{expr2}|}|\ldots +\] +% +where \emph{expr(n)} are the terms to be enclosed by the delimiters +and the optional \emph{flags} adjust the presentation of delimiters. +The \emph{flags} are described as follows: + +First, a size modifier flag controls the size of the delimiters +to be displayed. It can take one of the following values: +% +\[ +\begin{aligned} +|0|&\qquad \text{default size} +\text{ (0.96 times default line height)} +\\ +|!|, |+|, |^1|&\qquad \text{size }|\big| +\text{ (1.2 times default line height)} +\\ +|^2|&\qquad \text{size }|\Big| +\text{ (1.8 times default line height)} +\\ +|^3|&\qquad \text{size }|\bigg| +\text{ (2.4 times default line height)} +\\ +|^4|&\qquad \text{size }|\Bigg| +\text{ (3.0 times default line height)} +\\ +|^|\emph{n}, |^{|\emph{x}|}|&\qquad \text{flexible size adjustment +(\emph{n}=|0|\ldots|9|; \emph{x}: decimal number)} +\\ +|_{|\emph{h}|}|&\qquad \text{adjustment to absolute height \emph{h} (centred)} +\\ +|*|&\qquad \text{variable size }|\left...\right| +\end{aligned} +\] +% +The intended delimiter size is stored as the dimension register: +% +\[ +|\delimsize| +\] +% +It may be used to adjust spacing within the delimiter set +proportional to the size of the delimiters. +Note that the actual size of delimiters may deviate +depending on availability within the given font. +Note further that the size cannot be determined for variable-size delimiters +(`|*|') and thus size |\Big| is assumed for this case. +Note finally that the sub/superscript styles are not taken into +account and |\delimsize| applies to the default case |\textstyle|. +The package also supplies a macro to add horizontal glue +proportional to the intended delimiter size: +% +\[ +|\kerndelim{|\emph{width}|}| +\] +% +Here, \emph{width} is the amount of horizontal glue +in units of mu scaled by the ratio of |\delimsize| +and the current math font height. +The macro does adjust for the selected script style. + +Second, a delimiter selection flag is used to pick out +and display just one individual delimiter within the set. +It can take one of the following values: +% +\[ +\begin{aligned} +|(|&\qquad \text{left delimiter} +\\ +\textvert, |,|&\qquad \text{first intermediate delimiter} +\\ +|)|&\qquad \text{right delimiter} +\\ +|?|\emph{n}&\qquad \text{\emph{n}-th delimiter (starting with |0|: left)} +\end{aligned} +\] + +Third, register flags store are retrieve delimiter +for splitting the across blocks or lines: +% +\[ +\begin{aligned} +|[|&\qquad \text{store delimiter type to register `|.|', +display left delimiter (same as `|>.(|')} +\\ +|]|&\qquad \text{display right delimiter stored in default register `|.|' +(same as `|<.)|')} +\\ +|>|\emph{r}, |>{|\emph{reg}|}|&\qquad \text{store delimiter type +in register \emph{r} or \emph{reg}} +\\ +|<|\emph{r}, |<{|\emph{reg}|}|&\qquad \text{retrieve delimiter type +from register \emph{r} or \emph{reg}} +\end{aligned} +\] +% +A register stores the type of delimiter set (|\|\emph{name}), +the desired size (except for variable size `|*|') +as well as the math class of the compound (`|'|' vs. `|"|', see below). +A stored register can be retrieved and displayed by the macro: +% +\[ +|\usedelim|\,\emph{r}\ \emph{sel} +\quad\text{or}\quad +|\usedelim|\{\emph{reg}\}\emph{sel} +\] +% +Here, \emph{sel} is a flag to select an individual delimiter, see above. + +In addition, there are some general purpose flags: +% +\[ +\begin{aligned} +|.|&\qquad \text{terminates flag processing} +\\ +|:|&\qquad \text{enclose delimiter set in block +(for using total box dimensions)} +\\ +|'|&\qquad \text{render delimiter set as }|\mathopen|\text{ and }|\mathclose| +\\ +|"|&\qquad \text{render delimiter set as }|\mathinner| +\\ +|-|&\qquad \text{display phantom delimiters (for individual delimiters)} +\end{aligned} +\] + +Please note the following: +% +\begin{itemize} +\item +A delimiter selector (including the combined flags `|[|' and `|]|') +terminates flag processing, +therefore all relevant flags must be specified before it. +\item +Parsing also stops with the opening of the first term argument +by means of the opening brace `|{|'. +\item +Parsing can also be terminated manually by specifying the flag `|.|' +(in case the opening brace `|{|' for arguments is missing for whatever reason). +\item +Any other letter or token at the location of \emph{flags} +is interpreted as an unrecognised flag and triggers a compiler error. +For instance, |\brk{x}| must not be abbreviated as |\brk x| +because `|x|' would be interpreted as a flag +(it might be abbreviated as |\brk.x|). +\item +The legacy size modifier flags `|1|' \ldots `|4|' +provided for backward compatibility have the same effect as `|^1|'\ldots`|^4|'. +\item +The phantom delimiter flag `|-|' does not work for variable size. +It is intended for reserving space for individual delimiters +when they are composed manually into sets (e.g.\ across lines). +\item +Technically, individual delimiters can be produced in the variable size version +(even though it may defeat the purpose of the delimiter selection mechanism). +One has to pay attention when using +only the opening or only the closing delimiters from the package +and counterbalancing it by direct code for the opposite side. +This is because `|*(|' and `|*)|' do not directly translate to +|\left|\emph{delim} and |\right|\emph{delim} +due to proper spacing, see \secref{sec:spacing}. +Instead, they translate to: +% +\[ +\begin{aligned} +|*(|&\to|\mathopen{}\mathclose\bgroup\left|\emph{delim} +\\ +|*)|&\to|\right|\emph{delim}|\egroup| +\end{aligned} +\] +% +One should use analogous code to complete the manual variable size block. + +Note that similar restrictions apply to using the flag `|:|' +for block enclosure which uses |\bgroup| and |\egroup| as well. + +As it does not make much sense to use variable-size (`|*|') +and block (`|:|') compounds for individual delimiter selection, +the state of these flags is not stored in the global registers. +\end{itemize} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Inline Declarations} +\label{sec:inline} The package provides three general purpose commands to compose delimiter sets with one, two or three encapsulated expressions: % \[ \begin{aligned} -&|\delim{|\emph{l}|}{|\emph{r}|}|\emph{size}|{|\emph{expr}|}| +&|\delim{|\emph{l}|}{|\emph{r}|}|\emph{flags}|{|\emph{expr}|}| \\ &|\delimpair{|\emph{l}|}{|\emph{m}|}{|\emph{r}|}| -\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}| +\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| \\ -&|\delimtriple{|\emph{l}|}{|\emph{m1}|}{|\emph{m2}|}{|\emph{r}|}| -\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}{|\emph{expr3}|}| +&|\delimtriple{|\emph{l}|}{|\emph{m}|}{|\emph{n}|}{|\emph{r}|}| +\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}{|\emph{expr3}|}| \end{aligned} \] % The expression(s) \emph{expr(n)} will be surrounded by the delimiters \emph{l} and \emph{r} and, in the case of more than one expression, -they will be separated by the delimiters \emph{m(n)}: +they will be separated by the delimiters \emph{m}, \emph{n}: +% \[ \emph{l}\ \emph{expr}\ \emph{r}, \qquad \emph{l}\ \emph{expr1}\ \emph{m}\ \emph{expr2}\ \emph{r}, \qquad -\emph{l}\ \emph{expr1}\ \emph{m1}\ \emph{expr2}\ -\emph{m2}\ \emph{expr3}\ \emph{r} +\emph{l}\ \emph{expr1}\ \emph{m}\ \emph{expr2}\ +\emph{n}\ \emph{expr3}\ \emph{r} \] -Here, \emph{l} and \emph{r} have to be -math delimiters (symbols which can be used for |\left| and |\right|) or -the dot `.' for the null delimiter. -The separators \emph{m(n)} can be plain math delimiters as well, but they can -also be compound expression of the form |[|\emph{class}|]|\emph{delim} -where \emph{class} specifies -the intended math class of the delimiter \emph{delim}: +Here, \emph{l}, \emph{r}, \emph{m}, \emph{n} +should be math delimiters \emph{delim} +(elementary symbols which can be used for |\left| and |\right|) +or the dot `|.|' for the null delimiter. +The delimiter set expression can be adjusted in two ways: + +First, size adjustment +for the delimiters \emph{l}, \emph{r}, \emph{m}, \emph{n} +can be suppressed by a starred variant: +% +\[ +|{*|\emph{token}|}| +\qquad\text{or}\qquad +|{*{|\emph{expr}|}}| +\] +% +This allows to use an arbitrary \emph{token} +or a compound expression \emph{expr} in place of a delimiter \emph{delim}. +This is useful when a delimiter character should not adjust in size +(e.g.\ commas), or if a flexible-size version of the character +is not available. One might also use a compound expression +to create a null delimiter with non-zero width +(the width may be specified by |\kerndelim| +to make it proportional to the delimiter size). + +Second, the intended math class +of the intermediate delimiters \emph{m}, \emph{n} +may be adjusted in order to achieve a more appropriate automatic spacing +by using |{[|\emph{class}|]|\emph{delim}|}|. +Here, \emph{class} specifies +the intended math class of the delimiter \emph{delim} +according to: % \[ -\begin{aligned}{} +\begin{aligned} \left.\begin{array}{r} -\emph{delim}\\|{|\emph{delim}|}|\\|{[]|\emph{delim}|}| +\emph{delim}\\|{|\emph{delim}|}| \end{array}\right\} -&\qquad\text{class }|\mathord|\text{ (similar to }|\big|) -\\ -|{[l]|\emph{delim}|}|&\qquad -\text{class }|\mathopen|\text{ (similar to }|\bigl| -\text{, not for use in }|\delim...|) -\\ -|{[r]|\emph{delim}|}|&\qquad -\text{class }|\mathclose|\text{ (similar to }|\bigr| -\text{, not for use in }|\delim...|) +&\qquad +\left\{\begin{array}{l} +\text{no glue for size-adjusted delimiters (same as }|[o]|\text{)} \\ -|{[o]|\emph{delim}|}|&\qquad -\text{class }|\mathopen|\text{ (similar to }|\bigl|) +\text{determined by expression for unadjusted size (}|*|\text{ variant)} +\end{array}\right. \\ -|{[c]|\emph{delim}|}|&\qquad -\text{class }|\mathclose|\text{ (similar to }|\bigr|) -\\ -|{[m]|\emph{delim}|}|&\qquad -\text{class }|\mathrel|\text{ (similar to }|\bigm|) +|{[o]|\emph{delim}|}| +&\qquad +\text{no glue, similar to }|\big|, |\mathord|, |\mathopen|, |\mathclose| \\ |{[p]|\emph{delim}|}|&\qquad -\text{class }|\mathpunct|\text{ (similar to }|\bigp|) +\text{followed by }|\thinmuskip|\text{, similar to }|\bigp|, |\mathpunct| +\\ +|{[i]|\emph{delim}|}|&\qquad +\text{surrounded by }|\thinmuskip|\text{, similar to }|\bigi|, |\mathinner| \\ |{[b]|\emph{delim}|}|&\qquad -\text{class }|\mathbin|\text{ (similar to }|\bigb|) +\text{surrounded by }|\medmuskip|\text{, similar to }|\bigb|, |\mathbin| \\ -|{[.]|\emph{expr}|}|&\qquad -\text{no size adjustment, \emph{expr} can be any expression} +|{[m]|\emph{delim}|}|&\qquad +\text{surrounded by }|\thickmuskip|\text{, similar to }|\bigm|, |\mathrel| \end{aligned} \] -% -Note that the left and right delimiters \emph{l} and \emph{r} effectively -have |[l]| and |[r]| prepended, respectively, -and therefore they must be a plain math delimiter. -Conversely, the immediate delimiters \emph{m(n)} must not -have the |[l]| and |[r]| classes -because the latter must appear precisely once -and they are already taken by \emph{l} and \emph{r}; -use classes |[o]| and |[c]| instead. -The optional size modifier \emph{size} should take one of the following values: +Please note the following: +% +\begin{itemize} +\item +The left and right delimiters \emph{l} and \emph{r} +are assigned to special classes: +They leave no initial and final glue on the enclosed expressions +(same as |\mathopen| and |\mathclose|). +From the outside, the delimiter set appears +either as a combination of |\mathopen|+|\mathclose| (flag `|'|') +or as |\mathinner| (flag `|"|'). +\item +The legacy class |[.]| provided for backward compatibility +specifies delimiters with unadjusted size: +the compound |{[.]|\emph{expr}|}| has the same effect as |{*{|\emph{expr}|}}|. +\item +The legacy class |[c]| provided for backward compatibility +has the same effect as |[o]|. +\item +Unadjusted-size delimiters can be combined with math classes as: +% \[ -\begin{aligned}{} -\emph{empty}, \emph{anything else}, |0|&\qquad \text{default size} -\\ -|!|, |+|, |1|&\qquad \text{size }|\big|\text{ (|!| is preferred)} -\\ -|2|&\qquad \text{size }|\Big| -\\ -|3|&\qquad \text{size }|\bigg| -\\ -|4|&\qquad \text{size }|\Bigg| -\\ -|*|&\qquad \text{variable size }|\left...\right| -\end{aligned} +|{[|\emph{class}|]*|\emph{token}|}| +\qquad\text{or}\qquad +|{[|\emph{class}|]*{|\emph{expr}|}}| \] +% +\item +The opening square bracket `|[|' +takes the dual role of indicating the optional |[|\emph{class}|]| argument. +To avoid conflicts on intermediate delimiters, +opening square bracket delimiters should be encoded as +`|{{[}}|' (for |\delim...|) or `|{[}|' (for |\selectdelim|) +rather than `|[|'. +\end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Declarations} +\label{sec:declare} The above constructs can be used to define new delimiter commands via: % \[ -|\newcommand{\|\emph{name}|}{\delim...{|\emph{l}|}...{|\emph{r}|}}| +\begin{aligned} +&|\newcommand{\|\emph{name}|}{\delim{|\emph{l}|}{|\emph{r}|}| +\emph{flags}|}| +\\ +&|\newcommand{\|\emph{name}|}{\delimpair{|\emph{l}|}{|\emph{m}|}{|\emph{r}|}| +\emph{flags}|}| +\\ +&|\newcommand{\|\emph{name}|}{\delimtriple{|\emph{l}|}{|\emph{m}|}| +|{|\emph{n}|}{|\emph{r}|}|\emph{flags}|}| +\end{aligned} \] % -Here it makes sense to drop all arguments starting -with the size modifier \emph{size} from the definition. +Here it makes sense to drop all arguments +starting at the optional \emph{flags} argument from the definition. The \TeX{} parsing mechanism will then automatically use the tokens following |\|\emph{name} including the optional size modifier. -If the encapsulated expression(s) are to be passed as explicit arguments -to |\|\emph{name}, one will have to find an alternative way to pass the -optional size argument. +If any of the encapsulated expression(s) are to be passed as +explicit arguments to |\|\emph{name}, +one will have to find an alternative way to pass \emph{flags}. +However, it is possible to predefine \emph{flags} +which can be overridden by further \emph{flags} specified by the user. The above declarations via |\delim...| -should be sufficient for almost all situations. +should be sufficient for most situations. However, there is an even more flexible way to declare delimiter sets: +% \[ -|\DeclareMathDelimiterSet{\|\emph{name}|}[|\emph{narg}|]{|\emph{expr}|}| +|\DeclareMathDelimiterSet{\|\emph{name}|}[|\emph{narg}|]{|\emph{compositor}|}| \] % The syntax of this command is equivalent to the one of |\newcommand|. The difference is that the command |\|\emph{name} first looks -for the optional size modifier \emph{size} as -described above in \secref{sec:delimcommands}. -It remembers the desired size for evaluating the macro \emph{expr}. +for the \emph{flags} argument as +described above in \secref{sec:inline}. +It remembers the desired size for evaluating +the macro expression \emph{compositor}. Then it parses the arguments as if the command was declared by |\newcommand|. -As usual, the macro \emph{expr} contains the command arguments +As usual, the macro expression \emph{compositor} contains the command arguments specified by |#1|, |#2|, \ldots. Note that these should be encapsulated in groups |{#1}|, |{#2}|, \ldots, in order to prevent them from overwriting definitions @@ -598,16 +910,108 @@ It should also contain the desired math delimiters specified by: % \[ -|\selectdelim[|\emph{class}|]{|\emph{delim}|}| +\begin{aligned} +&|\selectdeliml|[|*|]|{|\emph{delim}|}| +\\ +&|\selectdelim[|\emph{class}|]|[|*|]|{|\emph{delim}|}| +\\ +&|\selectdelimr|[|*|]|{|\emph{delim}|}| +\end{aligned} \] % +The three commands must be in proper sequence +starting with |\selectdeliml| followed by arbitrarily many +|\selectdelim| and terminated by |\selectdelimr|. +The math classes \emph{class} and starred variants +are defined analogously to \secref{sec:inline}. Here, the sizes are adjusted automatically -according to the previously specified modifier \emph{size}. -The math classes must be in proper sequence, -i.e.\ the first and last ones must be |l| and |r|, respectively, -while the intermediate ones can be anything by |l| and |r|, -see \secref{sec:delimcommands}. +according to the previously specified modifier. + +Picking out individual delimiters from a set +declared by |\DeclareMathDelimiterSet| +cannot be achieved automatically. +Instead, a selector method may be specified manually (where needed) by: +% +\[ +\begin{aligned} +&|\DeclareMathDelimiterSel{\|\emph{name}|}| +\\ +&| {\selectdeliml{|\emph{l}|}|[|\||or\selectdelim{|\emph{m}|}|\ldots]|}| +\\ +&| {\selectdelimr{|\emph{r}|}}| +\end{aligned} +\] +% +As many intermediate delimiters as needed can be specified +at the end of the first argument; each one must start with `|\||or|'. + +\makeatletter +For example, one might declare a set of double square brackets +$[\kern-0.06\big@size[*]\kern-0.06\big@size]$ using: +\makeatother +% +\[ +\begin{aligned} +&|\DeclareMathDelimiterSet{\dsb}[1]| +\\ +&| {\selectdeliml{[}\kerndelim{-1.75}\selectdelim[o]{[}{#1}| +\\ +&| \selectdelim[o]{]}\kerndelim{-1.75}\selectdelimr{]}}| +\end{aligned} +\] +% +Here, the command |\kerndelim{-1.75}| reduces the spacing +between the two square brackets by approximately 1.75\,mu in default size. +This could be used for: +% +\[ +\makeatletter +|\dsb^4{\dsb^3{\dsb^2{\dsb^1{\dsb{*}}}}}| +\to +\Biggl[\kern-0.20\big@size\Biggl[ +\biggl[\kern-0.16\big@size\biggl[ +\Bigl[\kern-0.12\big@size\Bigl[ +\bigl[\kern-0.08\big@size\bigl[ +[\kern-0.06\big@size[* +]\kern-0.06\big@size] +\bigr]\kern-0.08\big@size\bigr] +\Bigr]\kern-0.12\big@size\Bigr] +\biggr]\kern-0.16\big@size\biggr] +\Biggr]\kern-0.20\big@size\Biggr], +\quad +|\dsb*|\ldots\to +\left[\kern-0.12\big@size\middle[\frac{x}{y} +\middle]\kern-0.12\big@size\right] +\makeatother +\] +% +An appropriate selector method for displaying individual +delimiters reads: +% +\[ +\begin{aligned} +&|\DeclareMathDelimiterSel{\dsb}| +\\ +&| {\selectdeliml{[}\kerndelim{-1.75}\selectdelim[o]{[}}| +\\ +&| {\selectdelim[o]]\kerndelim{-1.75}\selectdelimr{]}}| +\end{aligned} +\] +Finally, towards a very flexible manual composition +of delimiter sets, there is the macro: +% +\[ +|\parsedelimflags{|\emph{compositor}|}{|\emph{selector}|}|\emph{flags} +\] +% +It parses the modifier flags as described in \secref{sec:flags}. +The argument \emph{compositor} is code that displays the +composited delimiter set whereas \emph{selector} is a macro +that displays the delimiter number |\selecteddelim| of the set. +The \emph{flags} follow immediately and should be terminated by +an opening brace `|{|', the terminating flag `|.|' +or a delimiter selection flag. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Default Declarations} @@ -617,30 +1021,34 @@ The package predefines four commonly used sets of delimiters: % \begin{itemize} \item -|\brk[|\emph{type}|]|\emph{size}|{|\emph{expr}|}| represents +|\brk[|\emph{type}|]|\emph{flags}|{|\emph{expr}|}| represents a standard bracket around a single expression \emph{expr}. The type of bracket can be specified by the optional argument \emph{type}: +% \[ \text{\emph{empty} or |[r]|: round }(x),\quad \text{|[s]|: square }[x],\quad \text{|[c]|: curly }\{x\},\quad \text{|[a]|: angle }\langle x\rangle \] +% \item -|\eval[|\emph{type}|]|\emph{size}|{|\emph{expr}|}| represents +|\eval[|\emph{type}|]|\emph{flags}|{|\emph{expr}|}| represents evaluation of a functional expression \emph{expr}. The type of bracket can be specified by the optional argument \emph{type}: +% \[ \text{\emph{empty} or |[v]|: }f(x)\vert_{a},\qquad \text{|[s]|: }[f(x)]_{a}^{b} \] +% \item -|\abs|\emph{size}|{|\emph{expr}|}| represents +|\abs|\emph{flags}|{|\emph{expr}|}| represents the absolute value $\lvert\emph{expr}\rvert$. \item -|\norm|\emph{size}|{|\emph{expr}|}| represents +|\norm|\emph{flags}|{|\emph{expr}|}| represents the norm $\lVert\emph{expr}\rVert$. \end{itemize} % @@ -651,19 +1059,20 @@ The package also defines some extended sets of delimiters as follows: % \begin{itemize} \item -|\pair|\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}| represents +|\pair|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents a pair(ing) $(\emph{expr1},\emph{expr2})$. \item -|\set|\emph{size}|{|\emph{expr}|}| represents +|\set|\emph{flags}|{|\emph{expr}|}| represents the set $\{\emph{expr}\}$. \item -|\setcond|\emph{size}|{|\emph{expr}|}{|\emph{cond}|}| represents +|\setcond|\emph{flags}|{|\emph{expr}|}{|\emph{cond}|}| represents a set with condition $\{\emph{expr}\vert\emph{cond}\}$. \item -|\intv[|\emph{type}|]|\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}| represents +|\intv[|\emph{type}|]|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents an interval from \emph{expr1} to \emph{expr2}. The in/\hspace{0pt}exclusion of the bounds can be specified by the optional argument \emph{type}: +% \[ \text{\emph{empty} or |[c]|: closed }[a,b],\qquad \text{|[o]|: open }]a,b[,\qquad @@ -673,28 +1082,35 @@ argument \emph{type}: \text{|[r]|: right-open }[a,b[ \end{array} \] +% \item -|\avg|\emph{size}|{|\emph{expr}|}| represents +|\avg|\emph{flags}|{|\emph{expr}|}| represents some average $\langle\emph{expr}\rangle$. \item -|\corr|\emph{size}|{|\emph{expr}|}| represents +|\corr|\emph{flags}|{|\emph{expr}|}| represents some correlator $\langle\emph{expr}\rangle$. \item -|\comm|\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}| represents +|\comm|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents the commutator $[\emph{expr1},\emph{expr2}]$. \item -|\acomm|\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}| represents +|\acomm|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents the anti-commutator $\{\emph{expr1},\emph{expr2}\}$. \item -|\bra|\emph{size}|{|\emph{expr}|}| represents +|\bra|\emph{flags}|{|\emph{expr}|}| represents a bra-vector $\langle\emph{expr}\rvert$ in quantum mechanics. \item -|\ket|\emph{size}|{|\emph{expr}|}| represents +|\ket|\emph{flags}|{|\emph{expr}|}| represents a ket-vector $\lvert\emph{expr}\rangle$ in quantum mechanics. \item -|\setcond|\emph{size}|{|\emph{expr1}|}{|\emph{expr2}|}| represents +|\braket|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| represents a bra-ket contraction $\langle\emph{expr1}\vert\emph{expr2}\rangle$. +\item +|\lfrac[|\emph{type}|]|\emph{flags}|{|\emph{expr1}|}{|\emph{expr2}|}| describes +the linear representation $\emph{expr1}/\emph{expr2}$ of a fraction. +An optional argument \emph{type} taking values |[r]|, |[s]|, |[c]|, |[a]| encloses the +fraction in round, square, curly or angle brackets as for |\brk|. \end{itemize} +% The extended definitions need to be activated by the package option |extdef|, see \secref{sec:packageoptions}. @@ -707,10 +1123,10 @@ or taste of the user, they can be redefined with |\renewcommand|. In addition to the |\bigl|, |\bigr| and |\bigm| commands (as well as their |\Big.|, |\bigg.| and |\Bigg.| counterparts), -the package defines two additional sets |\bigp| and |\bigb| +the package defines three additional sets |\bigp|, |\bigb| and |\bigi| (and counterparts). -Here |\bigp| implies the math class |\mathpunct| -and |\bigb| the class |\mathbin|. +Here |\bigp| implies the math class |\mathpunct|, +|\bigb| the class |\mathbin| and |\bigi| the class |\mathinner|. Furthermore, the package overloads the size calculation in the |\big...| commands to properly account for the math styles in sub/superscripts @@ -722,7 +1138,8 @@ the package option |scriptstyle|, see \secref{sec:packageoptions}. \subsection{Package Options} \label{sec:packageoptions} -Options can be passed to the package by +Options can be passed to the package by: +% \[ |\usepackage[|\emph{opts}|]{delimset}| \qquad @@ -735,17 +1152,17 @@ Here \emph{opts} is a comma-separated list of the available options: % \begin{itemize} \item -|stddef|[|=true|$\vert$|false|] +|stddef|[|=true|\textbar|false|] controls the activation of standard delimiter definitions specified in \secref{sec:defaultcommands}. If no value is given |true| is assumed; initially set to |true|. \item -|extdef|[|=true|$\vert$|false|] +|extdef|[|=true|\textbar|false|] controls the activation of extended delimiter definitions specified in \secref{sec:defaultcommands}. If no value is given |true| is assumed; initially set to |false|. \item -|scriptstyle|[|=true|$\vert$|false|] +|scriptstyle|[|=true|\textbar|false|] controls the overwriting of size modifiers explained in \secref{sec:auxcommands}. If no value is given |true| is assumed; initially set to |true|. @@ -758,7 +1175,7 @@ If no value is given |true| is assumed; initially set to |true|. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Copyright} -Copyright \copyright{} 2016--2018 Niklas Beisert +Copyright \copyright{} 2016--2024 Niklas Beisert This work may be distributed and/or modified under the conditions of the \LaTeX{} Project Public License, either version 1.3 @@ -808,7 +1225,7 @@ distribution, e.g.\ \textit{texmf-root}|/tex/latex/delimset|. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Interaction with CTAN Packages} -The package relies on other packages: +The package is related to other packages available at CTAN: \begin{itemize} \item This package relies on some functionality of the package \textsf{amsmath} @@ -820,24 +1237,63 @@ This package uses the package \textsf{keyval} from the \textsf{graphics} bundle to process optional arguments to the package options. Compatibility with the \textsf{keyval} package has been tested with v1.15 (2014/10/28). +\item +The package \textsf{icomma} modifies the spacing behaviour +of the comma character in math mode +which leads to inadequate spacing when it is used as a middle delimiter. +To achieve proper spacing in sample code, +use |{[p]*,}| rather than |{*,}|. +The extended commands |\intv|, |\comm|, |\acomm| and |\pair| +are compatible with the \textsf{icomma} package +has been tested with v2.0 (2002/03/10). \end{itemize} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\subsection{Feature Suggestions} -% specify width of null delimiter? -% automatic nesting of bracket types? % make optional arguments work for DeclareMathDelimiterSet? -% add pfrac for fraction a/b in text mode +% (must go before parsing, but how to process and react?) +% make unadjusted size have right height +% automatic nesting of bracket types? -> depth stack? % handle cramped style properly (perhaps impossible) -% outer decorations for delimiters e.g. _y<a,b>_x -% freestyle delimiter with size adjustment replacement \size{\rangle}_x %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Revision History} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\paragraph{v2.0:} 2024/07/17 + +\begin{itemize} +\item +option to display individual delimiters +and to store them in global registers across blocks +(columns, lines, etc.) +\item +more general handling of unadjusted-size delimiters +\item +more general size adjustments +\item +added inner math class for intermediate delimiters +\item +added flag to enclose by open/close and inner math class +\item +added flag to display phantom delimiters +\item +selected size accessible by |\delimsize| +and add proportional kerning by |\kerndelim|. +\item +added extended definition |\lfrac| for plain inline fractions +\item +null delimiter now properly has zero width for variable size +\item +internal mechanisms revised +\item +compatibility with \textsf{icomma} package +(thanks to Olivier Godin for pointing out the issue) +\end{itemize} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \paragraph{v1.1:} 2018/12/30 \begin{itemize} @@ -914,11 +1370,11 @@ standard definitions sizes for default brackets: % \begin{macrocode} \[ -\brk0{x},\quad -\brk1{x},\quad -\brk2{x},\quad -\brk3{x},\quad -\brk4{x} +\brk^0{x},\quad +\brk^1{x},\quad +\brk^2{x},\quad +\brk^3{x},\quad +\brk^4{x} \] % \end{macrocode} @@ -935,7 +1391,7 @@ styles for default brackets: nested brackets: % \begin{macrocode} \[ -\brk[c]2{\brk[s]!{\brk{ax+b}x+c}x+d} +\brk[c]^2{\brk[s]!{\brk{ax+b}x+c}x+d} \] % \end{macrocode} @@ -952,7 +1408,7 @@ default absolute value, norm and default evaluations: outer delimiter spacing: % \begin{macrocode} \begin{align*} -&\square\brk0{x}\square,&&\square\brk1{A^k}\square, +&\square\brk^0{x}\square,&&\square\brk^1{A^k}\square, \\ &\square\brk*{x}\square,&&\square\brk*{A^k}\square \end{align*} @@ -969,7 +1425,7 @@ e^{\brk!{ax+b}} delimiter declaration: % \begin{macrocode} \DeclareMathDelimiterSet{\braket}[2] - {\selectdelim[l]<#1\selectdelim|#2\selectdelim[r]>} + {\selectdeliml<#1\selectdelim|#2\selectdelimr>} \[ \braket!{\psi}{\psi}, \quad @@ -988,32 +1444,36 @@ conditional set, alternative layouts: % \begin{macrocode} \[ \delimpair\{{[m]|}\}!{2n}{n\in\mathbb{Z}}, -\qquad +\quad \delimpair\{{[b]|}\}!{2n}{n\in\mathbb{Z}}, -\qquad +\quad +\delimpair\{{[i]|}\}!{2n}{n\in\mathbb{Z}}, +\quad \delimpair\{{[p]|}\}!{2n}{n\in\mathbb{Z}}, -\qquad +\quad \delimpair\{|\}!{2n}{n\in\mathbb{Z}}, -\qquad -\delimpair\{{[.];}\}!{2n}{n\in\mathbb{Z}} +\quad +\delimpair\{{*;}\}!{2n}{n\in\mathbb{Z}} \] conditional set, alternative layouts with variable size: \[ \delimpair\{{[m]|}\}*{2n}{n\in\mathbb{Z}\big.}, -\qquad +\quad \delimpair\{{[b]|}\}*{2n}{n\in\mathbb{Z}\big.}, -\qquad +\quad +\delimpair\{{[i]|}\}*{2n}{n\in\mathbb{Z}\big.}, +\quad \delimpair\{{[p]|}\}*{2n}{n\in\mathbb{Z}\big.}, -\qquad +\quad \delimpair\{|\}*{2n}{n\in\mathbb{Z}\big.}, -\qquad -\delimpair\{{[.];}\}*{2n}{n\in\mathbb{Z}\big.} +\quad +\delimpair\{{*;}\}*{2n}{n\in\mathbb{Z}\big.} \] % \end{macrocode} delimiter definition: % \begin{macrocode} -\newcommand{\comm}{\delimpair[{[.],}]} +\newcommand{\comm}{\delimpair[{*,}]} \[ \comm!{\comm{A}{B}}{C} +\comm!{\comm{B}{C}}{A} @@ -1024,7 +1484,7 @@ delimiter definition: alternative representation: % \begin{macrocode} -\renewcommand{\comm}{\delimpair[{[.];}]} +\renewcommand{\comm}{\delimpair[{*;}]} \[ \comm!{\comm{A}{B}}{C} +\comm!{\comm{B}{C}}{A} @@ -1033,6 +1493,31 @@ alternative representation: \] % \end{macrocode} +display individual delimiters of a set: +% \begin{macrocode} +\renewcommand{\braket}{\delimpair<|>} +\[ +\braket{A}{B} +\to \braket( A \braket| B \braket), +\quad +\braket*( A\big. \braket*| B_{} \braket*), +\quad +\braket^1( A \braket^3| B \braket^2) +\] +% \end{macrocode} + +placing indices before a bracket +(does not work in variable-size mode because +the final size is not available for the enclosed expressions): +% \begin{macrocode} +\DeclareMathDelimiterSet{\quadindex}[5] + {\selectdeliml.^{#2}_{#3}\mathord{}\selectdelim[o][ + {#1}\selectdelim[o]]^{#4}_{#5}\selectdelimr.} +\[ +\quadindex^2{\frac{x}{y}}{1}{2}{3}{4} +\] +% \end{macrocode} + % end of document body: % \begin{macrocode} \end{document} @@ -1057,6 +1542,7 @@ alternative representation: % if not yet present. % \textsf{amsmath} is used for basic delimiter size functionality. % \textsf{keyval} is used for extended options processing. +% % \begin{macrocode} \RequirePackage{amsmath} \RequirePackage{keyval} @@ -1067,6 +1553,7 @@ alternative representation: % % The package has some boolean \textsf{keyval} options % which can be set to |true| or |false|. +% % \begin{macrocode} \newif\ifdlm@std\dlm@stdtrue \newif\ifdlm@ext\dlm@extfalse @@ -1083,7 +1570,7 @@ alternative representation: % \end{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \paragraph{Internal Definitions.} +% \paragraph{Improved Size Adjustments.} % % Overwrite the \textsf{amsmath} command |\bBigg@| % to select the size according to the present math style @@ -1105,102 +1592,269 @@ alternative representation: \fi % \end{macrocode} -% Define punctuation marks (|\bigp|, etc.) -% and binary operators (|\bigb|, etc.). +% Define punctuation marks (|\bigp|, etc.), +% binary operators (|\bigb|, etc.) +% and inner class (|\bigi|, etc.). % % \begin{macrocode} -\newcommand{\bigp}{\mathpunct\big} -\newcommand{\Bigp}{\mathpunct\Big} -\newcommand{\biggp}{\mathpunct\bigg} -\newcommand{\Biggp}{\mathpunct\Bigg} -\newcommand{\bigb}{\mathbin\big} -\newcommand{\Bigb}{\mathbin\Big} -\newcommand{\biggb}{\mathbin\bigg} -\newcommand{\Biggb}{\mathbin\Bigg} +\providecommand{\bigp}{\mathpunct\big} +\providecommand{\Bigp}{\mathpunct\Big} +\providecommand{\biggp}{\mathpunct\bigg} +\providecommand{\Biggp}{\mathpunct\Bigg} +\providecommand{\bigb}{\mathbin\big} +\providecommand{\Bigb}{\mathbin\Big} +\providecommand{\biggb}{\mathbin\bigg} +\providecommand{\Biggb}{\mathbin\Bigg} +\providecommand{\bigi}{\mathinner\big} +\providecommand{\Bigi}{\mathinner\Big} +\providecommand{\biggi}{\mathinner\bigg} +\providecommand{\Biggi}{\mathinner\Bigg} % \end{macrocode} -% Define size selectors for standard size (|dlm@norm|), -% variable size (|dlm@var|). +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \paragraph{Size Adjustment Definitions.} +% +% The macro |\dlm@setvar| enables variable size, +% the macro |\dlm@setsize| sets a fixed size. +% Delimiter sizes are implented by |\dlm@big@|. +% The macro |\kerndelim| adds some kerning proportional +% to the chosen fixed size of the delimiters +% (the spacing is merely an approximation, +% and it does not actually scale for flexible size). +% +% \begin{macrocode} +\newlength\delimsize +\newcommand{\dlm@setvar}{\let\dlm@ifvar\@firstoftwo\delimsize1.5\big@size} +\newcommand{\dlm@setsize}[1]{\let\dlm@ifvar\@secondoftwo% + \delimsize#1\big@size\advance\delimsize by\big@size\delimsize0.5\delimsize} +\newcommand{\dlm@setabssize}[1]{\let\dlm@ifvar\@secondoftwo\delimsize#1\relax} +\newcommand{\dlm@big@}[1]{{\mathchoice% + {\dlm@big@choice{\displaystyle}{1}{#1}}% + {\dlm@big@choice{\textstyle}{1}{#1}}% + {\dlm@big@choice{\scriptstyle}{0.7}{#1}}% + {\dlm@big@choice{\scriptscriptstyle}{0.5}{#1}}}} +\newcommand{\dlm@big@choice}[3]{\@mathmeasure\z@{\nulldelimiterspace\z@}% + {#1\left#3\vcenter to#2\delimsize{}\right.}\box\z@} +\newcommand{\kerndelim}[1]{{\delimsize#1\delimsize% + \mkern\muexpr1.2mu*\delimsize/\big@size\relax}} +% \end{macrocode} + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \paragraph{Math Classes Processing.} +% +% Define class selectors for fixed and unadjusted sizes. % % \begin{macrocode} +\newcommand{\dlm@big}[2]{\dlm@plain{#1}{\dlm@big@#2}} +\newcommand{\dlm@plain}[2]{\dlm@class{#1}{\dlm@phantom{#2}}} \newcommand{\dlm@class}[1]{\csname dlm@class@#1\endcsname} -\newcommand{\dlm@class@}{} -\newcommand{\dlm@class@l}{\mathopen} -\newcommand{\dlm@class@r}{\mathclose} -\newcommand{\dlm@class@o}{\mathopen} -\newcommand{\dlm@class@c}{\mathclose} -\newcommand{\dlm@class@m}{\mathrel} -\newcommand{\dlm@class@p}{\mathpunct} -\newcommand{\dlm@class@b}{\mathbin} -\newcommand{\dlm@norm}[1]{\dlm@class{#1}\bBigg@{0.0}} -\newcommand{\dlm@big}[1]{\dlm@class{#1}\big} -\newcommand{\dlm@Big}[1]{\dlm@class{#1}\Big} -\newcommand{\dlm@bigg}[1]{\dlm@class{#1}\bigg} -\newcommand{\dlm@Bigg}[1]{\dlm@class{#1}\Bigg} +\let\dlm@class@\@firstofone +\let\dlm@class@o\mathord +\let\dlm@class@c\mathord +\let\dlm@class@p\mathpunct +\let\dlm@class@i\mathinner +\let\dlm@class@b\mathbin +\let\dlm@class@m\mathrel +% \end{macrocode} + +% Define class selector for variable size. +% The macro |\dlm@var@null| removes the extra space from +% variable-size null delimiters +% (|\left.|, |\middle.| and |\right.| apply the value +% of |\nulldelimiterspace| only at the end of math processing, +% even across blocks). +% The macro |\dlm@var@kern| applies kerning unless in the script styles. +% +% \begin{macrocode} +\newcommand{\dlm@var@null}[1]{\if.#1\kern-\nulldelimiterspace\fi} +\newcommand{\dlm@var@kern}[1]{\nonscript\mkern#1} \newcommand{\dlm@var}[1]{\csname dlm@var@#1\endcsname} -\newcommand{\dlm@var@}[1]{\middle#1} -\newcommand{\dlm@var@l}[1]{\mathopen{}\mathclose\bgroup\left#1} -\newcommand{\dlm@var@r}[1]{\right#1\egroup} -\newcommand{\dlm@var@o}[1]{\mathopen{}\middle#1\mathopen{}} -\newcommand{\dlm@var@c}[1]{\mathclose{}\middle#1\mathclose{}} -\newcommand{\dlm@var@m}[1]{\mathrel{}\middle#1\mathrel{}} -\newcommand{\dlm@var@p}[1]{\middle#1\mathpunct{}} -\newcommand{\dlm@var@b}[1]{\mathbin{}{}\mkern-\medmuskip% - \middle#1\mkern-\medmuskip{}\mathbin{}} +\newcommand{\dlm@var@}[1]{\dlm@var@null#1\middle#1} +\let\dlm@var@o\dlm@var@ +\let\dlm@var@c\dlm@var@ +\newcommand{\dlm@var@p}[1]{\dlm@var@#1\dlm@var@kern\thinmuskip} +\newcommand{\dlm@var@i}[1]{\dlm@var@kern\thinmuskip% + \dlm@var@#1\dlm@var@kern\thinmuskip} +\newcommand{\dlm@var@b}[1]{\dlm@var@kern\medmuskip% + \dlm@var@#1\dlm@var@kern\medmuskip} +\newcommand{\dlm@var@m}[1]{\dlm@var@kern\thickmuskip% + \dlm@var@#1\dlm@var@kern\thickmuskip} +% \end{macrocode} + +% Definitions for selecting outer math class +% |\mathopen|+|\mathclose| vs. |\mathinner|. +% +% \begin{macrocode} +\newcommand{\dlm@open@i}{\mathinner{}\mathclose{}\mathopen} +\newcommand{\dlm@close@i}{\mathclose{}\mathopen{}\mathinner} +\newcommand{\dlm@inner@oc}{\mathopen{}\mathclose} +\newcommand{\dlm@enclose@openclose}{% + \let\dlm@open\mathopen\let\dlm@close\mathclose\let\dlm@inner\dlm@inner@oc} +\newcommand{\dlm@enclose@inner}{% + \let\dlm@open\dlm@open@i\let\dlm@close\dlm@close@i\let\dlm@inner\mathinner} +% \end{macrocode} + +% Definitions for selecting inline vs. block insertion. +% +% \begin{macrocode} +\newcommand{\dlm@inline@l}[1]{\dlm@open{#1}} +\newcommand{\dlm@inline@r}[1]{\dlm@close{#1}} +\newcommand{\dlm@block@l}[1]{\dlm@inner\bgroup\mathopen{#1}} +\newcommand{\dlm@block@r}[1]{\mathclose{#1}\egroup} +\newcommand{\dlm@enclose@inline}{% + \let\dlm@class@l\dlm@inline@l\let\dlm@class@r\dlm@inline@r} +\newcommand{\dlm@enclose@block}{% + \let\dlm@class@l\dlm@block@l\let\dlm@class@r\dlm@block@r} +% \end{macrocode} + +% Opening and closing definitions. +% +% \begin{macrocode} +\newcommand{\dlm@plain@l}[1]{\dlm@class@l{\dlm@phantom{#1}}} +\newcommand{\dlm@plain@r}[1]{\dlm@class@r{\dlm@phantom{#1}}} +\newcommand{\dlm@big@l}[1]{\dlm@plain@l{\dlm@big@#1}} +\newcommand{\dlm@big@r}[1]{\dlm@plain@r{\dlm@big@#1}} +\newcommand{\dlm@var@l}[1]{\dlm@inner\bgroup\dlm@var@null#1\left#1} +\newcommand{\dlm@var@r}[1]{\right#1\dlm@var@null#1\egroup} +\newcommand{\dlm@var@pl}[1]{\dlm@var@l.\mathopen{#1}} +\newcommand{\dlm@var@pr}[1]{\mathclose{#1}\dlm@var@r.} +% \end{macrocode} + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \paragraph{Delimiter Storage.} +% +% Macros for storing and retrieving delimiter types using global registers. +% +% \begin{macrocode} +\newcommand{\dlm@reg@save@init}[1]{% + \xdef#1{\delimsize\the\delimsize}\ifx\dlm@inner\mathinner% + \expandafter\gdef\expandafter#1\expandafter{#1\dlm@enclose@inner}\fi} +\newcommand{\dlm@reg@save}[2]{% + \expandafter\dlm@reg@save@init\csname dlm@reg@init@#1\endcsname% + \expandafter\gdef\csname dlm@reg@sel@#1\endcsname{#2}} +\newcommand{\dlm@reg@init}[1]{\csname dlm@reg@init@#1\endcsname} +\newcommand{\dlm@reg@sel}[1]{\csname dlm@reg@sel@#1\endcsname} % \end{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \paragraph{Optional Size Argument Processing.} +% \paragraph{Flags Processing.} % -% Parse the optional argument following |\delim|\ldots\ -% commands to specify the size of delimiters. -% If the next character in line begins a group (`|{|') it is assumed that -% there is no optional argument. -% Otherwise the selected size is written to |\dlm@arg|. -% Unspecified or unknown sizes default to normal size. -% Finally, execute the code passed as an explicit argument to |\dlm@parsesize|. +% The macro |\parsedelimflags| parses the optional argument(s) +% following |\delim|\ldots\ commands to adjust the presentation. +% Parsing is terminated if the next character in line begins a group (`|{|') +% and the delimiter set is composed by executing argument |#1|. +% A size flag is stored and parsing continues. +% A delimiter selector flag immediately displays the desired delimiter +% by executing argument |#2|. +% Unknown flags produce an error message. % % \begin{macrocode} -\newcommand{\dlm@parsesize}[1]{\@ifnextchar\bgroup% - {\dlm@parsesize@{#1}{0}}{\dlm@parsesize@{#1}}} -\newcommand{\dlm@parsesize@}[2]{\let\dlm@arg\dlm@norm% - \if0#2\let\dlm@arg\dlm@norm\fi% - \if1#2\let\dlm@arg\dlm@big\fi% - \if+#2\let\dlm@arg\dlm@big\fi% - \if!#2\let\dlm@arg\dlm@big\fi% - \if2#2\let\dlm@arg\dlm@Big\fi% - \if3#2\let\dlm@arg\dlm@bigg\fi% - \if4#2\let\dlm@arg\dlm@Bigg\fi% - \if*#2\let\dlm@arg\dlm@var\fi% - #1} +\newcommand{\parsedelimflags}{\dlm@setsize{0.6}\let\dlm@phantom\@firstofone% + \dlm@enclose@openclose\dlm@enclose@inline\dlm@parseflags} +\newcommand{\dlm@parseflags}[2]{% + \@ifnextchar\bgroup{#1}{\dlm@parseflag{#1}{#2}}} +\newcommand{\dlm@parseflag}[3]{\begingroup% + \ifcsname dlm@parseflag@\string#3\endcsname% + \def\dlm@do{\csname dlm@parseflag@\string#3\endcsname{#1}{#2}}\else% + \def\dlm@do{\PackageError{delimset}% + {unknown delimiter set flag `\string#3'}{}#1}% + \fi\expandafter\endgroup\dlm@do} +\newcommand{\dlm@parsedef}[3]{% + \expandafter\def\csname dlm@parseflag@\string#1\endcsname ##1##2#2{#3}} % \end{macrocode} +% % Note that the delimited expression should be contained within a group % such that nested delimiters will not overwrite the outer size definition. +% Flags to adjust size. +% Note that sizes 0 and 1 amount to 0.96 and 1.2 times +% the current empty math box height. +% +% \begin{macrocode} +\dlm@parsedef{!}{}{\dlm@setsize{1}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{+}{}{\dlm@setsize{1}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{0}{}{\dlm@setsize{0.6}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{1}{}{\dlm@setsize{1}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{2}{}{\dlm@setsize{2}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{3}{}{\dlm@setsize{3}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{4}{}{\dlm@setsize{4}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{^}{#3}{\dlm@setsize{#3}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{_}{#3}{\dlm@setabssize{#3}\dlm@parseflags{#1}{#2}} +\dlm@parsedef{*}{}{\dlm@setvar\dlm@parseflags{#1}{#2}} +% \end{macrocode} + +% Flags to select individual delimiters. +% +% \begin{macrocode} +\dlm@parsedef{(}{}{\def\selecteddelim{0}#2} +\dlm@parsedef{|}{}{\def\selecteddelim{1}#2} +\dlm@parsedef{,}{}{\def\selecteddelim{1}#2} +\dlm@parsedef{)}{}{\def\selecteddelim{9}#2} +\dlm@parsedef{?}{#3}{\def\selecteddelim{#3}#2} +% \end{macrocode} + +% Flags to access registers. +% +% \begin{macrocode} +\dlm@parsedef{[}{}{\dlm@reg@save{.}{#2}\def\selecteddelim{0}#2} +\dlm@parsedef{]}{}{\dlm@reg@init{.}\def\selecteddelim{9}\dlm@reg@sel{.}} +\dlm@parsedef{>}{#3}{\dlm@reg@save{#3}{#2}} +\dlm@parsedef{<}{#3}{\dlm@reg@init{#3}\dlm@parseflags% + {\PackageError{delimset}{must select delimiter}{}}{\dlm@reg@sel{#3}}} +% \end{macrocode} + +% Further flags. +% +% \begin{macrocode} +\dlm@parsedef{.}{}{#1} +\dlm@parsedef{:}{}{\dlm@enclose@block\dlm@parseflags{#1}{#2}} +\dlm@parsedef{'}{}{\dlm@enclose@openclose\dlm@parseflags{#1}{#2}} +\dlm@parsedef{"}{}{\dlm@enclose@inner\dlm@parseflags{#1}{#2}} +\dlm@parsedef{-}{}{\let\dlm@phantom\phantom\dlm@parseflags{#1}{#2}} +% \end{macrocode} + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \paragraph{Size Selection.} +% \paragraph{Delimiter Display.} % -% The command |\selectdelim| reproduces the delimiter in the second argument -% using the math class given in the first argument -% using the previously selected size stored in |\dlm@arg|. -% It appends the class identifier to the command stored in |\dlm@arg| -% and calls the latter with the delimiter as the argument. +% The command |\selectdelim| reproduces the delimiter in argument |#2| +% using the math class given in argument |#1| and the previously stored size. % If the class identifier is `|.|', just return the delimiter argument as is. +% The commands |\selectdeliml| and |\selectdelimr| +% implement the left and right delimiter classes, respectively. +% % \begin{macrocode} -\newcommand{\selectdelim}[2][]{\if.#1#2\else\dlm@arg{#1}#2\fi} +\newcommand{\selectdelim}[1][]{\begingroup\def\dlm@do{\@ifstar{\dlm@plain{#1}}% + {\dlm@ifvar{\dlm@var{#1}}{\dlm@big{#1}}}}% + \if.#1\let\dlm@do\@empty\fi\expandafter\endgroup\dlm@do} +\newcommand{\selectdeliml}{\@ifstar% + {\dlm@ifvar\dlm@var@pl\dlm@plain@l}{\dlm@ifvar\dlm@var@l\dlm@big@l}} +\newcommand{\selectdelimr}{\@ifstar% + {\dlm@ifvar\dlm@var@pr\dlm@plain@r}{\dlm@ifvar\dlm@var@r\dlm@big@r}} % \end{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \paragraph{Declaration of New Delimiter Commands.} % -% Declares a new set of delimiters as the macro `|\|\emph{name}'. -% This macro checks for an optional size argument and stores it in |\dlm@arg|. +% The macro |\DeclareMathDelimiterSet| declares a new set of delimiters +% as the macro `|\|\emph{name}'. +% This macro checks for optional flags and stores the desired size. % It then passes on to a second macro `|\dlm@dcl@|\emph{name}', % which takes the actual code. +% If the flags select an individual delimiter, +% the macro `|\dlm@sel@|\emph{name}' is called instead. +% The latter macro should be defined via |\DeclareMathDelimiterSel| +% such that it produces the desired delimiter number |\selecteddelim|. +% % \begin{macrocode} \newcommand{\DeclareMathDelimiterSet}[1]{\expandafter\dlm@declare% \csname dlm@dcl@\expandafter\@gobble\string#1\endcsname{#1}} -\def\dlm@declare#1#2{\newcommand{#2}{\dlm@parsesize{#1}}\newcommand{#1}} +\def\dlm@declare#1#2{\expandafter\dlm@declare@% + \csname dlm@sel@\expandafter\@gobble\string#2\endcsname{#1}{#2}} +\def\dlm@declare@#1#2#3{\newcommand{#3}{\parsedelimflags{#2}{#1}}% + \providecommand{#1}{}\newcommand{#2}} +\newcommand{\DeclareMathDelimiterSel}[3]{\expandafter\def% + \csname dlm@sel@\expandafter\@gobble\string#1\endcsname% + {\ifcase\selecteddelim#2\else#3\fi}} % \end{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1212,29 +1866,51 @@ alternative representation: % are processed \emph{before} the optional size modifier. % % |\delim| is used for a single delimited expression. +% % \begin{macrocode} -\newcommand{\delim}[2] - {\dlm@parsesize{\dlm@dcl@delim{#1}{#2}}} -\newcommand{\dlm@dcl@delim}[3] - {\selectdelim[l]#1{#3}\selectdelim[r]#2} +\newcommand{\delim}[2]{% + \parsedelimflags{\dlm@dcl@delim{#1}{#2}}{\dlm@sel@delim{#1}{#2}}} +\newcommand{\dlm@dcl@delim}[3]{% + \selectdeliml#1{#3}\selectdelimr#2} +\newcommand{\dlm@sel@delim}[2]{\ifcase\selecteddelim\selectdeliml#1% + \else\selectdelimr#2\fi} % \end{macrocode} % |\delimpair| is used for two delimited expressions separated % by an intermediate delimiter. +% % \begin{macrocode} -\newcommand{\delimpair}[3] - {\dlm@parsesize{\dlm@dcl@delimpair{#1}{#2}{#3}}} -\newcommand{\dlm@dcl@delimpair}[5] - {\selectdelim[l]#1{#4}\selectdelim#2{#5}\selectdelim[r]#3} +\newcommand{\delimpair}[3]{% + \parsedelimflags{\dlm@dcl@delimpair{#1}{#2}{#3}}% + {\dlm@sel@delimpair{#1}{#2}{#3}}} +\newcommand{\dlm@dcl@delimpair}[5]{% + \selectdeliml#1{#4}\selectdelim#2{#5}\selectdelimr#3} +\newcommand{\dlm@sel@delimpair}[3]{\ifcase\selecteddelim\selectdeliml#1% + \or\selectdelim#2\else\selectdelimr#3\fi} % \end{macrocode} % |\delimtriple| is used for three delimited expressions separated % by two intermediate delimiters. +% % \begin{macrocode} -\newcommand{\delimtriple}[4] - {\dlm@parsesize{\dlm@dcl@delimtriple{#1}{#2}{#3}{#4}}} -\newcommand{\dlm@dcl@delimtriple}[7] - {\selectdelim[l]#1{#5}\selectdelim#2{#6}\selectdelim#3{#7}\selectdelim[r]#4} +\newcommand{\delimtriple}[4]{% + \parsedelimflags{\dlm@dcl@delimtriple{#1}{#2}{#3}{#4}}% + {\dlm@sel@delimtriple{#1}{#2}{#3}{#4}}} +\newcommand{\dlm@dcl@delimtriple}[7]{% + \selectdeliml#1{#5}\selectdelim#2{#6}\selectdelim#3{#7}\selectdelimr#4} +\newcommand{\dlm@sel@delimtriple}[4]{\ifcase\selecteddelim\selectdeliml#1% + \or\selectdelim#2\or\selectdelim#3\else\selectdelimr#4\fi} +% \end{macrocode} + +% |\usedelim| retrieves a stored delimiter type. +% The argument `|]|' immediately closes the delimiter set +% using the default register. +% Otherwise the desired register must be followed +% by the delimiter selection flag. +% +% \begin{macrocode} +\newcommand{\usedelim}{\@ifnextchar]{\parsedelimflags{}{}}{\parsedelimflags% + {\PackageError{delimset}{must select delimiter}{}}{}<}} % \end{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1243,17 +1919,18 @@ alternative representation: % Define some common delimiters (by |providecommand| so as not to % overwrite previously existing commands). % This code is activated only if the package option |stddef| is set to |true|. +% % \begin{macrocode} \ifdlm@std \providecommand{\brk}[1][r]{\begingroup\def\dlm@use{\delim()}% - \if r#1 \def\dlm@use{\delim()}\fi% - \if s#1 \def\dlm@use{\delim[]}\fi% - \if c#1 \def\dlm@use{\delim\{\}}\fi% - \if a#1 \def\dlm@use{\delim<>}\fi% + \if r#1\def\dlm@use{\delim()}\fi% + \if s#1\def\dlm@use{\delim[]}\fi% + \if c#1\def\dlm@use{\delim\{\}}\fi% + \if a#1\def\dlm@use{\delim<>}\fi% \expandafter\endgroup\dlm@use} \providecommand{\eval}[1][v]{\begingroup\def\dlm@use{\delim.\rvert}% - \if v#1 \def\dlm@use{\delim.\rvert}\fi% - \if s#1 \def\dlm@use{\delim[]}\fi% + \if v#1\def\dlm@use{\delim.\rvert}\fi% + \if s#1\def\dlm@use{\delim[]}\fi% \expandafter\endgroup\dlm@use} \providecommand{\abs}{\delim\lvert\rvert} \providecommand{\norm}{\delim\lVert\rVert} @@ -1265,24 +1942,33 @@ alternative representation: % % Define some extended delimiters. % This code is activated only if the package option |extdef| is set to |true|. +% % \begin{macrocode} \ifdlm@ext -\providecommand{\pair}{\delimpair({[.],})} +\providecommand{\pair}{\delimpair({[p]*,})} \providecommand{\set}{\delim\{\}} \providecommand{\setcond}{\delimpair\{|\}} -\providecommand{\intv}[1][c]{\begingroup\def\dlm@use{\delimpair[{[.],}]}% - \if c#1 \def\dlm@use{\delimpair[{[.],}]}\fi% - \if l#1 \def\dlm@use{\delimpair]{[.],}]}\fi% - \if r#1 \def\dlm@use{\delimpair[{[.],}[}\fi% - \if o#1 \def\dlm@use{\delimpair]{[.],}[}\fi% +\providecommand{\intv}[1][c]{\begingroup% + \def\dlm@use{\delimpair[{[p]*,}]}% + \if c#1\def\dlm@use{\delimpair[{[p]*,}]}\fi% + \if l#1\def\dlm@use{\delimpair]{[p]*,}]}\fi% + \if r#1\def\dlm@use{\delimpair[{[p]*,}[}\fi% + \if o#1\def\dlm@use{\delimpair]{[p]*,}[}\fi% \expandafter\endgroup\dlm@use} \providecommand{\avg}{\delim<>} \providecommand{\corr}{\delim<>} -\providecommand{\comm}{\delimpair[{[.],}]} -\providecommand{\acomm}{\delimpair\{{[.],}\}} +\providecommand{\comm}{\delimpair[{[p]*,}]} +\providecommand{\acomm}{\delimpair\{{[p]*,}\}} \providecommand{\bra}{\delim<|} \providecommand{\ket}{\delim|>} \providecommand{\braket}{\delimpair<|>} +\providecommand{\lfrac}[1][]{\begingroup% + \def\dlm@use{\delimpair./.}% + \if r#1\def\dlm@use{\delimpair(/)}\fi% + \if s#1\def\dlm@use{\delimpair[/]}\fi% + \if c#1\def\dlm@use{\delimpair\{/\}}\fi% + \if a#1\def\dlm@use{\delimpair</>}\fi% + \expandafter\endgroup\dlm@use} \fi % \end{macrocode} diff --git a/macros/latex/contrib/delimset/delimset.ins b/macros/latex/contrib/delimset/delimset.ins index daf870b5ff..68e41a7242 100644 --- a/macros/latex/contrib/delimset/delimset.ins +++ b/macros/latex/contrib/delimset/delimset.ins @@ -2,7 +2,7 @@ \input docstrip.tex \keepsilent -% delimset.ins Copyright (C) 2016-2018 Niklas Beisert +% delimset.ins Copyright (C) 2016-2024 Niklas Beisert % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -14,7 +14,7 @@ \preamble -Copyright (C) 2016-2018 Niklas Beisert +Copyright (C) 2016-2024 Niklas Beisert This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/macros/latex/contrib/delimset/delimset.pdf b/macros/latex/contrib/delimset/delimset.pdf Binary files differindex b964bea59d..734ebf01db 100644 --- a/macros/latex/contrib/delimset/delimset.pdf +++ b/macros/latex/contrib/delimset/delimset.pdf diff --git a/macros/latex/contrib/passopt/README.md b/macros/latex/contrib/passopt/README.md index 3b819c42b4..f8eb8f4c43 100644 --- a/macros/latex/contrib/passopt/README.md +++ b/macros/latex/contrib/passopt/README.md @@ -1,5 +1,5 @@ # The `passopt` package -Passing options to packages or classes (v1.01) +Passing options to packages or classes (v1.01a) ## Abstract `passopt` allow reset the global options of a loaded macro package or document class, or to change the position of the pre-passed options in the list to the right. diff --git a/macros/latex/contrib/passopt/passopt.pdf b/macros/latex/contrib/passopt/passopt.pdf Binary files differindex d6c865c112..ce6e437c65 100644 --- a/macros/latex/contrib/passopt/passopt.pdf +++ b/macros/latex/contrib/passopt/passopt.pdf diff --git a/macros/latex/contrib/passopt/passopt.sty b/macros/latex/contrib/passopt/passopt.sty index b5c24ed9a3..d74c698d27 100644 --- a/macros/latex/contrib/passopt/passopt.sty +++ b/macros/latex/contrib/passopt/passopt.sty @@ -8,7 +8,7 @@ % The latest version of this license is in % https://creativecommons.org/licenses/by/4.0/legalcode \NeedsTeXFormat{LaTeX2e}[2021/11/15] -\ProvidesExplPackage{passopt}{2024/07/15}{1.01} +\ProvidesExplPackage{passopt}{2024/07/17}{1.01a} {Passing options to packages or classes} \cs_generate_variant:Nn \tl_if_blank:nTF { v } diff --git a/macros/latex/contrib/passopt/passopt.tex b/macros/latex/contrib/passopt/passopt.tex index 76568eeff1..fb4473e356 100644 --- a/macros/latex/contrib/passopt/passopt.tex +++ b/macros/latex/contrib/passopt/passopt.tex @@ -5,8 +5,8 @@ \setcnltx { package = passopt, - version = v1.01, - date = 2024/07/15, + version = v1.01a, + date = 2024/07/17, authors = Qu Yi, info = Passing options to packages or classes, email = toquyi@163.com, @@ -42,7 +42,6 @@ \setlist{nosep,topsep = \smallskipamount} \setlist[description,1]{leftmargin = \parindent} \setlist[itemize,1]{leftmargin = *} -\deffootnote{2em}{1em}{\llap{\color{red}\thefootnotemark.\space}} \makeatother \begin{document} @@ -60,7 +59,7 @@ For a developer, there are some cases where packages and classes may load other In the example above, the list of options that the \pkg*{mypackage} macro package ends up executing is \fbox{\code{opt1,opt2=A,opt3}}. If you wish to \textcolor{red}{disable} the pre-enabled options or place the newly enabled options to the \textcolor{red}{right} of the list (last executed), then you need to modify the code of the load command in the package or class file, but this is not recommended for public sharing. Therefore, this macro package provides commands to reset the options and change the order of the new options. \section{User commands} -Four commands are provided to set the options to be passed later, all of which are \textcolor{red}{locally} assigned. +Four commands are provided to set the options to be passed later, all of which are \textcolor{red}{locally} assigned. Subsequent loading of the macro package is not must required due to the hook mechanism used to modify the list of options. \begin{commands} \command{SetOptionsToPackage}[\sarg\marg{options list}\marg{package}] Passes options to the macro package, the location of the passed options is to the right of the options used when loading the macro package. If an asterisk parameter is used, only the passed options were ultimately retained. @@ -95,7 +94,7 @@ Thanks Jonathan P. Spratte for the improvement suggestions. \appendix \begin{changelog}[simple] \begin{version}[v = 1.01,date = 2024/07/15] - \item Synchronization modifier for lists of \code{@raw@opt@} and \code{opt@}. + \item Synchronized modification for lists of \code{@raw@opt@} and \code{opt@}. \item Options that are set are expanded once rather than fully expanded. \end{version} \end{changelog} diff --git a/macros/luatex/generic/luamplib/NEWS b/macros/luatex/generic/luamplib/NEWS index 57324895f8..c97974fc20 100644 --- a/macros/luatex/generic/luamplib/NEWS +++ b/macros/luatex/generic/luamplib/NEWS @@ -1,8 +1,13 @@ History of the luamplib package +2024/07/17 2.34.0 + * support transparency group with metafun format + * fix regarding default value in circular fading mode + * fix regarging the scope of graphics state + 2024/07/14 2.33.1 * refactor the manual, including some minor items undocumented so far - * improve fade routine to get possibly smaller pdf file + * improve fading routine to get possibly smaller pdf file 2024/07/08 2.33.0 * provide a new metapost operator 'withfademethod' and related macros, diff --git a/macros/luatex/generic/luamplib/luamplib.dtx b/macros/luatex/generic/luamplib/luamplib.dtx index a7e44a487e..44500e957c 100644 --- a/macros/luatex/generic/luamplib/luamplib.dtx +++ b/macros/luatex/generic/luamplib/luamplib.dtx @@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luamplib.drv}% - [2024/07/14 v2.33.1 Interface for using the mplib library]% + [2024/07/17 v2.34.0 Interface for using the mplib library]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -153,7 +153,7 @@ See source file '\inFileName' for licencing and contact information. % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\ % Current Maintainer: Kim Dohyun\\ % Support: \url{https://github.com/lualatex/luamplib}} -% \date{2024/07/14 v2.33.1} +% \date{2024/07/17 v2.34.0} % % \maketitle % @@ -219,14 +219,14 @@ See source file '\inFileName' for licencing and contact information. % the lua table containing metapost code % which will % be automatically inserted at the beginning and ending of each metapost code chunk. -% \begin{verbatim} +%\begin{verbatim} % \everymplib{ beginfig(0); } % \everyendmplib{ endfig; } % \begin{mplibcode} % % beginfig/endfig not needed % draw fullcircle scaled 1cm; % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % % \paragraph{\cs{mplibsetformat\{plain\char"7C metafun\}}} % There are (basically) two formats for metapost: \emph{plain} and @@ -236,15 +236,24 @@ See source file '\inFileName' for licencing and contact information. % % \textsc{n.b.} As \emph{metafun} is such a complicated format, % we cannot support all the functionalities producing special effects provided by \emph{metafun}. -% At least, however, transparency (actually opacity) and shading (gradient colors) effects +% At least, however, transparency (actually opacity), transparency group, and shading (gradient colors) % are fully supported, % and outlinetext is supported by our own alternative |mpliboutlinetext| (see below \S\,1.2). % % \leavevmode\llap{\textcolor{red}{☞}\kern1.2\parindent}\relax % Among these, transparency is so simple that you can apply it to an object, % even with the \emph{plain} format, -% just by appending |withprescript "tr_transparency=|\emph{<number>}|"|, where -% $0 \le \hbox{\emph{<number>}} \le 1$, to the sentence. +% just by appending |withprescript "tr_transparency=|\emph{<number>}|"| to the sentence. +% ($0 \le \hbox{\emph{<number>}} \le 1$) +% +% As for transparency group, the current \emph{metafun} document \S\,8.8 is not correct. +% The true syntax is: +%\begin{verbatim} +% draw <picture>|<path> asgroup <string> +%\end{verbatim} +% where \emph{<string>} should be |""| (empty), |"isolated"|, |"knockout"|, or |"isolated,knockout"|. +% Beware that currently many of the PDF rendering applications, except Adobe Acrobat Reader, +% cannot properly render the isolated or knockout effect. % % One thing worth mentioning about shading is: % when a color expression is given in string type, @@ -277,14 +286,14 @@ See source file '\inFileName' for licencing and contact information. % each figure box can be freely moved horizontally or vertically. % Also, a box number can be assigned to a figure box, allowing it to be % reused later. -% \begin{verbatim} +%\begin{verbatim} % \mplibcode % verbatimtex \moveright 3cm etex; beginfig(0); ... endfig; % verbatimtex \leavevmode etex; beginfig(1); ... endfig; % verbatimtex \leavevmode\lower 1ex etex; beginfig(2); ... endfig; % verbatimtex \endgraf\moveright 1cm etex; beginfig(3); ... endfig; % \endmplibcode -% \end{verbatim} +%\end{verbatim} % \textsc{n.b.} \cs{endgraf} should be used instead of \cs{par} inside % |verbatimtex ... etex|. % @@ -292,7 +301,7 @@ See source file '\inFileName' for licencing and contact information. % between |beginfig()| and |endfig| will be inserted % after flushing out the metapost figure. % As shown in the example below, |VerbatimTeX()| is a synonym of |verbatimtex| |...| |etex|. -% \begin{verbatim} +%\begin{verbatim} % \mplibcode % D := sqrt(2)**7; % beginfig(0); @@ -301,7 +310,7 @@ See source file '\inFileName' for licencing and contact information. % endfig; % \endmplibcode % diameter: \Dia bp. -% \end{verbatim} +%\end{verbatim} % % By contrast, % when |\mpliblegacybehavior{disabled}| is declared, any @@ -309,7 +318,7 @@ See source file '\inFileName' for licencing and contact information. % sequentially one by one. % So, some \TeX\ code in |verbatimtex ... etex| will have effects on % following |btex| |...| |etex| codes. -% \begin{verbatim} +%\begin{verbatim} % \begin{mplibcode} % beginfig(0); % draw btex ABC etex; @@ -318,7 +327,7 @@ See source file '\inFileName' for licencing and contact information. % draw btex GHI etex shifted (2cm,0); % bold face % endfig; % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % % \paragraph{\cs{mplibtextextlabel\{enable\char"7C disable\}}} % Default: |disable|. @@ -347,11 +356,11 @@ See source file '\inFileName' for licencing and contact information. % in \LaTeX{} |mplibcode| environment. % Plain \TeX\ users also can use this functionality. % The syntax for \LaTeX\ is: -% \begin{verbatim} +%\begin{verbatim} % \begin{mplibcode}[instanceName] % % some mp code % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % The behavior is as follows. % \begin{itemize} % \item All the variables and functions are shared @@ -371,10 +380,10 @@ See source file '\inFileName' for licencing and contact information. % Unnamed \cs{everymplib} affects not only those instances with no name, % but also those with name but with no corresponding \cs{everymplib}. % The syntax is: -% \begin{verbatim} +%\begin{verbatim} % \everymplib[instanceName]{...} % \everyendmplib[instanceName]{...} -% \end{verbatim} +%\end{verbatim} % % \paragraph{\cs{mplibglobaltextext\{enable\char"7C disable\}}} % Default: |disable|. @@ -382,8 +391,8 @@ See source file '\inFileName' for licencing and contact information. % it was necessary to declare \cs{mplibglobaltextext\{enable\}} in advance. % But from v2.27, this is implicitly enabled when \cs{mplibcodeinherit} % is enabled. -% This optinal command still remains mostly for backward compatibility. -% \begin{verbatim} +% This optional command still remains mostly for backward compatibility. +%\begin{verbatim} % \mplibcodeinherit{enable} % %\mplibglobaltextext{enable} % \everymplib{ beginfig(0);} \everyendmplib{ endfig;} @@ -395,7 +404,7 @@ See source file '\inFileName' for licencing and contact information. % \mplibcode % currentpicture := pic scaled 2; % \endmplibcode -% \end{verbatim} +%\end{verbatim} % % \paragraph{\cs{mplibverbatim\{enable\char"7C disable\}}} % Default: |disable|. @@ -409,14 +418,14 @@ See source file '\inFileName' for licencing and contact information. % Besides other \TeX\ commands, \cs{mpdim} is specially allowed % in the mplibcode environment. This feature is inpired by \textsf{gmp} package authored by % Enrico Gregorio. Please refer to the manual of \textsf{gmp} package for details. -% \begin{verbatim} +%\begin{verbatim} % \begin{mplibcode} % beginfig(1) % draw origin--(.6\mpdim{\linewidth},0) withpen pencircle scaled 4 % dashed evenly scaled 4 withcolor \mpcolor{orange}; % endfig; % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % % \paragraph{\cs{mpcolor[...]\{...\}}} % With \cs{mpcolor} command, color names or expressions of @@ -435,7 +444,7 @@ See source file '\inFileName' for licencing and contact information. % we also provide unexpandable \TeX\ macros |\mpfig ... \endmpfig| and its starred version % |\mpfig* ... \endmpfig| to save typing toil. % The former is roughly the same as follows: -% \begin{verbatim} +%\begin{verbatim} % \begin{mplibcode}[@mpfig] % beginfig(0) % token list declared by \everymplib[@mpfig] @@ -443,24 +452,24 @@ See source file '\inFileName' for licencing and contact information. % token list declared by \everyendmplib[@mpfig] % endfig; % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % and the starred version is roughly the same as follows: -% \begin{verbatim} +%\begin{verbatim} % \begin{mplibcode}[@mpfig] % ... % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % In these macros |\mpliblegacybehavior{disable}| % is forcibly declared. % Again, as both share the same instance name, metapost codes are inherited among them. % A simple example: -% \begin{verbatim} +%\begin{verbatim} % \everymplib[@mpfig]{ drawoptions(withcolor .5[red,white]); } % \mpfig* input boxes \endmpfig % \mpfig % circleit.a(btex Box 1 etex); drawboxed(a); % \endmpfig -% \end{verbatim} +%\end{verbatim} % The instance name (default: |@mpfig|) can be changed by redefining % \cs{mpfiginstancename}, after which a new mplib instance will start and % code inheritance too will begin anew. |\let\mpfiginstancename\empty| will @@ -523,10 +532,10 @@ See source file '\inFileName' for licencing and contact information. % to a MetaPost color expression, that can be used anywhere color expression is expected % as well as after the |withcolor| operator. % For instance: -% \begin{verbatim} +%\begin{verbatim} % color col; % col := mplibtexcolor "olive!50"; -% \end{verbatim} +%\end{verbatim} % But the result may vary in its color model (gray/rgb/cmyk) % according to the given \TeX\ color. (Spot colors are forced to % cmyk model, so this operator is not recommended for spot colors.) @@ -538,11 +547,11 @@ See source file '\inFileName' for licencing and contact information. % |mplibgraphictext| is a metapost operator, the effect of which is similar to that of % \ConTeXt's |graphictext| or our own |mpliboutlinetext| (see below). % However the syntax is somewhat different. -% \begin{verbatim} +%\begin{verbatim} % mplibgraphictext "Funny" % fakebold 2.3 % fontspec option % drawcolor .7blue fillcolor "red!50" % color expressions -% \end{verbatim} +%\end{verbatim} % |fakebold|, |drawcolor| and |fillcolor| are optional; % default values are |2|, |"black"| and |"white"| respectively. % When the color expressions are given in string type, they are regarded as @@ -567,13 +576,13 @@ See source file '\inFileName' for licencing and contact information. % From v2.30, we provide a new metapost operator |mplibglyph|, which returns a metapost picture % containing outline paths of a glyph in opentype, truetype or type1 fonts. % When a type1 font is specified, metapost primitive |glyph| will be called. -% \begin{verbatim} +%\begin{verbatim} % mplibglyph 50 of \fontid\font % slot 50 of current font % mplibglyph "Q" of "TU/TeXGyrePagella(0)/m/n/10" % font csname % mplibglyph "Q" of "texgyrepagella-regular.otf" % raw filename % mplibglyph "Q" of "Times.ttc(2)" % subfont number % mplibglyph "Q" of "SourceHanSansK-VF.otf[Regular]" % instance name -% \end{verbatim} +%\end{verbatim} % Both arguments before and after of ``|of|'' can be either a number or a string. % Number arguments are regarded as a glyph slot (GID) and a font id number, repectively. % String argument at the left side is regarded as a glyph name in the font or a unicode character. @@ -601,12 +610,12 @@ See source file '\inFileName' for licencing and contact information. % From v2.31, a new metapost operator |mpliboutlinetext| is available, which mimicks % metafun's |outlinetext|. So the syntax is the same as metafun's. See the metafun % manual \S\,8.7 (|texdoc metafun|). A simple example: -% \begin{verbatim} +%\begin{verbatim} % draw mpliboutlinetext.b ("$\sqrt{2+\alpha}$") % (withcolor \mpcolor{red!50}) % (withpen pencircle scaled .2 withcolor red) % scaled 2 ; -% \end{verbatim} +%\end{verbatim} % After the process, |mpliboutlinepic[]| % and |mpliboutlinenum| will be preserved as global variables; % |mpliboutlinepic[1]| \ldots{} |mpliboutlinepic[mpliboutlinenum]| @@ -624,7 +633,7 @@ See source file '\inFileName' for licencing and contact information. % the given path with a tiling pattern of the |<name>| % by replicating it horizontally and vertically. % An example: -% \begin{verbatim} +%\begin{verbatim} % \mppattern{mypatt} % or \begin{mppattern}{mypatt} % [ % options: see below % xstep = 10, ystep = 12, @@ -645,7 +654,7 @@ See source file '\inFileName' for licencing and contact information. % withpattern "mypatt" % withpostscript "evenodd" ; % \endmpfig -% \end{verbatim} +%\end{verbatim} % % The available options are listed in Table~\ref{tab:mppatternoptions}. % \begin{table} @@ -681,7 +690,7 @@ See source file '\inFileName' for licencing and contact information. % Option |colored=false| (|coloured| is a synonym of |colored|) will generate an uncolored pattern which shall have no color at all. % Uncolored pattern will be painted later by the color of a metapost object. % An example: -% \begin{verbatim} +%\begin{verbatim} % \begin{mppattern}{pattuncolored} % [ % colored = false, @@ -710,7 +719,7 @@ See source file '\inFileName' for licencing and contact information. % endfor % endfig; % \end{mplibcode} -% \end{verbatim} +%\end{verbatim} % % \paragraph{\texttt{... withfademethod ...}, and related macros} % |withfademethod| is a metapost operator which makes the color of an object gradiently transparent. @@ -743,7 +752,7 @@ See source file '\inFileName' for licencing and contact information. % explicitly control the bounding box. % \end{description} % An example: -% \begin{verbatim} +%\begin{verbatim} % \mpfig % picture mill; % mill = btex \includegraphics[width=100bp]{mill} etex; @@ -754,7 +763,7 @@ See source file '\inFileName' for licencing and contact information. % withfadeopacity (1, 0) % ; % \endmpfig -% \end{verbatim} +%\end{verbatim} % % \subsection{Lua} % @@ -778,7 +787,7 @@ See source file '\inFileName' for licencing and contact information. % as documented in Lua\TeX{} manual \S\,11.2.8.4 (|texdoc luatex|). % The following will print |false|, |3.0|, |MetaPost| and % the knots and the cyclicity of the path |unitsquare|, consecutively. -% \begin{verbatim} +%\begin{verbatim} % \begin{mplibcode}[instance1] % boolean b; b = 1 > 2; % numeric n; n = 3; @@ -796,13 +805,13 @@ See source file '\inFileName' for licencing and contact information. % print(k, type(v)=='table' and table.concat(v,' ') or v) % end % } -% \end{verbatim} +%\end{verbatim} % % \paragraph{Lua function \texttt{luamplib.process\_mplibcode}} % Users can execute a MetaPost code chunk from Lua side by using this function: -% \begin{verbatim} +%\begin{verbatim} % luamplib.process_mplibcode (<string> metapost code, <string> instance name) -% \end{verbatim} +%\end{verbatim} % The second argument cannot be absent, but can be an empty string (|""|) which % means that it has no instance name. % @@ -841,8 +850,8 @@ See source file '\inFileName' for licencing and contact information. luatexbase.provides_module { name = "luamplib", - version = "2.33.1", - date = "2024/07/14", + version = "2.34.0", + date = "2024/07/17", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -1655,7 +1664,7 @@ luamplib.shadecolor = function (str) if res:find" cs " or res:find"@pdf.obj" then -- spot color shade: l3 only % \end{macrocode} % An example of spot color shading: -% \begin{verbatim} +%\begin{verbatim} % \documentclass{article} % \usepackage{luamplib} % \mplibsetformat{metafun} @@ -1701,9 +1710,9 @@ luamplib.shadecolor = function (str) % endfig; % \end{mplibcode} % \end{document} -% \end{verbatim} +%\end{verbatim} % another one: user-defined DeviceN colorspace -% \begin{verbatim} +%\begin{verbatim} % \DocumentMetadata{ } % \documentclass{article} % \usepackage{luamplib} @@ -1731,7 +1740,7 @@ luamplib.shadecolor = function (str) % ; % \endmpfig % \end{document} -% \end{verbatim} +%\end{verbatim} % \begin{macrocode} run_tex_code({ [[\color_export:nnN{]], str, [[}{backend}\mplib_@tempa]], @@ -2509,7 +2518,15 @@ vardef mplibtransformmatrix (text e) = & "}"); enddef; primarydef p withfademethod s = - p withprescript "mplibfadetype=" & s + if picture p: + image( + draw p; + draw center p withprescript "mplibfadestate=stop"; + ) + else: + p withprescript "mplibfadestate=stop" + fi + withprescript "mplibfadetype=" & s withprescript "mplibfadebbox=" & decimal xpart llcorner p & ":" & decimal ypart llcorner p & ":" & @@ -2863,6 +2880,7 @@ else "\\special{pdf:obj @MPlibCS<<>>}", "\\special{pdf:obj @MPlibPt<<>>}", } + pdfetcs.resadded = { } end % \end{macrocode} @@ -2909,23 +2927,29 @@ local function add_extgs_resources (on, new) end if not pdfmode and not pdfmanagement and not is_defined(pdfetcs.pgfextgs) then texsprint"\\special{pdf:put @resources <</ExtGState @MPlibTr>>}" + pdfetcs.resadded.ExtGState = "@MPlibTr" end return key end local function do_preobj_TR(object,prescript) if object.postscript == "collect" then return end local opaq = prescript and prescript.tr_transparency - local on if opaq then + local key, on, os, new local mode = prescript.tr_alternative or 1 - mode = transparancy_modes[tonumber(mode)] - local os, new = format("<</BM /%s/ca %.3f/CA %.3f/AIS false>>",mode,opaq,opaq) - on, new = update_pdfobjs(os) - local key = add_extgs_resources(on,new) - start_pdf_code() - pdf_literalcode("/%s gs",key) + mode = transparancy_modes[tonumber(mode)] or mode + for i,v in ipairs{ {mode,opaq},{"Normal",1} } do + mode, opaq = v[1], v[2] + os = format("<</BM /%s/ca %.3f/CA %.3f/AIS false>>",mode,opaq,opaq) + on, new = update_pdfobjs(os) + key = add_extgs_resources(on,new) + if i == 1 then + pdf_literalcode("/%s gs",key) + else + return format("/%s gs",key) + end + end end - return on end % \end{macrocode} @@ -2981,6 +3005,7 @@ local function sh_pdfpageresources(shtype,domain,colorspace,ca,cb,coordinates,st end if not pdfmode and not pdfmanagement then texsprint"\\special{pdf:put @resources <</Shading @MPlibSh>>}" + pdfetcs.resadded.Shading = "@MPlibSh" end return on end @@ -3131,6 +3156,64 @@ end % \begin{macrocode} pdfetcs.patterns = { } local patterns = pdfetcs.patterns +local function gather_resources (do_pattern, optres) + local t = { } + local names = {"ExtGState","ColorSpace","Shading"} + if do_pattern then + names[#names+1] = "Pattern" + end + if pdfmode then + if pdfmanagement then + for _,v in ipairs(names) do + local pp = get_macro(format("g__pdfdict_/g__pdf_Core/Page/Resources/%s_prop",v)) + if pp and pp:find"__prop_pair" then + t[#t+1] = format("/%s %s 0 R", v, ltx.pdf.object_id("__pdf/Page/Resources/"..v)) + end + end + else + local res = pdfetcs.getpageres() or "" + run_tex_code[[\mplibtmptoks\expandafter{\the\pdfvariable pageresources}]] + res = (res .. texgettoks'mplibtmptoks'):explode() + res = tableconcat(res," "):explode"/+" + for _,v in ipairs(res) do + if do_pattern or not v:find"Pattern" and not optres:find(v) then + t[#t+1] = "/" .. v + end + end + end + else + if pdfmanagement then + for _,v in ipairs(names) do + local pp = get_macro(format("g__pdfdict_/g__pdf_Core/Page/Resources/%s_prop",v)) + if pp and pp:find"__prop_pair" then + run_tex_code { + "\\mplibtmptoks\\expanded{{", + format("/%s \\csname pdf_object_ref:n\\endcsname{__pdf/Page/Resources/%s}",v,v), + "}}", + } + t[#t+1] = texgettoks'mplibtmptoks' + end + end + elseif is_defined(pdfetcs.pgfextgs) then + run_tex_code ({ + "\\mplibtmptoks\\expanded{{", + "\\ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs\\fi", + "\\ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces\\fi", + do_pattern and "\\ifpgf@sys@pdf@patterns@exists /Pattern @pgfpatterns \\fi" or "", + "}}", + }, catat11) + t[#t+1] = texgettoks'mplibtmptoks' + elseif do_pattern then + for _,v in ipairs(names) do + local vv = pdfetcs.resadded[v] + if vv then + t[#t+1] = format("/%s %s", v, vv) + end + end + end + end + return t +end function luamplib.registerpattern ( boxid, name, opts ) local box = texgetbox(boxid) local wd = format("%.3f",box.width/factor) @@ -3163,27 +3246,10 @@ function luamplib.registerpattern ( boxid, name, opts ) format("/YStep %s", opts.ystep or hd), format("/Matrix [%s %s %s]", opts.matrix or "1 0 0 1", opts.xshift or 0, opts.yshift or 0), } + local optres = opts.resources or "" + local t = gather_resources(false, optres) + optres = optres .. tableconcat(t) if pdfmode then - local optres, t = opts.resources or "", { } - if pdfmanagement then - for _,v in ipairs{"ExtGState","ColorSpace","Shading"} do - local pp = get_macro(format("g__pdfdict_/g__pdf_Core/Page/Resources/%s_prop",v)) - if pp and pp:find"__prop_pair" then - t[#t+1] = format("/%s %s 0 R", v, ltx.pdf.object_id("__pdf/Page/Resources/"..v)) - end - end - else - local res = pdfetcs.getpageres() or "" - run_tex_code[[\mplibtmptoks\expandafter{\the\pdfvariable pageresources}]] - res = (res .. texgettoks'mplibtmptoks'):explode() - res = tableconcat(res," "):explode"/+" - for _,v in ipairs(res) do - if not v:find"Pattern" and not optres:find(v) then - t[#t+1] = "/" .. v - end - end - end - optres = optres .. tableconcat(t) if opts.bbox then attr[#attr+1] = format("/BBox [%s]", opts.bbox) end @@ -3192,29 +3258,6 @@ function luamplib.registerpattern ( boxid, name, opts ) else local objname = "@mplibpattern"..name local metric = format("bbox %s", opts.bbox or format("0 0 %s %s",wd,hd)) - local optres, t = opts.resources or "", { } - if pdfmanagement then - for _,v in ipairs{"ExtGState","ColorSpace","Shading"} do - local pp = get_macro(format("g__pdfdict_/g__pdf_Core/Page/Resources/%s_prop",v)) - if pp and pp:find"__prop_pair" then - run_tex_code { - "\\mplibtmptoks\\expanded{{", - format("/%s \\csname pdf_object_ref:n\\endcsname{__pdf/Page/Resources/%s}",v,v), - "}}", - } - t[#t+1] = texgettoks'mplibtmptoks' - end - end - elseif is_defined(pdfetcs.pgfextgs) then - run_tex_code ({ - "\\mplibtmptoks\\expanded{{", - "\\ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs\\fi", - "\\ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces\\fi", - "}}", - }, catat11) - t[#t+1] = texgettoks'mplibtmptoks' - end - optres = optres .. tableconcat(t) texsprint { [[\ifvmode\nointerlineskip\fi]], format([[\hbox to0pt{\vbox to0pt{\hsize=\wd %i\vss\noindent]], boxid), -- force horiz mode? @@ -3251,6 +3294,7 @@ local function pattern_colorspace (cs) end if not pdfmode and not pdfmanagement and not is_defined(pdfetcs.pgfcolorspace) then texsprint"\\special{pdf:put @resources <</ColorSpace @MPlibCS>>}" + pdfetcs.resadded.ColorSpace = "@MPlibCS" end return on end @@ -3305,6 +3349,7 @@ local function do_preobj_PAT(object, prescript) end if not pdfmode and not pdfmanagement and not is_defined(pdfetcs.pgfpattern) then texsprint"\\special{pdf:put @resources <</Pattern @MPlibPt>>}" + pdfetcs.resadded.Pattern = "@MPlibPt" end patt.done = true end @@ -3313,22 +3358,29 @@ end % % Fading % \begin{macrocode} +pdfetcs.fading = { } local function do_preobj_FADE (object, prescript) - if object.postscript == "collect" then return end local fd_type = prescript and prescript.mplibfadetype - if not fd_type then return end + local fd_stop = prescript and prescript.mplibfadestate + if not fd_type then + return fd_stop -- returns "stop" (if picture) or nil + end local bbox = prescript.mplibfadebbox:explode":" - local width, height = bbox[3]-bbox[1], bbox[4]-bbox[2] - local vec = prescript.mplibfadevector - vec = vec and vec:explode":" - or fd_type == "linear" and {bbox[1], bbox[2], bbox[3], bbox[2]} -- left to right - or {width/2, height/2, width/2, height/2} -- center for both circles local dx, dy = -bbox[1], -bbox[2] - bbox = format("0 0 %f %f", bbox[3]+dx, bbox[4]+dy) + local vec = prescript.mplibfadevector; vec = vec and vec:explode":" + if not vec then + if fd_type == "linear" then + vec = {bbox[1], bbox[2], bbox[3], bbox[2]} -- left to right + else + local centerx, centery = (bbox[1]+bbox[3])/2, (bbox[2]+bbox[4])/2 + vec = {centerx, centery, centerx, centery} -- center for both circles + end + end local coords = { vec[1]+dx, vec[2]+dy, vec[3]+dx, vec[4]+dy } if fd_type == "linear" then coords = format("%f %f %f %f", tableunpack(coords)) elseif fd_type == "circular" then + local width, height = bbox[3]-bbox[1], bbox[4]-bbox[2] local radius = (prescript.mplibfaderadius or "0:"..math.sqrt(width^2+height^2)/2):explode":" tableinsert(coords, 3, radius[1]) tableinsert(coords, radius[2]) @@ -3336,6 +3388,7 @@ local function do_preobj_FADE (object, prescript) else err("unknown fading method '%s'", fd_type) end + bbox = format("0 0 %f %f", bbox[3]+dx, bbox[4]+dy) fd_type = fd_type == "linear" and 2 or 3 local opaq = (prescript.mplibfadeopacity or "1:0"):explode":" local on, os, new @@ -3360,7 +3413,76 @@ local function do_preobj_FADE (object, prescript) local key = add_extgs_resources(on,new) start_pdf_code() pdf_literalcode("/%s gs", key) - return on + if fd_stop then return "standalone" end + return "start" +end + +% \end{macrocode} +% +% Transparency Group +% \begin{macrocode} +pdfetcs.tr_group = { } +local function do_preobj_GRP (object, prescript) + local grstate = prescript and prescript.gr_state + if not grstate then return end + local trgroup = pdfetcs.tr_group + if grstate == "start" then + trgroup.isolated, trgroup.knockout = false, false + for _,v in ipairs(prescript.gr_type:explode",+") do + trgroup[v] = true + end + local p = object.path + trgroup.bbox = { + math.min(p[1].x_coord, p[2].x_coord, p[3].x_coord, p[4].x_coord), + math.min(p[1].y_coord, p[2].y_coord, p[3].y_coord, p[4].y_coord), + math.max(p[1].x_coord, p[2].x_coord, p[3].x_coord, p[4].x_coord), + math.max(p[1].y_coord, p[2].y_coord, p[3].y_coord, p[4].y_coord), + } + put2output[[\begingroup\setbox\mplibscratchbox\hbox\bgroup]] + elseif grstate == "stop" then + local llx,lly,urx,ury = tableunpack(trgroup.bbox) + local grattr = format("/Group<</S/Transparency/I %s/K %s>>",trgroup.isolated,trgroup.knockout) + local res = tableconcat(gather_resources(true)) + put2output(tableconcat{ + "\\egroup", + format("\\wd\\mplibscratchbox %fbp", urx-llx), + format("\\ht\\mplibscratchbox %fbp", ury-lly), + "\\dp\\mplibscratchbox 0pt", + }) + if pdfmode then + put2output(tableconcat{ + "\\saveboxresource type 2 attr{/Type/XObject/Subtype/Form/FormType 1", + format("/BBox[%f %f %f %f]", llx,lly,urx,ury), + grattr, "} resources{", res, "}\\mplibscratchbox", + [[\setbox\mplibscratchbox\hbox{\useboxresource\lastsavedboxresourceindex}]], + [[\wd\mplibscratchbox 0pt\ht\mplibscratchbox 0pt\dp\mplibscratchbox 0pt]], + [[\box\mplibscratchbox\endgroup]], + }) + else + trgroup.cnt = (trgroup.cnt or 0) + 1 + local objname = format("@mplibtrgr%s", trgroup.cnt) + put2output(tableconcat{ + "\\special{pdf:bxobj ", objname, " bbox ", format("%f %f %f %f", llx,lly,urx,ury), "}", + "\\unhbox\\mplibscratchbox", + "\\special{pdf:put @resources <<", res, ">>}", + "\\special{pdf:exobj <<", grattr, ">>}", + "\\special{pdf:uxobj ", objname, "}\\endgroup", + }) + end + end + return grstate +end + +local function stop_special_effects(fade,opaq,over) + if fade then -- fading + stop_pdf_code() + end + if opaq then -- opacity + pdf_literalcode(opaq) + end + if over then -- color + put2output"\\special{pdf:ec}" + end end % \end{macrocode} @@ -3488,11 +3610,11 @@ function luamplib.flush (result,flusher) % luamplib silently ignores this invalid figure for those % that do not contain |beginfig ... endfig|. (issue \#70) % Original code of ConTeXt general was: -% \begin{verbatim} +%\begin{verbatim} % -- invalid % pdf_startfigure(fignum,0,0,0,0) % pdf_stopfigure() -% \end{verbatim} +%\end{verbatim} % \begin{macrocode} else % \end{macrocode} @@ -3510,7 +3632,7 @@ function luamplib.flush (result,flusher) local object = objects[o] local objecttype = object.type % \end{macrocode} -% The following 7 lines are part of |btex...etex| patch. +% The following 8 lines are part of |btex...etex| patch. % Again, colors are processed at this stage. % \begin{macrocode} local prescript = object.prescript @@ -3518,6 +3640,7 @@ function luamplib.flush (result,flusher) local cr_over = do_preobj_CR(object,prescript) -- color local tr_opaq = do_preobj_TR(object,prescript) -- opacity local fading_ = do_preobj_FADE(object,prescript) -- fading + local trgroup = do_preobj_GRP(object,prescript) -- transparency group if prescript and prescript.mplibtexboxid then put_tex_boxes(object,prescript) elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then --skip @@ -3543,7 +3666,7 @@ function luamplib.flush (result,flusher) pdf_literalcode("%f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) pdf_textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth) stop_pdf_code() - else + elseif not trgroup and fading_ ~= "stop" then local evenodd, collect, both = false, false, false local postscript = object.postscript if not object.istext then @@ -3569,10 +3692,7 @@ function luamplib.flush (result,flusher) else % \end{macrocode} % Removed from ConTeXt general: color stuff. -% Added instead : shading stuff % \begin{macrocode} - local shade_no = do_preobj_SH(object,prescript) -- shading - local pattern_ = do_preobj_PAT(object,prescript) -- pattern local ml = object.miterlimit if ml and ml ~= miterlimit then miterlimit = ml @@ -3599,6 +3719,11 @@ function luamplib.flush (result,flusher) pdf_literalcode("[] 0 d") dashed = false end +% \end{macrocode} +% Added : shading and pattern +% \begin{macrocode} + local shade_no = do_preobj_SH(object,prescript) -- shading + local pattern_ = do_preobj_PAT(object,prescript) -- pattern local path = object.path local transformed, penwidth = false, 1 local open = path and path[1].left_type and path[#path].right_type @@ -3688,21 +3813,29 @@ function luamplib.flush (result,flusher) end end % \end{macrocode} -% Added to ConTeXt general: post-object color and shading stuff. +% Added to ConTeXt general: post-object colors and shading stuff. +% We should beware the |q ... Q| scope. % \begin{macrocode} if shade_no then -- shading pdf_literalcode("W n /MPlibSh%s sh Q",shade_no) end end end - if fading_ then -- fading - stop_pdf_code() - end - if tr_opaq then -- opacity - stop_pdf_code() + if fading_ == "start" then + pdfetcs.fading.specialeffects = {fading_, tr_opaq, cr_over} + elseif trgroup == "start" then + pdfetcs.tr_group.specialeffects = {fading_, tr_opaq, cr_over} + elseif fading_ == "stop" then + local se = pdfetcs.fading.specialeffects + if se then stop_special_effects(se[1], se[2], se[3]) end + elseif trgroup == "stop" then + local se = pdfetcs.tr_group.specialeffects + if se then stop_special_effects(se[1], se[2], se[3]) end + else + stop_special_effects(fading_, tr_opaq, cr_over) end - if cr_over then -- color - put2output"\\special{pdf:ec}" + if fading_ or trgroup then -- extgs resetted + miterlimit, linecap, linejoin, dashed = -1, -1, -1, false end end end @@ -3761,7 +3894,7 @@ end \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2024/07/14 v2.33.1 mplib package for LuaTeX] + [2024/07/17 v2.34.0 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi diff --git a/macros/luatex/generic/luamplib/luamplib.pdf b/macros/luatex/generic/luamplib/luamplib.pdf Binary files differindex a8bea32e1a..d59201ed00 100644 --- a/macros/luatex/generic/luamplib/luamplib.pdf +++ b/macros/luatex/generic/luamplib/luamplib.pdf diff --git a/macros/luatex/generic/luamplib/test-luamplib-latex.tex b/macros/luatex/generic/luamplib/test-luamplib-latex.tex index 50a5778870..b2f2f63cb7 100644 --- a/macros/luatex/generic/luamplib/test-luamplib-latex.tex +++ b/macros/luatex/generic/luamplib/test-luamplib-latex.tex @@ -287,7 +287,7 @@ draw mpliboutlinetext.b ("$\displaystyle\frac{1}{1-x^2}$") endfor endfor \endmpfig -\par +\par\leavevmode \mpfig picture mill; mill = btex \includegraphics[width=100bp]{mill} etex; draw mill; @@ -299,6 +299,33 @@ draw mpliboutlinetext.b ("$\displaystyle\frac{1}{1-x^2}$") withfadeopacity (1, 0) ; \endmpfig +\par +\def\test#1{% + \mpfig + fill unitsquare shifted -center unitsquare scaled 200 + withshademethod "linear" + withshadecolors (.3[red,white], .3[blue,white]) + ; + label( btex MetaPost etex scaled 3, origin) ; + draw image( + fill fullcircle scaled 100 shifted 25left + withcolor .8white + withtransparency (2,1) + ; + fill fullcircle scaled 100 shifted 25right + withcolor .8white + withtransparency (2,1) + ; + ) + asgroup "#1" + withtransparency (1,.5) + ; + currentpicture := currentpicture scaled 3/4; + \endmpfig +}% +\hbox{\test{isolated,knockout}\,\test{isolated}\vbox to\MPheight{\vss\hbox{~isolated}\vss}}% +\hbox{\test{knockout}\,\test{}}% +\hbox to\MPwidth{\hss knockout\hss}% \tracingcommands0 \vskip 2\baselineskip diff --git a/macros/luatex/generic/luamplib/test-luamplib-plain.tex b/macros/luatex/generic/luamplib/test-luamplib-plain.tex index dde6fbfb10..622932ca10 100644 --- a/macros/luatex/generic/luamplib/test-luamplib-plain.tex +++ b/macros/luatex/generic/luamplib/test-luamplib-plain.tex @@ -280,6 +280,20 @@ draw mpliboutlinetext.b ("$\overbrace{x+\cdots+x}^k$") endfor endfor \endmpfig +\mpfig +fill fullcircle scaled 125 withcolor 2/3[blue,white]; +draw image( + draw (left--right) rotated 45 scaled 50 + withpen pencircle scaled 20 + ; + draw (left--right) rotated -45 scaled 50 + withpen pencircle scaled 20 + ; + ) + asgroup "" + withprescript "tr_transparency=.3" + ; +\endmpfig \tracingcommands0 \vskip 2\baselineskip diff --git a/macros/luatex/latex/tango/README b/macros/luatex/latex/tango/README index 1d62186710..014ae456a2 100644 --- a/macros/luatex/latex/tango/README +++ b/macros/luatex/latex/tango/README @@ -1,12 +1,19 @@ Tango is a LaTeX document class for use by mathematics teachers. It requires lualatex, some LaTeX packages (see the complete documentation for details), and a recent version of LaTeX (see paragraph 4 below). +Author: Michel Bovani <Michel.Bovani@icloud.com> +Tango Web Page: https://tango.mathriochka.net + 1 Versions history -This version number is 0.7.2 +0.8.0 (2024-07-17) This version +New: Language complete support for +french, english, british, american, canadian, australian, newzealand, german, ngerman, naustrian, nswissgerman, italian, spanish. + +0.7.2 (2024-07-12) New in this version • correction of the countername in subparagraph definition for titlesec. • fix incorrect vertical space in the \exo command. -0.7.1 First release +0.7.1 First release (2024-07-08) 2 License Tango is released under Latex public project licence (LPPL), version 1.3c @@ -14,7 +21,7 @@ See https://www.latex-project.org/lppl/lppl-1-3c/ 3 Installation Just put the tango.cls file in a latex directory of a texmf tree, for example: -TEXMF/tex/latex/tango/tango.cls +TEXMF/tex/lualatex/tango/tango.cls 4 Usage \documentclass[<options>]{tango} diff --git a/macros/luatex/latex/tango/doc/tango-en.pdf b/macros/luatex/latex/tango/doc/tango-en.pdf Binary files differindex 3447817ff1..d7969f1cb5 100644 --- a/macros/luatex/latex/tango/doc/tango-en.pdf +++ b/macros/luatex/latex/tango/doc/tango-en.pdf diff --git a/macros/luatex/latex/tango/doc/tango-en.tex b/macros/luatex/latex/tango/doc/tango-en.tex index 99a6399dce..bf7995ef17 100644 --- a/macros/luatex/latex/tango/doc/tango-en.tex +++ b/macros/luatex/latex/tango/doc/tango-en.tex @@ -26,8 +26,9 @@ \renewcommand{\arraystretch}{1.1} \title{\textcolor{ColorOne}{\floweroneleft}\,The tango document class\,\textcolor{ColorOne}{\floweroneright}} -\author{\href{mailto:michel.bovani@icloud.com}{Michel \textsc{Bovani}}} -\date{\today\\v. 0.7.2} +\author{\href{mailto:michel.bovani@icloud.com}{Michel \textsc{Bovani}}\\ +Tango web page: \href{https://tango.mathriochka.net}{https://tango.mathriochka.net}} +\date{\today\\v. 0.8.0} {\sffamily \maketitle @@ -63,13 +64,11 @@ Default values are in bold red. Bold options marked with a \TO{\textbf{star*}} c \hline\endhead \hline\multicolumn{2}{r}{\emph{Continued next page}}\endfoot \hline\endlastfoot -\TO{french}&\TO{french=true/\DO{false}}. Adaptation to the French language and reserved names for the tango class (theorem gives \emph{e.g.} théorème). Mandatory use for French-speaking users. This option is also passed to the babel package.\\ + \hline -\TO{<language options>}& Tango will pass other language options to the \TO{babel} package. Note that -\begin{itemize} -\item Only English and French languages are fully implemented. -\item Even English-speaking people must pass a language option (\TO{english, british, UKenglish, USenglish} or \TO{american}) for \TO{babel} to the tango class. -\end{itemize} +\TO{% +french, english, british, american, canadian, australian, newzealand, german, ngerman, naustrian, nswissgerman, italian, spanish}.& Tango will transmit all language options to the \TO{babel} package. However, the translation of specific names used by tango (such as theorem, exercise, etc.) is only guaranteed for the languages listed opposite. Please note that even English speakers must \emph{imperatively} pass a language option to tango. + See section~\ref{lang} below.\\ \hline \TO{no-statement}&\TO{no-statement=true/\DO{false}}. The \TO{thm}, \TO{defin}, \TO{lem}, \TO{coro}, \TO{propo} environments (for theorems, definitions, lemmas, corollaries, propositions) are defined by default. The no-statement option allows you to define them later, on request (see \verb=\newstatement= and \verb=\renewstatement= commands in section~\ref{st-section} page~\pageref{st-section}).\\ @@ -262,8 +261,7 @@ Provided commands are: \section{Language settings}\label{lang} A language option \emph{must} be passed to the \TO{babel} package via the tango class: this is true \emph{even} for English-speaking people. A class error message will be generated otherwise. If you ignore this message you will get no hyphenation patterns at all! -For now, only the English and French languages are fully supported. With other languages, you benefit from the \TO{babel} facilities, but the \enquote{tango words} will remain defined by: -\begin{verbatim} +Tango also has some reserved words, which are (when an english language option is passed to tango):\begin{verbatim} \newcommand\TgoTheoremName{Theorem} \newcommand\TgoDefinitionName{Definition} \newcommand\TgoPropositionName{Proposition} @@ -276,7 +274,19 @@ For now, only the English and French languages are fully supported. With other l \newcommand\TgoExercisesSubsectionName{Exercises} \newcommand\TgoExercisesSectionName{Exercises} \end{verbatim} -If you want to use tango with a new language, here is what you can do: + +Although any language option recognized by babel will (in principle) be taken into account as soon as it is passed to tango, the translation of these reserved words only happens for the following languages: +\begin{itemize} +\item\TO{french}; +\item\TO{english, british, american, canadian, australian, newzealand}; +\item\TO{german, ngerman, naustrian, nswissgerman}; +\item\TO{italian}; +\item\TO{spanish}. +\end{itemize} + +Other languages benefit from babel's facilities, but tango's reserved words are not translated. +So here's what concerned users can do. + \begin{enumerate} \item Translate these names in your language (for now it is done only for the french language), using \verb+\renewcommand+. \item (Better) Mail me all the necessary information (at least babel language option used and your translation of the tango names) and I will adapt the tango class to your language. diff --git a/macros/luatex/latex/tango/doc/tango-fr.pdf b/macros/luatex/latex/tango/doc/tango-fr.pdf Binary files differindex 08767d9155..a4438d58de 100644 --- a/macros/luatex/latex/tango/doc/tango-fr.pdf +++ b/macros/luatex/latex/tango/doc/tango-fr.pdf diff --git a/macros/luatex/latex/tango/doc/tango-fr.tex b/macros/luatex/latex/tango/doc/tango-fr.tex index 06cd61f378..1ed1a70abf 100644 --- a/macros/luatex/latex/tango/doc/tango-fr.tex +++ b/macros/luatex/latex/tango/doc/tango-fr.tex @@ -26,8 +26,9 @@ \renewcommand{\arraystretch}{1.1} \title{\textcolor{ColorOne}{\floweroneleft}\,La classe de documents tango\,\textcolor{ColorOne}{\floweroneright}} -\author{\href{mailto:michel.bovani@icloud.com}{Michel \textsc{Bovani}}} -\date{\today\\v. 0.7.2} +\author{\href{mailto:michel.bovani@icloud.com}{Michel \textsc{Bovani}}\\ +Page internet de tango: \href{https://tango.mathriochka.net}{https://tango.mathriochka.net}} +\date{\today\\v. 0.8.0} {\sffamily \maketitle @@ -59,14 +60,9 @@ Les valeurs par défaut sont présentées en bleu gras. Les options en gras, mar \hline\endhead \hline\multicolumn{2}{r}{\emph{Voir page suivante}}\endfoot \hline\endlastfoot -\hline\endlastfoot -\TO{french}&\TO{french=true/\DO{false}}. Adaptation à la langue française et noms définis par la classe tango (\frquote{Theorem} donne par exemple \frquote{Théorème}). Usage indispensable pour les utilisateurs de langue française. Cette option est également passée au package babel.\\ -\hline -\TO{<options de langue>}& Tango transmettra au package \TO{babel} toutes les options de langue. Notez bien que : -\begin{itemize} -\item Seuls l'anglais et le français sont complètement implémentés. -\item Même les locuteurs anglais doivent passer une option de langue pour \TO{babel} (\TO{english, british, UKenglish, USenglish} ou \TO{american}) à la classe tango. -\end{itemize} +\TO{% +french, english, british, american, canadian, australian, newzealand, german, ngerman, naustrian, nswissgerman, italian, spanish}.& Tango transmettra au package \TO{babel} toutes les options de langue. En revanche, la traduction des noms spécifiques employés par tango (comme théorème, exercice, etc.) n'est assurée que pour les langues listées ci-contre. Notez bien que même les locuteurs anglais doivent \emph{impérativement} passer une option de langue à tango. + Voir la section~\ref{lang} plus loin.\\ \hline \TO{no-statement}&\TO{no-statement=true/\DO{false}}. Des environnements \TO{thm}, \TO{defin}, \TO{lem}, \TO{coro}, \TO{propo} (pour présenter les théorèmes, définitions, lemmes, corollaires et propositions) sont définis par défaut. L'option \DO{no-statement} vous permet de définir ces environnements vous-même avec une configuration plus personnelle (voir les commandes \verb=\newstatement= and \verb=\renewstatement= dans la section~\ref{st-section} page~\pageref{st-section}).\\ @@ -275,24 +271,8 @@ Les commandes proposées par tango sont : \section{Sélection de la langue}\label{lang} Il est impératif de passer une option de langue à babel par l'intermédiaire de la classe tango : cela est vrai même pour les personnes de langue anglaise. Un message d'erreur sera généré par la classe tango si celle-ci n'a reçu aucune option de langue à transmettre à \TO{babel} ; si vous ignorez ce message, vous devrez travailler sans aucun motif de césure. -Tango possède également certains mots réservés qui sont: -\begin{tcolorbox} -\begin{verbatim} -\newcommand\TgoTheoremName{Theorem} -\newcommand\TgoDefinitionName{Definition} -\newcommand\TgoPropositionName{Proposition} -\newcommand\TgoLemmaName{Lemma} -\newcommand\TgoCorollaryName{Corollary} -\newcommand\TgoRemarkName{Remark} -\newcommand\TgoExampleName{Example} -\newcommand\TgoContentsName{Contents} -\newcommand\TgoExerciseName{Exercise} -\newcommand\TgoExercisesSubsectionName{Exercises} -\newcommand\TgoExercisesSectionName{Exercises} -\end{verbatim} -\end{tcolorbox} +Tango possède également certains mots réservés qui sont (lorsque l'option french est passée à tango) : -Au chargement du français par babel (déclenché par l'option french), les traductions suivantes sont effectuées: \begin{tcolorbox} \begin{verbatim} \renewcommand\TgoTheoremName{Théorème} @@ -309,7 +289,16 @@ Au chargement du français par babel (déclenché par l'option french), les trad \end{verbatim} \end{tcolorbox} -Pour l'instant seules les langues anglaise et française sont pleinement supportées par tango. Les autres langues bénéficient des facilités offertes par babel, mais les mots réservés de tango ne sont pas traduits. +Même si toute option de langue reconnue par babel sera (en principe) prise en compte dès lors qu'elle est passée à tango, la traduction de ces mots réservés n'a lieu que pour les langues suivantes : +\begin{itemize} +\item\TO{french}; +\item\TO{english, british, american, canadian, australian, newzealand}; +\item\TO{german, ngerman, naustrian, nswissgerman}; +\item\TO{italian}; +\item\TO{spanish}. +\end{itemize} + +Les autres langues bénéficient des facilités offertes par babel, mais les mots réservés de tango ne sont pas traduits. Voici donc ce que peuvent faire les utilisateurs concernés. \begin{enumerate} \item Utiliser \verb+\renewcommand+ pour faire ces traductions eux-mêmes. diff --git a/macros/luatex/latex/tango/latex/tango.cls b/macros/luatex/latex/tango/lualatex/tango.cls index 7fad8c30d8..f188200b4c 100644 --- a/macros/luatex/latex/tango/latex/tango.cls +++ b/macros/luatex/latex/tango/lualatex/tango.cls @@ -1,6 +1,6 @@ \NeedsTeXFormat{LaTeX2e}% \ProvidesClass{tango}% -[2024/07/11 v0.7.2 tango document class. Michel Bovani]% % +[2024/07/15 v0.8.0 tango document class. Michel Bovani]% % % % Ensure luatex engine \RequirePackage{iftex}[2019/10/24] @@ -28,6 +28,18 @@ \newcommand\TgoPublicationClass{article} \newcommand\TgoStatementIndent{\indent} \newif\ifTgoFrenchLanguage +\newif\ifTgoNGermanLanguage +\newif\ifTgoGermanLanguage +\newif\ifTgoNAustrianLanguage +\newif\ifTgoNSwissGermanLanguage +\newif\ifTgoItalianLanguage +\newif\ifTgoSpanishLanguage +\newif\ifTgoEnglishLanguage +\newif\ifTgoBritishLanguage +\newif\ifTgoAmericanLanguage +\newif\ifTgoCanadianLanguage +\newif\ifTgoAustralianLanguage +\newif\ifTgoNewZealandLanguage \newif\ifTgoNoStatement \newif\ifTgoBook \newif\ifTgoOneSide\TgoOneSidetrue @@ -70,6 +82,42 @@ \TgoFrenchLanguagetrue \TgoTitleIndentZerofalse }, + ngerman.code= {% + \TgoNGermanLanguagetrue + }, + german.code= {% + \TgoGermanLanguagetrue + }, +naustrian.code= {% + \TgoNAustrianLanguagetrue + }, +nswissgerman.code= {% + \TgoNSwissGermanLanguagetrue + }, + italian.code= {% + \TgoItalianLanguagetrue + }, + spanish.code= {% + \TgoSpanishLanguagetrue + }, +english.code= {% + \TgoEnglishLanguagetrue + }, +british.code= {% + \TgoBritishLanguagetrue + }, +american.code= {% + \TgoAmericanLanguagetrue + }, +canadian.code= {% + \TgoCanadianLanguagetrue + }, +australian.code= {% + \TgoAustralianLanguagetrue + }, +newzealand.code= {% + \TgoNewZealandLanguagetrue + }, %%%%%% Default Statements %%%%%%%%%%%%%%%%%%%%%%%% no-statement.if = TgoNoStatement, %%%%%% No Hyperref %%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -834,6 +882,209 @@ CustomiseFigTabCaptions=false} \renewcommand\TgoExercisesSectionName{Exercices} } \fi +%%% +\ifTgoNGermanLanguage +\addto\captionsngerman{% +\renewcommand\TgoTheoremName{Satz} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Korollar}%% ???? +\renewcommand\TgoRemarkName{Bemerkung} +\renewcommand\TgoExampleName{Beispiel} +\renewcommand\TgoContentsName{Inhaltsverzeichnis} +\renewcommand\TgoExerciseName{Übung} +\renewcommand\TgoExercisesSubsectionName{Übungen} +\renewcommand\TgoExercisesSectionName{Übungen} +} +\fi +% +%%% +\ifTgoGermanLanguage +\addto\captionsgerman{% +\renewcommand\TgoTheoremName{Satz} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Korollar}%% ???? +\renewcommand\TgoRemarkName{Bemerkung} +\renewcommand\TgoExampleName{Beispiel} +\renewcommand\TgoContentsName{Inhaltsverzeichnis} +\renewcommand\TgoExerciseName{Übung} +\renewcommand\TgoExercisesSubsectionName{Übungen} +\renewcommand\TgoExercisesSectionName{Übungen} +} +\fi +% +%%% +\ifTgoNAustrianLanguage +\addto\captionsnaustrian{% +\renewcommand\TgoTheoremName{Satz} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Korollar}%% ???? +\renewcommand\TgoRemarkName{Bemerkung} +\renewcommand\TgoExampleName{Beispiel} +\renewcommand\TgoContentsName{Inhaltsverzeichnis} +\renewcommand\TgoExerciseName{Übung} +\renewcommand\TgoExercisesSubsectionName{Übungen} +\renewcommand\TgoExercisesSectionName{Übungen} +} +\fi +% +%%% +\ifTgoNSwissGermanLanguage +\addto\captionsnswissgerman{% +\renewcommand\TgoTheoremName{Satz} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Korollar}%% ???? +\renewcommand\TgoRemarkName{Bemerkung} +\renewcommand\TgoExampleName{Beispiel} +\renewcommand\TgoContentsName{Inhaltsverzeichnis} +\renewcommand\TgoExerciseName{Übung} +\renewcommand\TgoExercisesSubsectionName{Übungen} +\renewcommand\TgoExercisesSectionName{Übungen} +} +\fi +% +%%% +\ifTgoItalianLanguage +\addto\captionsitalian{% +\renewcommand\TgoTheoremName{Teorema} +\renewcommand\TgoDefinitionName{Definizione} +\renewcommand\TgoPropositionName{Proposizione} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollario} +\renewcommand\TgoRemarkName{Nota}%%???? +\renewcommand\TgoExampleName{Esempio} +\renewcommand\TgoContentsName{Sommario}%%Contenuti???? +\renewcommand\TgoExerciseName{Esercizio} +\renewcommand\TgoExercisesSubsectionName{Esercizi} +\renewcommand\TgoExercisesSectionName{Esercizi} +} +\fi +% +%%% +\ifTgoSpanishLanguage +\addto\captionsspanish{% +\renewcommand\TgoTheoremName{Teorema} +\renewcommand\TgoDefinitionName{Definición} +\renewcommand\TgoPropositionName{Proposición} +\renewcommand\TgoLemmaName{Lema} +\renewcommand\TgoCorollaryName{Corolario} +\renewcommand\TgoRemarkName{Osservación}%%???? +\renewcommand\TgoExampleName{Ejemplo} +\renewcommand\TgoContentsName{Sumario}%%???? +\renewcommand\TgoExerciseName{Ejercicio} +\renewcommand\TgoExercisesSubsectionName{Ejercicios} +\renewcommand\TgoExercisesSectionName{Ejercicios} +} +\fi +% +%%% +\ifTgoEnglishLanguage +\addto\captionsenglish{% +\renewcommand\TgoTheoremName{Theorem} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollary} +\renewcommand\TgoRemarkName{Remark} +\renewcommand\TgoExampleName{Example} +\renewcommand\TgoContentsName{Contents} +\renewcommand\TgoExerciseName{Exercise} +\renewcommand\TgoExercisesSubsectionName{Exercises} +\renewcommand\TgoExercisesSectionName{Exercises} +} +\fi +% +%%% +\ifTgoBritishLanguage +\addto\captionsbritish{% +\renewcommand\TgoTheoremName{Theorem} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollary} +\renewcommand\TgoRemarkName{Remark} +\renewcommand\TgoExampleName{Example} +\renewcommand\TgoContentsName{Contents} +\renewcommand\TgoExerciseName{Exercise} +\renewcommand\TgoExercisesSubsectionName{Exercises} +\renewcommand\TgoExercisesSectionName{Exercises} +} +\fi +% +%%% +\ifTgoAmericanLanguage +\addto\captionsamerican{% +\renewcommand\TgoTheoremName{Theorem} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollary} +\renewcommand\TgoRemarkName{Remark} +\renewcommand\TgoExampleName{Example} +\renewcommand\TgoContentsName{Contents} +\renewcommand\TgoExerciseName{Exercise} +\renewcommand\TgoExercisesSubsectionName{Exercises} +\renewcommand\TgoExercisesSectionName{Exercises} +} +\fi +% +%%% +\ifTgoCanadianLanguage +\addto\captionscanadian{% +\renewcommand\TgoTheoremName{Theorem} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollary} +\renewcommand\TgoRemarkName{Remark} +\renewcommand\TgoExampleName{Example} +\renewcommand\TgoContentsName{Contents} +\renewcommand\TgoExerciseName{Exercise} +\renewcommand\TgoExercisesSubsectionName{Exercises} +\renewcommand\TgoExercisesSectionName{Exercises} +} +\fi +% +%%% +\ifTgoAustralianLanguage +\addto\captionsaustralian{% +\renewcommand\TgoTheoremName{Theorem} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollary} +\renewcommand\TgoRemarkName{Remark} +\renewcommand\TgoExampleName{Example} +\renewcommand\TgoContentsName{Contents} +\renewcommand\TgoExerciseName{Exercise} +\renewcommand\TgoExercisesSubsectionName{Exercises} +\renewcommand\TgoExercisesSectionName{Exercises} +} +\fi +% +%%% +\ifTgoNewZealandLanguage +\addto\captionsnewzealand{% +\renewcommand\TgoTheoremName{Theorem} +\renewcommand\TgoDefinitionName{Definition} +\renewcommand\TgoPropositionName{Proposition} +\renewcommand\TgoLemmaName{Lemma} +\renewcommand\TgoCorollaryName{Corollary} +\renewcommand\TgoRemarkName{Remark} +\renewcommand\TgoExampleName{Example} +\renewcommand\TgoContentsName{Contents} +\renewcommand\TgoExerciseName{Exercise} +\renewcommand\TgoExercisesSubsectionName{Exercises} +\renewcommand\TgoExercisesSectionName{Exercises} +} +\fi % %%% Last package \ifTgoNoHyperref @@ -1005,7 +1256,7 @@ labelwidth=0.75\TgoStandardMargin, labelsep=0.25\TgoStandardMargin, itemindent=! \ifTgoBook \newcommand\TgoChapterBox[1]{% {\filright\sffamily\addfontfeature{RawFeature=-onum}\fontseries{eb}\selectfont\HUGE\hspace*{-0.06em}\thechapter}% -\quad\parbox[b]{0.75\textwidth}{\filright#1} +\quad\parbox{0.75\textwidth}{\filright#1} } \titleformat{\part}[display]{\centering\color{ColorOne}\sffamily \addfontfeature{RawFeature=-onum}\fontseries{eb}\selectfont\Huge} |