summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xsavebox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-03-07 23:22:38 +0000
committerKarl Berry <karl@freefriends.org>2016-03-07 23:22:38 +0000
commit7a90070ab1c2a78ee48e025706907db2b5fb4384 (patch)
treeffbdbdbfb365f1b7696570815ed5d05fe663940f /Master/texmf-dist/tex/latex/xsavebox
parentd9eed51f22174ef543823392b76a190f3c7f83a4 (diff)
xsavebox (7mar16)
git-svn-id: svn://tug.org/texlive/trunk@39965 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xsavebox')
-rw-r--r--Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty79
1 files changed, 42 insertions, 37 deletions
diff --git a/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty b/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty
index cbbd3b25f76..976507d9545 100644
--- a/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty
+++ b/Master/texmf-dist/tex/latex/xsavebox/xsavebox.sty
@@ -47,9 +47,10 @@
\RequirePackage{xparse}
\RequirePackage{pdfbase} %everything with `pbs_' prefix
+\RequirePackage{l3keys2e}
-\def\g@xsb@version@tl{0.1}
-\def\g@xsb@date@tl{2016/02/25}
+\def\g@xsb@version@tl{0.2}
+\def\g@xsb@date@tl{2016/03/07}
\ProvidesExplPackage{xsavebox}{\g@xsb@date@tl}{\g@xsb@version@tl}
{saveboxes for repeating content without code replication}
@@ -59,11 +60,33 @@
Please~install~an~up~to~date~version~of~`#1'.\\
Loading~xsavebox~will~abort!
}
-\@ifpackagelater{pdfbase}{2016/02/25}{}{
- \msg_error:nnn{xsavebox}{support~outdated}{pdfbase}
+\@ifpackagelater{pdfbase}{2016/03/07}{}{
+ \msg_error:nnn{xsavebox}{support~outdated}{pdfbase.sty}
\tex_endinput:D
}
+%package options
+
+%unknown package option error message
+\msg_set:nnnn{xsavebox}{unknown~package~option}{Unknown~package~option~`#1'.}{
+ Package option~'#1'~is~unknown;\\
+ perhaps~it~is~spelled~incorrectly.
+}
+
+\tl_gset:Nn\g_xsb_margin_tl{3pt}
+\keys_define:nn{xsavebox}{
+ margin .code:n = {
+ \setlength\l_tmpa_dim{#1}
+ \tl_gset:Nx\g_xsb_margin_tl{\dim_use:N\l_tmpa_dim}
+ },
+
+ unknown .code:n = {
+ \msg_error:nnx{xsavebox}{unknown~package~option}{\l_keys_key_tl}
+ }
+}
+
+\ProcessKeysOptions{xsavebox}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% content insertion (referencing, actually)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -107,7 +130,7 @@
\xsb_process_box:nnnN{#2}{#3}{#4}\l_xsb_raw_box
}
}{
- \xsb_process_box:nN{#2}\l_xsb_box
+ \xsb_process_box:nnnN{#2}{\width}{c}\l_xsb_box
}
\group_end:
}
@@ -137,7 +160,7 @@
\unskip
\egroup\egroup
\sbox\l_xsb_box{\hbox_unpack_clear:N\l_xsb_box}
- \xsb_process_box:nN{#1}\l_xsb_box
+ \xsb_process_box:nnnN{#1}{\width}{c}\l_xsb_box
\group_end:
}
@@ -150,35 +173,12 @@
\cs_new_nopar:Nn\xsb_endxlrbox_star:n{
\unskip
\color@endgroup\egroup
- \xsb_process_box:nN{#1}\l_xsb_box
+ \xsb_process_box:nnnN{#1}{\width}{c}\l_xsb_box
\group_end:
}
-\cs_new_nopar:Nn\xsb_process_box:nN{ %process a readily resized (new width) box
- %measure box
- \tl_set:Nx\l_xsb_wd_tl{\dim_use:N\box_wd:N#2}
- \tl_set:Nx\l_xsb_ht_tl{\dim_use:N\box_ht:N#2}
- \tl_set:Nx\l_xsb_dp_tl{\dim_use:N\box_dp:N#2}
- %push the box bounds somewhat to get everything while distilling, as
- %glyphs tend to be larger than their bounding boxes
- \hbox_set_to_wd:Nnn#2{\l_xsb_wd_tl+6pt}{\hss\hbox_unpack_clear:N#2\hss}
- \box_set_ht:Nn#2{\l_xsb_ht_tl+3pt}
- \box_set_dp:Nn#2{\l_xsb_dp_tl+3pt}
- %distill box into PDF Form XObject
- \pbs_pdfxform:nn{0}{#2}%
- %define command for inserting the h-boxed XObject reference
- \tl_gset:cx{the#1}{
- \exp_not:N\hbox_to_wd:nn{\l_xsb_wd_tl}{
- \exp_not:N\vrule~width~\c_zero_dim~height~\l_xsb_ht_tl~
- depth~\l_xsb_dp_tl
- \exp_not:N\skip_horizontal:n{\dim_eval:n{-3pt}}
- \exp_not:N\pbs_pdfrefxform:n{\pbs_pdflastxform:}\hss
- }
- }
-}
-
-\cs_new_nopar:Nn\xsb_process_box:nnnN{ %first distill, then put XObject ref
- %measure natural dimensions into mbox of user defined size
+\cs_new_nopar:Nn\xsb_process_box:nnnN{
+ %measure natural dimensions
\cs_set_nopar:Npn\width {\box_wd:N#4}
\cs_set_nopar:Npn\height{\box_ht:N#4}
\cs_set_nopar:Npn\depth {\box_dp:N#4}
@@ -189,17 +189,22 @@
%evaluate width argument (allowing for calc-type expressions)
\setlength\l_tmpa_dim{#2}
\tl_set:Nx\l_xsb_new_wd_tl{\dim_use:N\l_tmpa_dim}
- \hbox_set_to_wd:Nnn#4{\width+6pt}{\hss\hbox_unpack_clear:N#4\hss}
- \box_set_ht:Nn#4{\height+3pt}
- \box_set_dp:Nn#4{\depth+3pt}
- \pbs_pdfxform:nn{0}{#4}%
+ %temporarily (for distilling) push the box bounds somewhat; glyphs tend to
+ %be bigger than their bounding boxes
+ \hbox_set_to_wd:Nnn#4{\width+\g_xsb_margin_tl+\g_xsb_margin_tl}{
+ \hss\hbox_unpack_clear:N#4\hss
+ }
+ \box_set_ht:Nn#4{\height+\g_xsb_margin_tl}
+ \box_set_dp:Nn#4{\depth+\g_xsb_margin_tl}
+ %distill box to Form XObject
+ \pbs_pdfxform:nnn{1}{0}{#4}
%define command for inserting the m-boxed XObject reference
\tl_gset:cx{the#1}{
\exp_not:N\makebox[\l_xsb_new_wd_tl][#3]{
\exp_not:N\hbox_to_wd:nn{\l_xsb_wd_tl}{
\exp_not:N\vrule~width~\c_zero_dim~height~\l_xsb_ht_tl~
depth~\l_xsb_dp_tl
- \exp_not:N\skip_horizontal:n{\dim_eval:n{-3pt}}
+ \exp_not:N\skip_horizontal:n{-\g_xsb_margin_tl}
\exp_not:N\pbs_pdfrefxform:n{\pbs_pdflastxform:}\hss
}
}