diff options
author | Karl Berry <karl@freefriends.org> | 2022-03-10 21:26:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-03-10 21:26:16 +0000 |
commit | af396b33f6d1b355d6240f7e08181ee7f8a4e462 (patch) | |
tree | 46441386e3df89674e573a63fec97d8113a83c14 /Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty | |
parent | 8b4eaa6c023b9c30744144dc0844c7a59a23e951 (diff) |
xsavebox (10mar22)
git-svn-id: svn://tug.org/texlive/trunk@62604 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty b/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty index 2f3fac684fe..36aeaaa1d0f 100644 --- a/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty +++ b/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty @@ -45,11 +45,11 @@ % % The Current Maintainer of this work is A. Grahn. -\RequirePackage{xparse} +\NeedsTeXFormat{LaTeX2e}[2020-10-01] \RequirePackage{l3keys2e} -\def\g@xsb@version@tl{0.16} -\def\g@xsb@date@tl{2020/03/04} +\def\g@xsb@version@tl{0.17} +\def\g@xsb@date@tl{2022/03/10} \ProvidesExplPackage{xsavebox}{\g@xsb@date@tl}{\g@xsb@version@tl} {saveboxes for repeating content without code replication} @@ -149,24 +149,21 @@ \DeclareDocumentCommand\xsavebox{smO{\width}O{c}+m}{ \xsb_check_box_name:n{#2} \group_begin: - \tl_set:Nn\l_xsb_content_grouped_tl{ - \group_begin: - \cs_set:Nn\ocgxii_beginocg:nnnn{}\cs_set:Nn\ocgxii_endocg:{} - #5 - \group_end: - } \xsb_push_props: %new, empty properties dict \xsb_beginLTR: - \IfBooleanTF{#1}{ - %later colour injection possible (pdfTeX, LuaTeX) - \hbox_set:Nn\l_xsb_raw_box{\l_xsb_content_grouped_tl} %raw content - \hbox_set:Nn\l_xsb_box{ %content re-aligned - \makebox[#3][#4]{\l_xsb_content_grouped_tl} + \hbox_set:Nn\l_xsb_raw_box{ %raw content + \bool_lazy_and:nnF{ + \tl_if_exist_p:c{xsb@\int_use:N\g_xsb_id_int} + }{ + \bool_if_p:c{c_\tl_use:c{xsb@\int_use:N\g_xsb_id_int}_bool} + }{ %prevent unused boxes from creating OCGs/OCMDs + \DeclareDocumentEnvironment{ocg}{O{}mmm}{\ignorespaces}{\unskip} + \DeclareDocumentEnvironment{ocmd}{O{}m}{\ignorespaces}{\unskip} } - }{ - %the LaTeX way (no colour injection) - \sbox\l_xsb_raw_box{\l_xsb_content_grouped_tl} %raw content - \savebox\l_xsb_box[#3][#4]{\l_xsb_content_grouped_tl} %re-aligned + #5 + } + \hbox_set:Nn\l_xsb_box{ %content re-aligned + \makebox[#3][#4]{\hbox_unpack:N\l_xsb_raw_box} } %process one of \l_xsb_raw_box or \l_xsb_box \dim_compare:nTF{\box_wd:N\l_xsb_raw_box>\box_wd:N\l_xsb_box}{ @@ -176,31 +173,25 @@ %for colour injection \hbox_set:Nn\l_xsb_box{ \makebox[\box_wd:N\l_xsb_raw_box][l]{ - \makebox[#3][s]{#5} + \makebox[#3][s]{\hbox_unpack:N\l_xsb_raw_box} } } }{ %no colour injection \savebox\l_xsb_box[\box_wd:N\l_xsb_raw_box][l]{ - \makebox[#3][s]{#5} + \makebox[#3][s]{\hbox_unpack:N\l_xsb_raw_box} } } \xsb_process_box:nnnN{#2}{#3}{#4}\l_xsb_box }{ % raw content - \IfBooleanTF{#1}{ - \hbox_set:Nn\l_xsb_raw_box{#5} - }{ - \sbox\l_xsb_raw_box{#5} + \IfBooleanF{#1}{ + \sbox\l_xsb_raw_box{\hbox_unpack:N\l_xsb_raw_box} } \xsb_process_box:nnnN{#2}{#3}{#4}\l_xsb_raw_box } }{ - \IfBooleanTF{#1}{ - \hbox_set:Nn\l_xsb_box{ %content re-aligned - \makebox[#3][#4]{#5} - } - }{ - \savebox\l_xsb_box[#3][#4]{#5} %re-aligned + \IfBooleanF{#1}{ + \savebox\l_xsb_box[#3][#4]{\hbox_unpack:N\l_xsb_raw_box} } \xsb_process_box:nnnN{#2}{\width}{c}\l_xsb_box } @@ -219,7 +210,7 @@ \DeclareDocumentEnvironment{xlrbox*}{m}{ \xsb_check_box_name:n{#1} - \xsb_xlrbox_star: + \xsb_xlrbox: }{ \xsb_endxlrbox_star:n{#1} } @@ -243,27 +234,27 @@ \group_begin: \xsb_push_props: %new, empty properties dict \xsb_beginLTR: - \hbox_set:Nw\l_xsb_box\group_begin: + \hbox_set:Nw\l_xsb_box + \bool_lazy_and:nnF{ %prevent unused boxes from creating OCGs/OCMDs + \tl_if_exist_p:c{xsb@\int_use:N\g_xsb_id_int} + }{ + \bool_if_p:c{c_\tl_use:c{xsb@\int_use:N\g_xsb_id_int}_bool} + }{ + \DeclareDocumentEnvironment{ocg}{O{}mmm}{\ignorespaces}{\unskip} + \DeclareDocumentEnvironment{ocmd}{O{}m}{\ignorespaces}{\unskip} + } \ignorespaces } \cs_new_protected_nopar:Nn\xsb_endxlrbox:n{ \unskip - \group_end:\hbox_set_end: + \hbox_set_end: \sbox\l_xsb_box{\hbox_unpack_drop:N\l_xsb_box} \xsb_process_box:nnnN{#1}{\width}{c}\l_xsb_box \xsb_endLTR: \group_end: } -\cs_new_protected:Nn\xsb_xlrbox_star:{ - \group_begin: - \xsb_push_props: %new, empty properties dict - \xsb_beginLTR: - \hbox_set:Nw\l_xsb_box - \ignorespaces -} - \cs_new_protected_nopar:Nn\xsb_endxlrbox_star:n{ \unskip \hbox_set_end: |