diff options
author | Karl Berry <karl@freefriends.org> | 2022-03-11 22:00:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-03-11 22:00:40 +0000 |
commit | 1052550c761c8504454157d94094dc792e7e32e5 (patch) | |
tree | 8e52ffabb2fd136ee534384a22bc8bff6d14477b /Master/texmf-dist | |
parent | b405da142dbd35182a6530ceb43be46cd0cf5bab (diff) |
jmsdelim (11mar22)
git-svn-id: svn://tug.org/texlive/trunk@62630 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/jmsdelim/README.md | 35 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/jmsdelim/jmsdelim.pdf | bin | 0 -> 415204 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/jmsdelim/refs.bib | 13 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/jmsdelim/jmsdelim.dtx | 693 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/jmsdelim/jmsdelim.ins | 15 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty | 218 |
6 files changed, 974 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/jmsdelim/README.md b/Master/texmf-dist/doc/latex/jmsdelim/README.md new file mode 100644 index 00000000000..dfdeff2ab30 --- /dev/null +++ b/Master/texmf-dist/doc/latex/jmsdelim/README.md @@ -0,0 +1,35 @@ +The `jmsdelim` package +====================== + +A package for compositional delimiter sizing. + +The following files are included: +- `jmsdelim.dtx` : the doctrip source for the package and documentation +- `jmsdelim.ins` : the generation script for producing `ebproof-rules.sty` + +The package requires `expl3` (the LaTeX3 programming environment) which +provides many useful programming tools. + +To build the documenation, run `l3build doc`. + + +License +------- + +Copyright 2022 Jonathan Sterling <jon@jonmsterling.com> + +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. +The latest version of this license is in + <http://www.latex-project.org/lppl.txt> +and version 1.3 or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status “maintained”. + +The Current Maintainer of this work is Jonathan Sterling. + +This work consists of the file `jmsdelim.dtx`. + + diff --git a/Master/texmf-dist/doc/latex/jmsdelim/jmsdelim.pdf b/Master/texmf-dist/doc/latex/jmsdelim/jmsdelim.pdf Binary files differnew file mode 100644 index 00000000000..0199f3b2bb5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/jmsdelim/jmsdelim.pdf diff --git a/Master/texmf-dist/doc/latex/jmsdelim/refs.bib b/Master/texmf-dist/doc/latex/jmsdelim/refs.bib new file mode 100644 index 00000000000..13c0e80f201 --- /dev/null +++ b/Master/texmf-dist/doc/latex/jmsdelim/refs.bib @@ -0,0 +1,13 @@ +@misc{oberdick:mleftright, + author = {Oberdick, Heiko}, + date = {2016-05-16}, + title = {The {\ttfamily mleftright} package}, + url = {https://ctan.org/pkg/mleftright} +} + +@misc{segletes:scalerel, + title = {{\ttfamily scalerel} -- Constrained scaling and stretching of objects}, + author = {Segletes, Steven B.}, + date = {2016-12-29}, + url = {https://ctan.org/pkg/scalerel} +} diff --git a/Master/texmf-dist/source/latex/jmsdelim/jmsdelim.dtx b/Master/texmf-dist/source/latex/jmsdelim/jmsdelim.dtx new file mode 100644 index 00000000000..868070471e6 --- /dev/null +++ b/Master/texmf-dist/source/latex/jmsdelim/jmsdelim.dtx @@ -0,0 +1,693 @@ +% \iffalse meta-comment +% +%% File: jmsdelim.dtx Copyright (C) 2020 Jonathan Sterling +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% ------------------------------------------------------------------------- +% +%<*driver> +\documentclass[cs-f]{l3doc} +\usepackage{jmsdelim} +\usepackage{mlmodern} +\usepackage{mleftright} +\usepackage[capitalize]{cleveref} +\usepackage[protrusion=true,expansion=true,tracking=false]{microtype} +\microtypecontext{spacing=nonfrench} + +\usepackage{xcolor} +\usepackage{zi4} +\definecolor{Matterhorn}{RGB}{77,77,77} +\definecolor{RedDevil}{RGB}{134,1,17} +\definecolor{RegalBlue}{RGB}{3,69,117} +\usepackage[backend=biber,natbib=true, doi=true, citestyle=alphabetic, backref=true, style=alphabetic, maxnames=1000]{biblatex} +\hypersetup{breaklinks=true,colorlinks=true,linkcolor=RedDevil,urlcolor=RegalBlue, citecolor=RegalBlue!70} +\addbibresource{refs.bib} +\setlength\parindent{0pt} +\setlength\parskip{.5em} +\renewcommand\bfdefault{b} +% +\let\oldmeta\meta +\renewcommand\meta[1]{\texttt{\oldmeta{#1}}} +% +% ripped from ebproof +\NewDocumentEnvironment{example}{}{% + \VerbatimEnvironment + \begin{VerbatimOut}{example.tex}% +}{% + \end{VerbatimOut} + \begin{center} + \begin{minipage}{.4\textwidth} + \input{example.tex} + \end{minipage}% + \begin{minipage}{.6\textwidth} + \small\VerbatimInput[gobble=0]{example.tex} + \end{minipage}% + \end{center} +} +\NewDocumentEnvironment{wide-example}{}{% + \VerbatimEnvironment + \begin{VerbatimOut}{example.tex}% +}{% + \end{VerbatimOut} + \input{example.tex} +% + \small\VerbatimInput[gobble=0]{example.tex} +} +% +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{The \pkg{jmsdelim} package} +% +% \author{Jonathan Sterling} +% +% \date{September 14, 2019} +% +% \maketitle +% +% \begin{documentation} +% +% \section{Overview} +% +% Sizing delimiters using \cs{left} and \cs{right} should be outlawed! The results are nearly always unaesthetic, primarily because the correct size of a mathematical delimiter is a typesetting consideration which does \emph{not} emanate from the physical size of the interior. +% +% Correctly sizing delimiters is very difficult, particularly in well-architected documents: a correctly engineered mathematical document will include macros for all operations, and these macros necessarily will include delimiters (such as parentheses). However, the correct size for the delimiter cannot be chosen ahead of time, because it will depend on the arguments; two options are available: +% +% \begin{enumerate} +% \item Provide optional arguments to each notation macro for choosing delimiter sizes. This is nearly intractable to do in practice. +% \item Ignore delimiter sizes. +% \end{enumerate} +% +% With \pkg{jmsdelim} we offer an alternative: the correct delimiter sizes can be set at the \emph{leaf nodes} of a mathematical expression, and magically bubble upward through the delimiters. +% +% +% \section{Document interface} +% +% \begin{function}{\DelimMin} +% \begin{syntax} +% \cs{DelimMin}\marg{intexpr_{min}} +% \end{syntax} +% +% This sets the minimum delimiter size to \meta{intexpr_{min}} outside the current location; delimiter sizes are +% represented as natural numbers, with \verb|0| the smallest size. +% \end{function} +% +% \cs{DelimMin} is the work-horse of \pkg{jmsdelim}; let us consider an example of what one might do prior to adopting \pkg{jmsdelim}. Suppose we have defined a macro \cs{Psh} for the free co-completion, following the notation of the French school, and we wish to parenthesize an instance of it: +% \begin{example} +% \NewDocumentCommand\Cat{}{\mathbf{Cat}} +% \NewDocumentCommand\Psh{m}{\widehat{#1}} +% \NewDocumentCommand\Hom{mmm}{ +% \operatorname{Hom}_{#1}(#2,#3) +% } +% \[ \Hom{\Cat}{1}{\Psh{\mathbb{C}}} \] +% \end{example} +% +% One might have tried to get a better result by using \cs{left} and \cs{right}: +% \begin{example} +% \NewDocumentCommand\Cat{}{\mathbf{Cat}} +% \NewDocumentCommand\Psh{m}{\widehat{#1}} +% \NewDocumentCommand\HomX{mmm}{ +% \operatorname{Hom}_{#1}\left(#2,#3\right) +% } +% \NewDocumentCommand\Hom{mmm}{ +% \operatorname{Hom}_{#1}\mleft(#2,#3\mright) +% } +% \[ \Hom{\Cat}{1}{\Psh{\mathbb{C}}} \] +% \[ \HomX{\Cat}{1}{\Psh{\mathbb{C}}} \] +% \end{example} +% +% The above is appallingly worse: the height of the hat does not in any way determine the correct size for the delimiter! The solution using \pkg{jmsdelim} is quite simple, however: first, we change \cs{Hom} to call \cs{DelimPrn}, and then we use \cs{DelimMin} within the \cs{Psh} notation. +% \begin{example} +% \NewDocumentCommand\Cat{}{\mathbf{Cat}} +% \NewDocumentCommand\Psh{m}{\DelimMin{1}\widehat{#1}} +% \NewDocumentCommand\Hom{mmm}{ +% \operatorname{Hom}_{#1}\DelimPrn{#2,#3} +% } +% \[ \Hom{\Cat}{1}{\Psh{\mathbb{C}}} \] +% \end{example} +% +% \paragraph{Behavior under subscripts} +% By default, delimiter sizes are capped under subscripts and superscripts because the alternative is unaesthetic. For instance, consider the following somewhat contrived examples: +% \begin{example} +% \NewDocumentCommand\Sum{mm}{% +% \DelimMin{1}{\textstyle\sum}_{#1}{#2}% +% } +% \[ +% \int_{\DelimPrn{\Sum{i}{a_i}}} +% \int_{\DelimPrn{\DelimMin{4}\Sum{i}{a_i}}} +% \] +% \end{example} +% +% Because the emitted delimiter size under a subscript does \emph{not} determine the actual amount of space used, it is in most cases not correct for this delimiter size to have an effect on its non-subscript context. For this reason, judicious use of the \cs{DelimProtect} command is recommended in the case of subscripts. +% +% +% +% \subsection{Basic Delimiter commands} +% +% Like \pkg{mleftright}~\citep{oberdick:mleftright}, \pkg{jmsdelim} ensures the correct amount of space on the outside of the delimiters using \cs{mathopen} and \cs{mathclose}. +% +% \begin{function}{\DelimSurround} +% \begin{syntax} +% \cs{DelimSurround}\marg{left}\marg{right}\marg{body} +% \end{syntax} +% Surrounds \meta{body} with appropriately sized \meta{left} and \meta{right} delimiters respectively. +% \begin{example} +% \NewDocumentCommand\Sum{mm}{% +% \DelimMin{1}{\textstyle\sum}_{#1}{#2}% +% } +% \[\DelimSurround{\vert}{\vert}{\Sum{i}{b_i}}\] +% \end{example} +% \end{function} +% +% \begin{function}{\DelimBetween} +% \begin{syntax} +% \cs{DelimSurround}\marg{sep}\marg{lbody}\marg{rbody} +% \end{syntax} +% Places an appropriately sized \meta{sep} between \meta{lbody} and \meta{rbody}. +% \begin{example} +% \NewDocumentCommand\Sum{mm}{% +% \DelimMin{1}{\textstyle\sum}_{#1}{#2}% +% } +% \[\DelimBetween{\Vert}{a}{\Sum{i}{b_i}}\] +% \end{example} +% \end{function} +% +% \begin{function}{\DelimBetweenSurround} +% \begin{syntax} +% \cs{DelimSurround}\marg{left}\marg{sep}\marg{right}\marg{lbody}\marg{rbody} +% \end{syntax} +% Places an appropriately sized \meta{sep} between \meta{lbody} and \meta{rbody}, surrounding the result by \meta{left} and \meta{right} respectively. +% \begin{example} +% \NewDocumentCommand\Sum{mm}{% +% \DelimMin{1}{\textstyle\sum}_{#1}{#2}% +% } +% \[ +% \DelimBetweenSurround{\lbrace}{\vert}{\rbrace}{ +% \Sum{i}{a\cdot b_i} +% }{a\in A} +% \] +% \end{example} +% \end{function} +% +% \begin{function}{\DelimProtect} +% \begin{syntax} +% \cs{DelimProtect}\marg{body} +% \end{syntax} +% Executes \meta{body} in a sandbox, preventing its state updates from bubbling outward; this is useful in case of subscripts and superscripts. +% The following command demonstrates incorrect sizing in the presence of a high delimiter size within a subscript: +% \begin{example} +% \NewDocumentCommand\Sum{mm}{% +% \DelimMin{1}{\textstyle\sum}_{#1}{#2}% +% } +% \[ +% \DelimPrn{\Sum{\DelimPrn{\DelimMin{4}\Sum{i}{a_i}}}{F}} +% \] +% \end{example} +% +% Using a combination of \cs{DelimProtect} and \cs{DelimMin}, the formatting can be corrected locally. +% \begin{example} +% \NewDocumentCommand\Sum{mm}{% +% \DelimMin{1}{\textstyle\sum}_{\DelimProtect{#1}}{#2}% +% } +% \[ +% \DelimPrn{ +% \DelimMin{2} +% \Sum{\DelimPrn{\DelimMin{4}\Sum{i}{a_i}}}{F} +% } +% \] +% \end{example} +% \end{function} +% +% \subsection{Derived delimiter commands} +% +% \begin{function}{\DelimPrn} +% \begin{syntax} +% \cs{DelimPrn}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in parentheses. +% \end{function} +% +% \begin{function}{\DelimBrk} +% \begin{syntax} +% \cs{DelimBrk}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in square brackets. +% \end{function} +% +% \begin{function}{\DelimBrc} +% \begin{syntax} +% \cs{DelimBrc}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in curly braces. +% \end{function} +% +% \begin{function}{\DelimGl} +% \begin{syntax} +% \cs{DelimGl}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in angle brackets. +% \end{function} +% +% \begin{function}{\DelimVrt} +% \begin{syntax} +% \cs{DelimVrt}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in vertical brackets. +% \end{function} +% +% \begin{function}{\DelimBbrk} +% \begin{syntax} +% \cs{DelimBbrk}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in Scott brackets (requires \cs{llbracket}, \cs{rrbracket} to be defined). +% \end{function} +% +% \begin{function}{\DelimVvrt} +% \begin{syntax} +% \cs{DelimVvrt}\marg{body} +% \end{syntax} +% Surrounds \meta{body} in double vertical bars. +% \end{function} +% +% +% \subsection{Configuration and options}\label{sec:options} +% \begin{function}{\DelimSetup} +% \begin{syntax} +% \cs{DelimSetup}\marg{options} +% \end{syntax} +% \pkg{jmsdelim} can be customized along a few axes. +% \end{function} +% +% \begin{variable}{size commands} +% The option \cmd{size commands} is a comma-separated list which contains a list of sizing commands for delimiters, from smallest to largest. By default, the standard \cs{big}, \cs{Big}, \cs{bigg}, \cs{Bigg} sequence is replaced by custom versions that behave differently in script size. This behavior can be overridden as follows: +% \begin{verbatim} +% \DelimSetup{ +% size commands = {\relax,\big,\Big,\bigg,\Bigg} +% } +% \end{verbatim} +% \end{variable} +% +% +% +% \section{Interface for macro authors} +% +% The internals of \pkg{jmsdelim} are implemented in \pkg{expl3}. +% +% \begin{function}{jmsdelim_scope:nn} +% \begin{syntax} +% "jmsdelim_scope:nn" \Arg{pre} \Arg{post} +% \end{syntax} +% This is the fundamental control structure for authors of custom delimiting commands; \meta{pre} is a block of code that renders things to temporary boxes, and \Arg{post} is code that \emph{uses} these boxes, placing them relative to some delimiters. The function of \cs{jmsdelim_scope:nn} is to watch for the delimiter size updates induced by \meta{pre}, and set the delimiter size commands correctly before executing \meta{post}. Both \meta{pre} and \meta{post} are to be executed in the same block level. +% \end{function} +% +% \begin{function}{jmsdelim_hbox_set:Nn} +% \begin{syntax} +% "jmsdelim_hbox_set:Nn" \Arg{box} \Arg{contents} +% \end{syntax} +% This command is meant to be used inside the \meta{pre} block of \cs{jmsdelim_scope:nn}; it typesets \meta{contents} in the box named by \meta{box}, correctly propagating the math style. +% \end{function} +% +% \begin{function}{jmsdelim_size_cmd:} +% \begin{syntax} +% "jmsdelim_size_cmd:" +% \end{syntax} +% This command is meant to be used inside the \meta{post} block of \cs{jmsdelim_scope:nn} to set the size of a given delimiter; it behaves like \cs{big}, etc. +% \end{function} +% +% \begin{function}{jmsdelim_surround:nnn} +% \begin{syntax} +% "jmsdelim_surround:nnn" \Arg{left} \Arg{right} \Arg{body} +% \end{syntax} +% This routine surrounds \meta{body} with the delimiters \meta{left} and \meta{right} of the appropriate size respectively. +% \end{function} +% +% \begin{function}{jmsdelim_between:nnn} +% \begin{syntax} +% "jmsdelim_between:nnn" \Arg{sep} \Arg{lbody} \Arg{rbody} +% \end{syntax} +% This routine separates \meta{lbody} and \meta{rbody} with a separator \meta{sep} of the appropriate size. +% \end{function} +% +% \begin{function}{jmsdelim_between:nnnnn} +% \begin{syntax} +% "jmsdelim_between:nnnnn" \Arg{left} \Arg{sep} \Arg{right} \Arg{lbody} \Arg{rbody} +% \end{syntax} +% This routine separates \meta{lbody} and \meta{rbody} with a separator \meta{sep} of the appropriate size, and surrounds the result by \meta{left} and \meta{right} respectively of the same size. +% \end{function} +% +% \begin{function}{jmsdelim_protect:n} +% \begin{syntax} +% "jmsdelim_protect:n" \Arg{body} +% \end{syntax} +% Executes \meta{body} in a sandbox, preventing its state updates from bubbling upward. +% \end{function} +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{jmsdelim} implementation} +% \label{sec:jmsdelim:implementation} +% +% +% \begin{macrocode} +%<*package> +\RequirePackage{expl3} +\RequirePackage{l3keys2e} +\RequirePackage{xparse} +\RequirePackage{ifluatex} +\RequirePackage{scalerel} +\ProvidesExplPackage {jmsdelim} {2022/03/11} {0.2.0} + {Compositional delimiter sizing} +%<@@=jmsdelim> +% \end{macrocode} +% +% We first declare the options for the \pkg{jmsdelim} module, together with their default valeus. +% +% \begin{macrocode} +\keys_define:nn { jmsdelim } { + size~commands .clist_set:N = \l@@_size_cmds, +} +\keys_set:nn { jmsdelim } { + size~commands = {relax,jmsdelim_big:n,jmsdelim_Big:n,jmsdelim_bigg:n,jmsdelim_Bigg:n}, +} + +\cs_new:Npn \jmsdelim_big:n #1 { + {\mathchoice{\big #1} {\big #1}{\big #1}{#1}} +} + +\cs_new:Npn \jmsdelim_Big:n #1 { + {\mathchoice{\Big #1} {\Big #1}{\big #1}{#1}} +} + +\cs_new:Npn \jmsdelim_bigg:n #1 { + {\mathchoice{\bigg #1} {\bigg #1}{\big #1}{#1}} +} + +\cs_new:Npn \jmsdelim_Bigg:n #1 { + {\mathchoice{\Bigg #1} {\Bigg #1}{\big #1}{#1}} +} +% \end{macrocode} +% +% Then, we set up the internal state that will be used by \pkg{jmsdelim}. +% \begin{macrocode} +\int_new:N \g@@_size +\int_new:N \g@@_size_up +\int_gset:Nn \g@@_size {0} +\int_gset:Nn \g@@_size_up {0} +% \end{macrocode} +% +% \subsection{Internals} +% +% \begin{macro}{\@@_clist_item:Nn} +% A version of \cs{clist_item:Nn} that takes the last item when the index is out of bounds. +% \begin{macrocode} +\cs_new:Npn \@@_clist_item:Nn #1 #2 { + \clist_item:Nn #1 { + \int_min:nn { #2 } {\clist_count:N #1} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{@@_setup_sizes:} +% \begin{macrocode} +\cs_new:Npn \@@_setup_sizes: { + \int_gset:Nn \g@@_size { + \int_max:nn \g@@_size \g@@_size_up + } + + \cs_set_eq:Nc \jmsdelim_size_cmd: { + \@@_clist_item:Nn \l@@_size_cmds { + \g@@_size + 1 + } + } +} +% \end{macrocode} +% \end{macro} + +% +% \subsubsection{Preservation of math styles} +% It is fairly complicated and inefficient to preserve math styles across boxes. There is an appropriate way to do so in Lua\LaTeX, which we use conditionally if available; otherwise, we make use of \cs{ThisStyle} and \cs{SavedStyle} from \pkg{scalerel}~\citep{segletes:scalerel}, which are more inefficient. In fact, it becomes impossible to use \pkg{jmsdelim} in PDF\LaTeX{} when the nesting is sufficiently deep, whereas there is no corresponding blowup in Lua\LaTeX. The \cs{ignoremathstyle} and \cs{discernmathstyle} macros from \pkg{scalerel} can be used to turn off the inefficient preservation of math styles locally, such as in the case where no subscripts are used. + +% \begin{macro}{@@_luatex_save_mathstyle:N} +% \begin{macrocode} +\cs_new:Npn \@@_luatex_save_mathstyle:N #1 { + \ifcase \mathstyle + \cs_set_eq:NN #1 \displaystyle + \or + \cs_set_eq:NN #1 \crampeddisplaystyle + \or + \cs_set_eq:NN #1 \textstyle + \or + \cs_set_eq:NN #1 \crampedtextstyle + \or + \cs_set_eq:NN #1 \scriptstyle + \or + \cs_set_eq:NN #1 \crampedscriptstyle + \or + \cs_set_eq:NN #1 \scriptscriptstyle + \or + \cs_set_eq:NN #1 \crampedscriptscriptstyle + \fi +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{@@_restore_mathstyle:n} +% \begin{macrocode} +\cs_new:Npn \@@_restore_mathstyle: { + \SavedStyle +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{@@_save_mathstyle:n} +% \begin{macrocode} +\cs_new:Npn \@@_save_mathstyle:n #1 { + \ifluatex + \@@_luatex_save_mathstyle:N \@@_restore_mathstyle: + #1 + \else + \ThisStyle{#1} + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Public interface for macro authors} +% +% \begin{macro}{jmsdelim_scope:nn} +% \begin{macrocode} +\cs_new:Npn \jmsdelim_scope:nn #1 #2 { + \group_begin: + \int_set:Nn \l_tmpa_int \g@@_size_up + \int_gset:Nn \g@@_size_up 0 + \int_gset:Nn \g@@_size 0 + \group_begin: + \@@_save_mathstyle:n { + #1 + \@@_setup_sizes: + #2 + } + \group_end: + \int_gset:Nn \g@@_size_up {\int_max:nn \g@@_size_up \l_tmpa_int} + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{jmsdelim_hbox_set:Nn} +% \begin{macrocode} +\cs_new:Npn \jmsdelim_hbox_set:Nn #1 #2 { + \mode_if_math:TF + { \hbox_set:Nn #1 {$\m@th\@@_restore_mathstyle: #2$} } + { \hbox_set:Nn #1 { #2 } } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{jmsdelim_surround:nnn} +% \begin{macrocode} +\cs_new:Npn \jmsdelim_surround:nnn #1 #2 #3 { + \jmsdelim_scope:nn { + \jmsdelim_hbox_set:Nn \l_tmpa_box {#3} + }{ + \mathopen\jmsdelim_size_cmd: {#1} + \box_use:N \l_tmpa_box + \mathclose\jmsdelim_size_cmd: {#2} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{jmsdelim_protect:n} +% \begin{macrocode} +\cs_new:Npn \jmsdelim_protect:n #1 { + \group_begin: + \int_set:Nn \l_tmpa_int \g@@_size_up + \int_set:Nn \l_tmpb_int \g@@_size + \group_begin: #1 \group_end: + \int_gset:Nn \g@@_size_up \l_tmpa_int + \int_gset:Nn \g@@_size \l_tmpb_int + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{jmsdelim_between:nnn} +% \begin{macrocode} +\cs_new:Npn \jmsdelim_between:nnn #1 #2 #3 { + \jmsdelim_scope:nn { + \jmsdelim_hbox_set:Nn \l_tmpa_box {#2} + \jmsdelim_hbox_set:Nn \l_tmpb_box {#3} + }{ + \box_use:N \l_tmpa_box + \mathrel{\jmsdelim_size_cmd: {#1}} + \box_use:N \l_tmpb_box + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{jmsdelim_between:nnnnn} +% \begin{macrocode} +\cs_new:Npn \jmsdelim_between:nnnnn #1 #2 #3 #4 #5 { + \jmsdelim_scope:nn { + \jmsdelim_hbox_set:Nn \l_tmpa_box {#4} + \jmsdelim_hbox_set:Nn \l_tmpb_box {#5} + }{ + \mathopen\jmsdelim_size_cmd: {#1} + \box_use:N \l_tmpa_box + \mathrel{\jmsdelim_size_cmd: {#2}} + \box_use:N \l_tmpb_box + \mathclose\jmsdelim_size_cmd: {#3} + } +} +% \end{macrocode} +% \end{macro} + +% \subsection{Document interace} + + +% \begin{macro}{DelimMin} +% \begin{macrocode} +\NewDocumentCommand\DelimMin{m}{ + \int_gset:Nn \g@@_size_up {\int_max:nn \g@@_size_up {#1}} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{DelimSurround} +% \begin{macrocode} +\NewDocumentCommand\DelimSurround{mmm}{ + \jmsdelim_surround:nnn {#1} {#2} {#3} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimBetween} +% \begin{macrocode} +\NewDocumentCommand\DelimBetween{mmm}{ + \jmsdelim_between:nnn {#1} {#2} {#3} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimBetweenSurround} +% \begin{macrocode} +\NewDocumentCommand\DelimBetweenSurround{mmmmm}{ + \jmsdelim_between:nnnnn {#1} {#2} {#3} {#4} {#5} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimProtect} +% \begin{macrocode} +\NewDocumentCommand\DelimProtect{m}{ + \jmsdelim_protect:n {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimPrn} +% \begin{macrocode} +\NewDocumentCommand\DelimPrn{m}{ + \jmsdelim_surround:nnn {(} {)} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimBrk} +% \begin{macrocode} +\NewDocumentCommand\DelimBrk{m}{ + \jmsdelim_surround:nnn {[} {]} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimBrc} +% \begin{macrocode} +\NewDocumentCommand\DelimBrc{m}{ + \jmsdelim_surround:nnn {\lbrace} {\rbrace} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimBbrk} +% \begin{macrocode} +\NewDocumentCommand\DelimBbrk{m}{ + \jmsdelim_surround:nnn {\llbracket} {\rrbracket} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimGl} +% \begin{macrocode} +\NewDocumentCommand\DelimGl{m}{ + \jmsdelim_surround:nnn {\langle} {\rangle} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimVrt} +% \begin{macrocode} +\NewDocumentCommand\DelimVrt{m}{ + \jmsdelim_surround:nnn {\lvert} {\rvert} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DelimVvrt} +% \begin{macrocode} +\NewDocumentCommand\DelimVvrt{m}{ + \jmsdelim_surround:nnn {\lVert} {\rVert} {#1} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\ProcessKeysPackageOptions {jmsdelim} +% \end{macrocode} +% +%\iffalse meta-comment +%</package> +%\fi +% +% \end{implementation} +% +% \printbibliography +% \PrintIndex +% +\endinput +% +% end of file diff --git a/Master/texmf-dist/source/latex/jmsdelim/jmsdelim.ins b/Master/texmf-dist/source/latex/jmsdelim/jmsdelim.ins new file mode 100644 index 00000000000..77bc0a4529d --- /dev/null +++ b/Master/texmf-dist/source/latex/jmsdelim/jmsdelim.ins @@ -0,0 +1,15 @@ +%% Copyright (C) 2019 by Jonathan Sterling +%% +%% This file 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. The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2005/12/01 or later. + +\input l3docstrip.tex +\keepsilent \askforoverwritefalse +\generate{\file{jmsdelim.sty}{\from{jmsdelim.dtx}{package}}} +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty b/Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty new file mode 100644 index 00000000000..762402abbf9 --- /dev/null +++ b/Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty @@ -0,0 +1,218 @@ +%% +%% This is file `jmsdelim.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% jmsdelim.dtx (with options: `package') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from jmsdelim.sty. +%% +%% For distribution of the original source see the terms +%% for copying and modification in the file jmsdelim.dtx. +%% +%% This generated file may be distributed as long as the +%% original source files, as listed above, are part of the +%% same distribution. (The sources need not necessarily be +%% in the same archive or directory.) +%% File: jmsdelim.dtx Copyright (C) 2020 Jonathan Sterling +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% ------------------------------------------------------------------------- +\RequirePackage{expl3} +\RequirePackage{l3keys2e} +\RequirePackage{xparse} +\RequirePackage{ifluatex} +\RequirePackage{scalerel} +\ProvidesExplPackage {jmsdelim} {2022/03/11} {0.2.0} + {Compositional delimiter sizing} +\keys_define:nn { jmsdelim } { + size~commands .clist_set:N = \l__jmsdelim_size_cmds, +} +\keys_set:nn { jmsdelim } { + size~commands = {relax,jmsdelim_big:n,jmsdelim_Big:n,jmsdelim_bigg:n,jmsdelim_Bigg:n}, +} + +\cs_new:Npn \jmsdelim_big:n #1 { + {\mathchoice{\big #1} {\big #1}{\big #1}{#1}} +} + +\cs_new:Npn \jmsdelim_Big:n #1 { + {\mathchoice{\Big #1} {\Big #1}{\big #1}{#1}} +} + +\cs_new:Npn \jmsdelim_bigg:n #1 { + {\mathchoice{\bigg #1} {\bigg #1}{\big #1}{#1}} +} + +\cs_new:Npn \jmsdelim_Bigg:n #1 { + {\mathchoice{\Bigg #1} {\Bigg #1}{\big #1}{#1}} +} +\int_new:N \g__jmsdelim_size +\int_new:N \g__jmsdelim_size_up +\int_gset:Nn \g__jmsdelim_size {0} +\int_gset:Nn \g__jmsdelim_size_up {0} +\cs_new:Npn \__jmsdelim_clist_item:Nn #1 #2 { + \clist_item:Nn #1 { + \int_min:nn { #2 } {\clist_count:N #1} + } +} +\cs_new:Npn \__jmsdelim_setup_sizes: { + \int_gset:Nn \g__jmsdelim_size { + \int_max:nn \g__jmsdelim_size \g__jmsdelim_size_up + } + + \cs_set_eq:Nc \jmsdelim_size_cmd: { + \__jmsdelim_clist_item:Nn \l__jmsdelim_size_cmds { + \g__jmsdelim_size + 1 + } + } +} + + +\cs_new:Npn \__jmsdelim_luatex_save_mathstyle:N #1 { + \ifcase \mathstyle + \cs_set_eq:NN #1 \displaystyle + \or + \cs_set_eq:NN #1 \crampeddisplaystyle + \or + \cs_set_eq:NN #1 \textstyle + \or + \cs_set_eq:NN #1 \crampedtextstyle + \or + \cs_set_eq:NN #1 \scriptstyle + \or + \cs_set_eq:NN #1 \crampedscriptstyle + \or + \cs_set_eq:NN #1 \scriptscriptstyle + \or + \cs_set_eq:NN #1 \crampedscriptscriptstyle + \fi +} + +\cs_new:Npn \__jmsdelim_restore_mathstyle: { + \SavedStyle +} + +\cs_new:Npn \__jmsdelim_save_mathstyle:n #1 { + \ifluatex + \__jmsdelim_luatex_save_mathstyle:N \__jmsdelim_restore_mathstyle: + #1 + \else + \ThisStyle{#1} + \fi +} +\cs_new:Npn \jmsdelim_scope:nn #1 #2 { + \group_begin: + \int_set:Nn \l_tmpa_int \g__jmsdelim_size_up + \int_gset:Nn \g__jmsdelim_size_up 0 + \int_gset:Nn \g__jmsdelim_size 0 + \group_begin: + \__jmsdelim_save_mathstyle:n { + #1 + \__jmsdelim_setup_sizes: + #2 + } + \group_end: + \int_gset:Nn \g__jmsdelim_size_up {\int_max:nn \g__jmsdelim_size_up \l_tmpa_int} + \group_end: +} +\cs_new:Npn \jmsdelim_hbox_set:Nn #1 #2 { + \mode_if_math:TF + { \hbox_set:Nn #1 {$\m@th\__jmsdelim_restore_mathstyle: #2$} } + { \hbox_set:Nn #1 { #2 } } +} +\cs_new:Npn \jmsdelim_surround:nnn #1 #2 #3 { + \jmsdelim_scope:nn { + \jmsdelim_hbox_set:Nn \l_tmpa_box {#3} + }{ + \mathopen\jmsdelim_size_cmd: {#1} + \box_use:N \l_tmpa_box + \mathclose\jmsdelim_size_cmd: {#2} + } +} +\cs_new:Npn \jmsdelim_protect:n #1 { + \group_begin: + \int_set:Nn \l_tmpa_int \g__jmsdelim_size_up + \int_set:Nn \l_tmpb_int \g__jmsdelim_size + \group_begin: #1 \group_end: + \int_gset:Nn \g__jmsdelim_size_up \l_tmpa_int + \int_gset:Nn \g__jmsdelim_size \l_tmpb_int + \group_end: +} +\cs_new:Npn \jmsdelim_between:nnn #1 #2 #3 { + \jmsdelim_scope:nn { + \jmsdelim_hbox_set:Nn \l_tmpa_box {#2} + \jmsdelim_hbox_set:Nn \l_tmpb_box {#3} + }{ + \box_use:N \l_tmpa_box + \mathrel{\jmsdelim_size_cmd: {#1}} + \box_use:N \l_tmpb_box + } +} +\cs_new:Npn \jmsdelim_between:nnnnn #1 #2 #3 #4 #5 { + \jmsdelim_scope:nn { + \jmsdelim_hbox_set:Nn \l_tmpa_box {#4} + \jmsdelim_hbox_set:Nn \l_tmpb_box {#5} + }{ + \mathopen\jmsdelim_size_cmd: {#1} + \box_use:N \l_tmpa_box + \mathrel{\jmsdelim_size_cmd: {#2}} + \box_use:N \l_tmpb_box + \mathclose\jmsdelim_size_cmd: {#3} + } +} + + +\NewDocumentCommand\DelimMin{m}{ + \int_gset:Nn \g__jmsdelim_size_up {\int_max:nn \g__jmsdelim_size_up {#1}} +} + +\NewDocumentCommand\DelimSurround{mmm}{ + \jmsdelim_surround:nnn {#1} {#2} {#3} +} +\NewDocumentCommand\DelimBetween{mmm}{ + \jmsdelim_between:nnn {#1} {#2} {#3} +} +\NewDocumentCommand\DelimBetweenSurround{mmmmm}{ + \jmsdelim_between:nnnnn {#1} {#2} {#3} {#4} {#5} +} +\NewDocumentCommand\DelimProtect{m}{ + \jmsdelim_protect:n {#1} +} +\NewDocumentCommand\DelimPrn{m}{ + \jmsdelim_surround:nnn {(} {)} {#1} +} +\NewDocumentCommand\DelimBrk{m}{ + \jmsdelim_surround:nnn {[} {]} {#1} +} +\NewDocumentCommand\DelimBrc{m}{ + \jmsdelim_surround:nnn {\lbrace} {\rbrace} {#1} +} +\NewDocumentCommand\DelimBbrk{m}{ + \jmsdelim_surround:nnn {\llbracket} {\rrbracket} {#1} +} +\NewDocumentCommand\DelimGl{m}{ + \jmsdelim_surround:nnn {\langle} {\rangle} {#1} +} +\NewDocumentCommand\DelimVrt{m}{ + \jmsdelim_surround:nnn {\lvert} {\rvert} {#1} +} +\NewDocumentCommand\DelimVvrt{m}{ + \jmsdelim_surround:nnn {\lVert} {\rVert} {#1} +} +\ProcessKeysPackageOptions {jmsdelim} +\endinput +%% +%% End of file `jmsdelim.sty'. |