diff options
author | Karl Berry <karl@freefriends.org> | 2022-03-11 22:00:56 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-03-11 22:00:56 +0000 |
commit | cfd4eaf73ba8c94fe655bd83f13fd99ca0c62683 (patch) | |
tree | 48f0cebb5f671487ffb74f00f8e318606f6b6600 /Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty | |
parent | 8c307687e0e09e8cbc6ed56f687cf3dc3fc76a57 (diff) |
jmsdelim (11mar22) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2021.final@62631 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/jmsdelim/jmsdelim.sty | 218 |
1 files changed, 218 insertions, 0 deletions
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'. |