summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3box.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3box.dtx963
1 files changed, 124 insertions, 839 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
index 8ec1f62babe..b578295ac44 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3box.dtx 3490 2012-03-04 01:00:53Z bruno $
+\GetIdInfo$Id: l3box.dtx 3986 2012-07-15 19:23:51Z joseph $
{L3 Experimental boxes}
%</driver|package>
%<*driver>
@@ -106,9 +106,9 @@
% \box_gset_eq:NN, \box_gset_eq:cN, \box_gset_eq:Nc, \box_gset_eq:cc
% }
% \begin{syntax}
-% \cs{box_set_eq:NN} \meta{box1} \meta{box2}
+% \cs{box_set_eq:NN} \meta{box_1} \meta{box_2}
% \end{syntax}
-% Sets the content of \meta{box1} equal to that of \meta{box2}.
+% Sets the content of \meta{box_1} equal to that of \meta{box_2}.
% \end{function}
%
% \begin{function}
@@ -117,10 +117,10 @@
% \box_set_eq_clear:Nc, \box_set_eq_clear:cc
% }
% \begin{syntax}
-% \cs{box_set_eq_clear:NN} \meta{box1} \meta{box2}
+% \cs{box_set_eq_clear:NN} \meta{box_1} \meta{box_2}
% \end{syntax}
-% Sets the content of \meta{box1} within the current \TeX{} group
-% equal to that of \meta{box2}, then clears \meta{box2} globally.
+% Sets the content of \meta{box_1} within the current \TeX{} group
+% equal to that of \meta{box_2}, then clears \meta{box_2} globally.
% \end{function}
%
% \begin{function}
@@ -129,10 +129,10 @@
% \box_gset_eq_clear:Nc, \box_gset_eq_clear:cc
% }
% \begin{syntax}
-% \cs{box_gset_eq_clear:NN} \meta{box1} \meta{box2}
+% \cs{box_gset_eq_clear:NN} \meta{box_1} \meta{box_2}
% \end{syntax}
-% Sets the content of \meta{box1} equal to that of \meta{box2}, then
-% clears \meta{box2}. These assignments are global.
+% Sets the content of \meta{box_1} equal to that of \meta{box_2}, then
+% clears \meta{box_2}. These assignments are global.
% \end{function}
%
% \begin{function}[EXP, pTF, added=2012-03-03]
@@ -255,153 +255,6 @@
% \Arg{dimension expression}. This is a global assignment.
% \end{function}
%
-% \section{Affine transformations}
-%
-% Affine transformations are changes which (informally) preserve straight
-% lines. Simple translations are affine transformations, but are better handled
-% in \TeX{} by doing the translation first, then inserting an unmodified box.
-% On the other hand, rotation and resizing of boxed material can best be
-% handled by modifying boxes. These transformations are described here.
-%
-% \begin{function}[added = 2011-09-02]{\box_resize:Nnn, \box_resize:cnn}
-% \begin{syntax}
-% \cs{box_resize:Nnn} \meta{box} \Arg{x-size} \Arg{y-size}
-% \end{syntax}
-% Resize the \meta{box} to \meta{x-size} horizontally and \meta{y-size}
-% vertically (both of the sizes are dimension expressions).
-% The \meta{y-size} is the vertical size (height plus depth) of
-% the box. The updated \meta{box} will be an hbox, irrespective of the nature
-% of the \meta{box} before the resizing is applied. Negative sizes will
-% cause the material in the \meta{box} to be reversed in direction, but the
-% reference point of the \meta{box} will be unchanged. The resizing applies
-% within the current \TeX{} group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
-% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
-% {\box_resize_to_ht_plus_dp:Nn, \box_resize_to_ht_plus_dp:cn}
-% \begin{syntax}
-% \cs{box_resize_to_ht_plus_dp:Nn} \meta{box} \Arg{y-size}
-% \end{syntax}
-% Resize the \meta{box} to \meta{y-size} vertically, scaling the horizontal
-% size by the same amount (\meta{y-size} is a dimension expression).
-% The \meta{y-size} is the vertical size (height plus depth) of
-% the box.
-% The updated \meta{box} will be an hbox, irrespective of the nature
-% of the \meta{box} before the resizing is applied. A negative size will
-% cause the material in the \meta{box} to be reversed in direction, but the
-% reference point of the \meta{box} will be unchanged. The resizing applies
-% within the current \TeX{} group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
-% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
-% {\box_resize_to_wd:Nn, \box_resize_to_wd:cn}
-% \begin{syntax}
-% \cs{box_resize_to_wd:Nn} \meta{box} \Arg{x-size}
-% \end{syntax}
-% Resize the \meta{box} to \meta{x-size} horizontally, scaling the vertical
-% size by the same amount (\meta{x-size} is a dimension expression).
-% The updated \meta{box} will be an hbox, irrespective of the nature
-% of the \meta{box} before the resizing is applied. A negative size will
-% cause the material in the \meta{box} to be reversed in direction, but the
-% reference point of the \meta{box} will be unchanged. The resizing applies
-% within the current \TeX{} group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
-% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
-% {\box_rotate:Nn, \box_rotate:cn}
-% \begin{syntax}
-% \cs{box_rotate:Nn} \meta{box} \Arg{angle}
-% \end{syntax}
-% Rotates the \meta{box} by \meta{angle} (in degrees) anti-clockwise about
-% its reference point. The reference point of the updated box will be moved
-% horizontally such that it is at the left side of the smallest rectangle
-% enclosing the rotated material.
-% The updated \meta{box} will be an hbox, irrespective of the nature
-% of the \meta{box} before the rotation is applied. The rotation applies
-% within the current \TeX{} group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
-% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
-% {\box_scale:Nnn, \box_scale:cnn}
-% \begin{syntax}
-% \cs{box_scale:Nnn} \meta{box} \Arg{x-scale} \Arg{y-scale}
-% \end{syntax}
-% Scales the \meta{box} by factors \meta{x-scale} and \meta{y-scale} in
-% the horizontal and vertical directions, respectively (both scales are
-% integer expressions). The updated \meta{box} will be an hbox, irrespective
-% of the nature of the \meta{box} before the scaling is applied. Negative
-% scalings will cause the material in the \meta{box} to be reversed in
-% direction, but the reference point of the \meta{box} will be unchanged.
-% The scaling applies within the current \TeX{} group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
-% \section{Viewing part of a box}
-%
-% \begin{function}[added = 2011-11-13]{\box_clip:N, \box_clip:c}
-% \begin{syntax}
-% \cs{box_clip:N} \meta{box}
-% \end{syntax}
-% Clips the \meta{box} in the output so that only material inside the
-% bounding box is displayed in the output. The updated \meta{box} will be an
-% hbox, irrespective of the nature of the \meta{box} before the clipping is
-% applied. The clipping applies within the current \TeX{} group level.
-%
-% \textbf{This function is experimental}
-% \begin{texnote}
-% Clipping is implemented by the driver, and as such the full content of
-% the box is places in the output file. Thus clipping does not remove
-% any information from the raw output, and hidden material can therefore
-% be viewed by direct examination of the file.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}[added = 2011-11-13]
-% {\box_trim:Nnnnn, \box_trim:cnnnn}
-% \begin{syntax}
-% \cs{box_trim:Nnnnn} \meta{box} \Arg{left} \Arg{bottom} \Arg{right} \Arg{top}
-% \end{syntax}
-% Adjusts the bounding box of the \meta{box} \meta{left} is removed from
-% the left-hand edge of the bounding box, \meta{right} from the right-hand
-% edge and so fourth. All adjustments are \meta{dimension expressions}.
-% Material output of the bounding box will still be displayed in the output
-% unless \cs{box_clip:N} is subsequently applied.
-% The updated \meta{box} will be an
-% hbox, irrespective of the nature of the \meta{box} before the viewport
-% operation is applied. The clipping applies within the current \TeX{}
-% group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
-% \begin{function}[added = 2011-11-13]
-% {\box_viewport:Nnnnn, \box_viewport:cnnnn}
-% \begin{syntax}
-% \cs{box_viewport:Nnnnn} \meta{box} \Arg{llx} \Arg{lly} \Arg{urx} \Arg{ury}
-% \end{syntax}
-% Adjusts the bounding box of the \meta{box} such that it has lower-left
-% co-ordinates (\meta{llx}, \meta{lly}) and upper-right co-ordinates
-% (\meta{urx}, \meta{ury}). All four co-ordinate positions are
-% \meta{dimension expressions}. Material output of the bounding box will
-% still be displayed in the output unless \cs{box_clip:N} is
-% subsequently applied.
-% The updated \meta{box} will be an
-% hbox, irrespective of the nature of the \meta{box} before the viewport
-% operation is applied. The clipping applies within the current \TeX{}
-% group level.
-%
-% \textbf{This function is experimental}
-% \end{function}
-%
% \section{Box conditionals}
%
% \begin{function}[EXP,pTF]{\box_if_empty:N, \box_if_empty:c}
@@ -460,16 +313,45 @@
% code and so should only be used for short-term storage.
% \end{variable}
%
+% \begin{variable}{\g_tmpa_box, \g_tmpb_box}
+% Scratch boxes for global assignment. These are never used by
+% the kernel code, and so are safe for use with any \LaTeX3-defined
+% function. However, they may be overwritten by other non-kernel
+% code and so should only be used for short-term storage.
+% \end{variable}
+%
% \section{Viewing box contents}
%
-% \begin{function}{\box_show:N, \box_show:c}
+% \begin{function}[updated = 2012-05-11]{\box_show:N, \box_show:c}
% \begin{syntax}
% \cs{box_show:N} \meta{box}
% \end{syntax}
-% Writes the contents of \meta{box} to the log file.
-% \begin{texnote}
-% This is a wrapper around the \TeX{} primitive \tn{showbox}.
-% \end{texnote}
+% Shows full details of the content of the \meta{box} in the terminal.
+% \end{function}
+%
+% \begin{function}[added = 2012-05-11]{\box_show:Nnn, \box_show:cnn}
+% \begin{syntax}
+% \cs{box_show:Nnn} \meta{box} \meta{intexpr_1} \meta{intexpr_2}
+% \end{syntax}
+% Display the contents of \meta{box} in the terminal, showing the first
+% \meta{intexpr_1} items of the box, and descending into \meta{intexpr_2}
+% group levels.
+% \end{function}
+%
+% \begin{function}[added = 2012-05-11]{\box_log:N, \box_log:c}
+% \begin{syntax}
+% \cs{box_show:N} \meta{box}
+% \end{syntax}
+% Writes full details of the content of the \meta{box} to the log.
+% \end{function}
+%
+% \begin{function}[added = 2012-05-11]{\box_log:Nnn, \box_log:cnn}
+% \begin{syntax}
+% \cs{box_show:Nnn} \meta{box} \meta{intexpr_1} \meta{intexpr_2}
+% \end{syntax}
+% Writes the contents of \meta{box} to the log, showing the first
+% \meta{intexpr_1} items of the box, and descending into \meta{intexpr_2}
+% group levels.
% \end{function}
%
% \section{Horizontal mode boxes}
@@ -671,7 +553,7 @@
% \vbox_gset_end:
% }
% \begin{syntax}
-% \cs{vbox_begin:Nw} \meta{box} \meta{contents} \cs{vbox_set_end:}
+% \cs{vbox_set:Nw} \meta{box} \meta{contents} \cs{vbox_set_end:}
% \end{syntax}
% Typesets the \meta{contents} at natural height and then stores the
% result inside the \meta{box}. In contrast
@@ -682,10 +564,10 @@
%
% \begin{function}[updated = 2011-10-22]{\vbox_set_split_to_ht:NNn}
% \begin{syntax}
-% \cs{vbox_set_split_to_ht:NNn} \meta{box1} \meta{box2} \Arg{dimexpr}
+% \cs{vbox_set_split_to_ht:NNn} \meta{box_1} \meta{box_2} \Arg{dimexpr}
% \end{syntax}
-% Sets \meta{box1} to contain material to the height given by the
-% \meta{dimexpr} by removing content from the top of \meta{box2}
+% Sets \meta{box_1} to contain material to the height given by the
+% \meta{dimexpr} by removing content from the top of \meta{box_2}
% (which must be a vertical box).
% \begin{texnote}
% This is the \TeX{} primitive \tn{vsplit}.
@@ -759,29 +641,6 @@
% \end{texnote}
% \end{function}
%
-% \section{Experimental box functions}
-%
-% \begin{function}[added = 2011-11-21]{\box_show:Nnn, \box_show:cnn}
-% \begin{syntax}
-% \cs{box_show:Nnn} \meta{box} \meta{int 1} \meta{int 2}
-% \end{syntax}
-% Display the contents of \meta{box} in the terminal,
-% showing the first \meta{int 1} items of the box,
-% and descending into \meta{int 1} levels of nesting.
-% \begin{texnote}
-% This is a wrapper around the \TeX{} primitives \tn{showbox},
-% \tn{showboxbreadth} and \tn{showboxdepth}.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}[added = 2011-11-22]{\box_show_full:N, \box_show_full:c}
-% \begin{syntax}
-% \cs{box_show_full:N} \meta{box}
-% \end{syntax}
-% Display the contents of \meta{box} in the terminal,
-% showing all items in the box.
-% \end{function}
-%
% \end{documentation}
%
% \begin{implementation}
@@ -791,12 +650,16 @@
% \begin{macrocode}
%<*initex|package>
% \end{macrocode}
+%
+% \begin{macrocode}
+%<@@=box>
+% \end{macrocode}
%
% \begin{macrocode}
%<*package>
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
-\package_check_loaded_expl:
+\__expl_package_check:
%</package>
% \end{macrocode}
%
@@ -814,7 +677,7 @@
%<*package>
\cs_new_protected:Npn \box_new:N #1
{
- \chk_if_free_cs:N #1
+ \__chk_if_free_cs:N #1
\newbox #1
}
%</package>
@@ -863,8 +726,8 @@
{ \tex_setbox:D #1 \tex_copy:D #2 }
\cs_new_protected:Npn \box_gset_eq:NN
{ \tex_global:D \box_set_eq:NN }
-\cs_generate_variant:Nn \box_set_eq:NN { cN , Nc , cc }
-\cs_generate_variant:Nn \box_gset_eq:NN { cN , Nc , cc }
+\cs_generate_variant:Nn \box_set_eq:NN { c , Nc , cc }
+\cs_generate_variant:Nn \box_gset_eq:NN { c , Nc , cc }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -888,8 +751,8 @@
{ \tex_setbox:D #1 \tex_box:D #2 }
\cs_new_protected:Npn \box_gset_eq_clear:NN
{ \tex_global:D \box_set_eq_clear:NN }
-\cs_generate_variant:Nn \box_set_eq_clear:NN { cN , Nc , cc }
-\cs_generate_variant:Nn \box_gset_eq_clear:NN { cN , Nc , cc }
+\cs_generate_variant:Nn \box_set_eq_clear:NN { c , Nc , cc }
+\cs_generate_variant:Nn \box_gset_eq_clear:NN { c , Nc , cc }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -934,11 +797,11 @@
% expandable, so the derived functions are not either.
% \begin{macrocode}
\cs_new_protected:Npn \box_set_dp:Nn #1#2
- { \box_dp:N #1 \dim_eval:w #2 \dim_eval_end: }
+ { \box_dp:N #1 \__dim_eval:w #2 \__dim_eval_end: }
\cs_new_protected:Npn \box_set_ht:Nn #1#2
- { \box_ht:N #1 \dim_eval:w #2 \dim_eval_end: }
+ { \box_ht:N #1 \__dim_eval:w #2 \__dim_eval_end: }
\cs_new_protected:Npn \box_set_wd:Nn #1#2
- { \box_wd:N #1 \dim_eval:w #2 \dim_eval_end: }
+ { \box_wd:N #1 \__dim_eval:w #2 \__dim_eval_end: }
\cs_generate_variant:Nn \box_set_ht:Nn { c }
\cs_generate_variant:Nn \box_set_dp:Nn { c }
\cs_generate_variant:Nn \box_set_wd:Nn { c }
@@ -968,13 +831,13 @@
% Move box material in different directions.
% \begin{macrocode}
\cs_new_protected:Npn \box_move_left:nn #1#2
- { \tex_moveleft:D \dim_eval:w #1 \dim_eval_end: #2 }
+ { \tex_moveleft:D \__dim_eval:w #1 \__dim_eval_end: #2 }
\cs_new_protected:Npn \box_move_right:nn #1#2
- { \tex_moveright:D \dim_eval:w #1 \dim_eval_end: #2 }
+ { \tex_moveright:D \__dim_eval:w #1 \__dim_eval_end: #2 }
\cs_new_protected:Npn \box_move_up:nn #1#2
- { \tex_raise:D \dim_eval:w #1 \dim_eval_end: #2 }
+ { \tex_raise:D \__dim_eval:w #1 \__dim_eval_end: #2 }
\cs_new_protected:Npn \box_move_down:nn #1#2
- { \tex_lower:D \dim_eval:w #1 \dim_eval_end: #2 }
+ { \tex_lower:D \__dim_eval:w #1 \__dim_eval_end: #2 }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1063,7 +926,8 @@
%
% \subsection{Scratch boxes}
%
-% \begin{variable}{\l_tmpa_box, \l_tmpb_box}
+% \begin{variable}{\l_tmpa_box, \l_tmpb_box, \g_tmpa_box, \g_tmpb_box}
+% Reuse the \LaTeXe{} scratch box in package mode.
% \begin{macrocode}
%<*package>
\cs_new_eq:NN \l_tmpa_box \@tempboxa
@@ -1072,52 +936,78 @@
\box_new:N \l_tmpa_box
%</initex>
\box_new:N \l_tmpb_box
+\box_new:N \g_tmpa_box
+\box_new:N \g_tmpb_box
% \end{macrocode}
% \end{variable}
%
% \subsection{Viewing box contents}
+%
+% \TeX{}'s \tn{tex_showbox:D} is not really that helpful in many cases, and
+% it is also inconsistent with other \LaTeX3{} \texttt{show} functions as it
+% does not actually shows material in the terminal. So we provide a richer
+% set of functionality.
%
% \begin{macro}{\box_show:N, \box_show:c}
-% \testfile*
-% Check that the variable exists, then show the contents of the box
-% and write it into the log file. The spurious \cs{use:n} gives
-% a nicer output.
+% \begin{macro}{\box_show:Nnn, \box_show:cnn}
+% Essentially a wrapper around the internal function.
% \begin{macrocode}
\cs_new_protected:Npn \box_show:N #1
+ { \box_show:Nnn #1 \c_max_int \c_max_int }
+\cs_generate_variant:Nn \box_show:N { c }
+\cs_new_protected_nopar:Npn \box_show:Nnn
+ { \@@_show:NNnn \c_one }
+\cs_generate_variant:Nn \box_show:Nnn { c }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\box_log:N, \box_log:c}
+% \begin{macro}{\box_log:Nnn, \box_log:cnn}
+% Getting \TeX{} to write to the log without interruption the run is done by
+% altering the interaction mode. For that, the \eTeX{} extensions are needed.
+% \begin{macrocode}
+\cs_new_protected:Npn \box_log:N #1
+ { \box_log:Nnn #1 \c_max_int \c_max_int }
+\cs_generate_variant:Nn \box_log:N { c }
+\cs_new_protected:Npn \box_log:Nnn #1#2#3
{
- \box_if_exist:NTF #1
- { \tex_showbox:D \use:n {#1} }
+ \use:x
{
- \msg_kernel_error:nnx { kernel } { variable-not-defined }
- { \token_to_str:N #1 }
+ \etex_interactionmode:D \c_zero
+ \@@_show:NNnn \c_zero \exp_not:N #1
+ { \int_eval:n {#2} } { \int_eval:n {#3} }
+ \etex_interactionmode:D
+ = \tex_the:D \etex_interactionmode:D \scan_stop:
}
}
-\cs_generate_variant:Nn \box_show:N { c }
+\cs_generate_variant:Nn \box_log:Nnn { c }
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\box_show:Nnn, \box_show:cnn}
-% \begin{macro}{\box_show_full:N, \box_show_full:c}
-% Show the contents of a box and write it into the log file,
-% after setting the parameters \tn{showboxbreadth} and \tn{showboxdepth}
-% to the values provided by the user.
+% \end{macro}
+%
+% \begin{macro}[aux]{\@@_show:NNnn}
+% The internal auxiliary to actually do the output uses a group to deal
+% with breadth and depth values. The \cs{use:n} here gives better output
+% appearance. Setting \tn{tex_tracingonline:D} is used to control what
+% appears in the terminal.
% \begin{macrocode}
-\cs_new_protected:Npn \box_show:Nnn #1#2#3
+\cs_new_protected:Npn \@@_show:NNnn #1#2#3#4
{
\group_begin:
- \int_set:Nn \tex_showboxbreadth:D {#2}
- \int_set:Nn \tex_showboxdepth:D {#3}
- \int_set_eq:NN \tex_tracingonline:D \c_one
- \box_show:N #1
+ \int_set:Nn \tex_showboxbreadth:D {#3}
+ \int_set:Nn \tex_showboxdepth:D {#4}
+ \int_set_eq:NN \tex_tracingonline:D #1
+ \box_if_exist:NTF #2
+ { \tex_showbox:D \use:n {#2} }
+ {
+ \__msg_kernel_error:nnx { kernel } { variable-not-defined }
+ { \token_to_str:N #2 }
+ }
\group_end:
}
-\cs_generate_variant:Nn \box_show:Nnn { c }
-\cs_new_protected:Npn \box_show_full:N #1
- { \box_show:Nnn #1 { \c_max_int } { \c_max_int } }
-\cs_generate_variant:Nn \box_show_full:N { c }
% \end{macrocode}
% \end{macro}
-% \end{macro}
%
% \subsection{Horizontal mode boxes}
%
@@ -1147,7 +1037,7 @@
% Storing material in a horizontal box with a specified width.
% \begin{macrocode}
\cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3
- { \tex_setbox:D #1 \tex_hbox:D to \dim_eval:w #2 \dim_eval_end: {#3} }
+ { \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end: {#3} }
\cs_new_protected:Npn \hbox_gset_to_wd:Nnn
{ \tex_global:D \hbox_set_to_wd:Nnn }
\cs_generate_variant:Nn \hbox_set_to_wd:Nnn { c }
@@ -1199,7 +1089,7 @@
% Put a horizontal box directly into the input stream.
% \begin{macrocode}
\cs_new_protected:Npn \hbox_to_wd:nn #1#2
- { \tex_hbox:D to \dim_eval:w #1 \dim_eval_end: {#2} }
+ { \tex_hbox:D to \__dim_eval:w #1 \__dim_eval_end: {#2} }
\cs_new_protected:Npn \hbox_to_zero:n #1 { \tex_hbox:D to \c_zero_skip {#1} }
% \end{macrocode}
% \end{macro}
@@ -1253,7 +1143,7 @@
% Put a vertical box directly into the input stream.
% \begin{macrocode}
\cs_new_protected:Npn \vbox_to_ht:nn #1#2
- { \tex_vbox:D to \dim_eval:w #1 \dim_eval_end: { #2 \par } }
+ { \tex_vbox:D to \__dim_eval:w #1 \__dim_eval_end: { #2 \par } }
\cs_new_protected:Npn \vbox_to_zero:n #1
{ \tex_vbox:D to \c_zero_dim { #1 \par } }
% \end{macrocode}
@@ -1296,7 +1186,7 @@
% Storing material in a vertical box with a specified height.
% \begin{macrocode}
\cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3
- { \tex_setbox:D #1 \tex_vbox:D to \dim_eval:w #2 \dim_eval_end: { #3 \par } }
+ { \tex_setbox:D #1 \tex_vbox:D to \__dim_eval:w #2 \__dim_eval_end: { #3 \par } }
\cs_new_protected:Npn \vbox_gset_to_ht:Nnn
{ \tex_global:D \vbox_set_to_ht:Nnn }
\cs_generate_variant:Nn \vbox_set_to_ht:Nnn { c }
@@ -1366,614 +1256,7 @@
% Splitting a vertical box in two.
% \begin{macrocode}
\cs_new_protected:Npn \vbox_set_split_to_ht:NNn #1#2#3
- { \tex_setbox:D #1 \tex_vsplit:D #2 to \dim_eval:w #3 \dim_eval_end: }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Affine transformations}
-%
-% \begin{variable}{\l_box_angle_fp}
-% When rotating boxes, the angle itself may be needed by the
-% engine-dependent code. This is done using the \pkg{fp} module so
-% that the value is tidied up properly.
-% \begin{macrocode}
-\fp_new:N \l_box_angle_fp
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_box_cos_fp, \l_box_sin_fp}
-% These are used to hold the calculated sine and cosine values while
-% carrying out a rotation.
-% \begin{macrocode}
-\fp_new:N \l_box_cos_fp
-\fp_new:N \l_box_sin_fp
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}
-% {\l_box_top_dim, \l_box_bottom_dim, \l_box_left_dim, \l_box_right_dim}
-% These are the positions of the four edges of a box before
-% manipulation.
-% \begin{macrocode}
-\dim_new:N \l_box_top_dim
-\dim_new:N \l_box_bottom_dim
-\dim_new:N \l_box_left_dim
-\dim_new:N \l_box_right_dim
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}
-% {
-% \l_box_top_new_dim, \l_box_bottom_new_dim ,
-% \l_box_left_new_dim, \l_box_right_new_dim
-% }
-% These are the positions of the four edges of a box after
-% manipulation.
-% \begin{macrocode}
-\dim_new:N \l_box_top_new_dim
-\dim_new:N \l_box_bottom_new_dim
-\dim_new:N \l_box_left_new_dim
-\dim_new:N \l_box_right_new_dim
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_box_internal_box, \l_box_internal_fp}
-% Scratch space.
-% \begin{macrocode}
-\box_new:N \l_box_internal_box
-\fp_new:N \l_box_internal_fp
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_box_x_fp, \l_box_y_fp, \l_box_x_new_fp, \l_box_y_new_fp}
-% Used as the input and output values for a point when manipulation the
-% location.
-% \begin{macrocode}
-\fp_new:N \l_box_x_fp
-\fp_new:N \l_box_y_fp
-\fp_new:N \l_box_x_new_fp
-\fp_new:N \l_box_y_new_fp
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{macro}{\box_rotate:Nn}
-% \begin{macro}[aux]{\box_rotate_aux:N}
-% \begin{macro}[aux]{\box_rotate_set_sin_cos:}
-% \begin{macro}[aux]{\box_rotate_x:nnN, \box_rotate_y:nnN}
-% \begin{macro}[aux]
-% {
-% \box_rotate_quadrant_one:, \box_rotate_quadrant_two:,
-% \box_rotate_quadrant_three:, \box_rotate_quadrant_four:
-% }
-% Rotation of a box starts with working out the relevant sine and
-% cosine. There is then a check to avoid doing any real work for the
-% trivial rotation.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_rotate:Nn #1#2
- {
- \hbox_set:Nn #1
- {
- \group_begin:
- \fp_set:Nn \l_box_angle_fp {#2}
- \box_rotate_set_sin_cos:
- \fp_compare:NNNTF \l_box_sin_fp = \c_zero_fp
- {
- \fp_compare:NNNTF \l_box_cos_fp = \c_one_fp
- { \box_use:N #1 }
- { \box_rotate_aux:N #1 }
- }
- { \box_rotate_aux:N #1 }
- \group_end:
- }
- }
-% \end{macrocode}
-% The edges of the box are then recorded: the left edge will
-% always be at zero. Rotation of the four edges then takes place: this is
-% most efficiently done on a quadrant by quadrant basis.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_rotate_aux:N #1
- {
- \dim_set:Nn \l_box_top_dim { \box_ht:N #1 }
- \dim_set:Nn \l_box_bottom_dim { -\box_dp:N #1 }
- \dim_set:Nn \l_box_right_dim { \box_wd:N #1 }
- \dim_zero:N \l_box_left_dim
-% \end{macrocode}
-% The next step is to work out the $x$ and $y$ coordinates of vertices of
-% the rotated box in relation to its original coordinates. The box can be
-% visualized with vertices $B$, $C$, $D$ and $E$ is illustrated
-% (Figure~\ref{fig:rotation}). The vertex $O$ is the reference point on the
-% baseline, and in this implementation is also the centre of rotation.
-% \begin{figure}
-% \centering
-% \setlength{\unitlength}{3pt}^^A
-% \begin{picture}(34,36)(12,44)
-% \thicklines
-% \put(20,52){\dashbox{1}(20,21){}}
-% \put(20,80){\line(0,-1){36}}
-% \put(12,58){\line(1, 0){34}}
-% \put(41,59){A}
-% \put(40,74){B}
-% \put(21,74){C}
-% \put(21,49){D}
-% \put(40,49){E}
-% \put(21,59){O}
-% \end{picture}
-% \caption{Co-ordinates of a box prior to rotation.}
-% \label{fig:rotation}
-% \end{figure}
-% The formulae are, for a point $P$ and angle $\alpha$:
-% \[
-% \begin{array}{l}
-% P'_x = P_x - O_x \\
-% P'_y = P_y - O_y \\
-% P''_x = ( P'_x \cos(\alpha)) - ( P'_y \sin(\alpha) ) \\
-% P''_y = ( P'_x \sin(\alpha)) + ( P'_y \cos(\alpha) ) \\
-% P'''_x = P''_x + O_x + L_x \\
-% P'''_y = P''_y + O_y
-% \end{array}
-% \]
-% The \enquote{extra} horizontal translation $L_x$ at the end is calculated
-% so that the leftmost point of the resulting box has $x$-coordinate $0$.
-% This is desirable as \TeX{} boxes must have the reference point at
-% the left edge of the box. (As $O$ is always $(0,0)$, this part of the
-% calculation is omitted here.)
-% \begin{macrocode}
- \fp_compare:NNNTF \l_box_sin_fp > \c_zero_fp
- {
- \fp_compare:NNNTF \l_box_cos_fp > \c_zero_fp
- { \box_rotate_quadrant_one: }
- { \box_rotate_quadrant_two: }
- }
- {
- \fp_compare:NNNTF \l_box_cos_fp < \c_zero_fp
- { \box_rotate_quadrant_three: }
- { \box_rotate_quadrant_four: }
- }
-% \end{macrocode}
-% The position of the box edges are now known, but the box at this
-% stage be misplaced relative to the current \TeX{} reference point. So the
-% content of the box is moved such that the reference point of the
-% rotated box will be in the same place as the original.
-% \begin{macrocode}
- \hbox_set:Nn \l_box_internal_box { \box_use:N #1 }
- \hbox_set:Nn \l_box_internal_box
- {
- \tex_kern:D -\l_box_left_new_dim
- \hbox:n
- {
- \driver_box_rotate_begin:
- \box_use:N \l_box_internal_box
- \driver_box_rotate_end:
- }
- }
-% \end{macrocode}
-% Tidy up the size of the box so that the material is actually inside
-% the bounding box. The result can then be used to reset the original
-% box.
-% \begin{macrocode}
- \box_set_ht:Nn \l_box_internal_box { \l_box_top_new_dim }
- \box_set_dp:Nn \l_box_internal_box { -\l_box_bottom_new_dim }
- \box_set_wd:Nn \l_box_internal_box
- { \l_box_right_new_dim - \l_box_left_new_dim }
- \box_use:N \l_box_internal_box
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% A simple conversion from degrees to radians followed by calculation
-% of the sine and cosine.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_rotate_set_sin_cos:
- {
- \fp_set_eq:NN \l_box_internal_fp \l_box_angle_fp
- \fp_div:Nn \l_box_internal_fp { 180 }
- \fp_mul:Nn \l_box_internal_fp { \c_pi_fp }
- \fp_sin:Nn \l_box_sin_fp { \l_box_internal_fp }
- \fp_cos:Nn \l_box_cos_fp { \l_box_internal_fp }
- }
-% \end{macrocode}
-% These functions take a general point $(|#1|, |#2|)$ and rotate its
-% location about the origin, using the previously-set sine and cosine
-% values. Each function gives only one component of the location of the
-% updated point. This is because for rotation of a box each step needs
-% only one value, and so performance is gained by avoiding working
-% out both $x'$ and $y'$ at the same time. Contrast this with
-% the equivalent function in the \pkg{l3coffins} module, where both parts
-% are needed.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_rotate_x:nnN #1#2#3
- {
- \fp_set_from_dim:Nn \l_box_x_fp {#1}
- \fp_set_from_dim:Nn \l_box_y_fp {#2}
- \fp_set_eq:NN \l_box_x_new_fp \l_box_x_fp
- \fp_set_eq:NN \l_box_internal_fp \l_box_y_fp
- \fp_mul:Nn \l_box_x_new_fp { \l_box_cos_fp }
- \fp_mul:Nn \l_box_internal_fp { \l_box_sin_fp }
- \fp_sub:Nn \l_box_x_new_fp { \l_box_internal_fp }
- \dim_set:Nn #3 { \fp_to_dim:N \l_box_x_new_fp }
- }
-\cs_new_protected:Npn \box_rotate_y:nnN #1#2#3
- {
- \fp_set_from_dim:Nn \l_box_x_fp {#1}
- \fp_set_from_dim:Nn \l_box_y_fp {#2}
- \fp_set_eq:NN \l_box_y_new_fp \l_box_y_fp
- \fp_set_eq:NN \l_box_internal_fp \l_box_x_fp
- \fp_mul:Nn \l_box_y_new_fp { \l_box_cos_fp }
- \fp_mul:Nn \l_box_internal_fp { \l_box_sin_fp }
- \fp_add:Nn \l_box_y_new_fp { \l_box_internal_fp }
- \dim_set:Nn #3 { \fp_to_dim:N \l_box_y_new_fp }
-}
-% \end{macrocode}
-% Rotation of the edges is done using a different formula for each
-% quadrant. In every case, the top and bottom edges only need the
-% resulting $y$-values, whereas the left and right edges need the
-% $x$-values. Each case is a question of picking out which corner
-% ends up at with the maximum top, bottom, left and right value. Doing
-% this by hand means a lot less calculating and avoids lots of
-% comparisons.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_rotate_quadrant_one:
- {
- \box_rotate_y:nnN \l_box_right_dim \l_box_top_dim
- \l_box_top_new_dim
- \box_rotate_y:nnN \l_box_left_dim \l_box_bottom_dim
- \l_box_bottom_new_dim
- \box_rotate_x:nnN \l_box_left_dim \l_box_top_dim
- \l_box_left_new_dim
- \box_rotate_x:nnN \l_box_right_dim \l_box_bottom_dim
- \l_box_right_new_dim
- }
-\cs_new_protected:Npn \box_rotate_quadrant_two:
- {
- \box_rotate_y:nnN \l_box_right_dim \l_box_bottom_dim
- \l_box_top_new_dim
- \box_rotate_y:nnN \l_box_left_dim \l_box_top_dim
- \l_box_bottom_new_dim
- \box_rotate_x:nnN \l_box_right_dim \l_box_top_dim
- \l_box_left_new_dim
- \box_rotate_x:nnN \l_box_left_dim \l_box_bottom_dim
- \l_box_right_new_dim
- }
-\cs_new_protected:Npn \box_rotate_quadrant_three:
- {
- \box_rotate_y:nnN \l_box_left_dim \l_box_bottom_dim
- \l_box_top_new_dim
- \box_rotate_y:nnN \l_box_right_dim \l_box_top_dim
- \l_box_bottom_new_dim
- \box_rotate_x:nnN \l_box_right_dim \l_box_bottom_dim
- \l_box_left_new_dim
- \box_rotate_x:nnN \l_box_left_dim \l_box_top_dim
- \l_box_right_new_dim
- }
-\cs_new_protected:Npn \box_rotate_quadrant_four:
- {
- \box_rotate_y:nnN \l_box_left_dim \l_box_top_dim
- \l_box_top_new_dim
- \box_rotate_y:nnN \l_box_right_dim \l_box_bottom_dim
- \l_box_bottom_new_dim
- \box_rotate_x:nnN \l_box_left_dim \l_box_bottom_dim
- \l_box_left_new_dim
- \box_rotate_x:nnN \l_box_right_dim \l_box_top_dim
- \l_box_right_new_dim
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{variable}{\l_box_scale_x_fp, \l_box_scale_y_fp}
-% Scaling is potentially-different in the two axes.
-% \begin{macrocode}
-\fp_new:N \l_box_scale_x_fp
-\fp_new:N \l_box_scale_y_fp
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{macro}{\box_resize:Nnn, \box_resize:cnn}
-% \begin{macro}[aux]{\box_resize_aux:Nnn}
-% Resizing a box starts by working out the various dimensions of the
-% existing box.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_resize:Nnn #1#2#3
- {
- \hbox_set:Nn #1
- {
- \group_begin:
- \dim_set:Nn \l_box_top_dim { \box_ht:N #1 }
- \dim_set:Nn \l_box_bottom_dim { -\box_dp:N #1 }
- \dim_set:Nn \l_box_right_dim { \box_wd:N #1 }
- \dim_zero:N \l_box_left_dim
-% \end{macrocode}
-% The $x$-scaling and resulting box size is easy enough to work
-% out: the dimension is that given as |#2|, and the scale is simply the
-% new width divided by the old one.
-% \begin{macrocode}
- \fp_set_from_dim:Nn \l_box_scale_x_fp {#2}
- \fp_set_from_dim:Nn \l_box_internal_fp { \l_box_right_dim }
- \fp_div:Nn \l_box_scale_x_fp { \l_box_internal_fp }
-% \end{macrocode}
-% The $y$-scaling needs both the height and the depth of the current box.
-% \begin{macrocode}
- \fp_set_from_dim:Nn \l_box_scale_y_fp {#3}
- \fp_set_from_dim:Nn \l_box_internal_fp
- { \l_box_top_dim - \l_box_bottom_dim }
- \fp_div:Nn \l_box_scale_y_fp { \l_box_internal_fp }
-% \end{macrocode}
-% At this stage, check for trivial scaling. If both scalings are unity, then
-% the code does nothing. Otherwise, pass on to the auxiliary function to
-% find the new dimensions.
-% \begin{macrocode}
- \fp_compare:NNNTF \l_box_scale_x_fp = \c_one_fp
- {
- \fp_compare:NNNTF \l_box_scale_y_fp = \c_one_fp
- { \box_use:N #1 }
- { \box_resize_aux:Nnn #1 {#2} {#3} }
- }
- { \box_resize_aux:Nnn #1 {#2} {#3} }
- \group_end:
- }
- }
-\cs_generate_variant:Nn \box_resize:Nnn { c }
-% \end{macrocode}
-% With at least one real scaling to do, the next phase is to find the new
-% edge co-ordinates. In the $x$~direction this is relatively easy: just
-% scale the right edge. This is done using the absolute value of the
-% scale so that the new edge is in the correct place. In the $y$~direction,
-% both dimensions have to be scaled, and this again needs the absolute
-% scale value. Once that is all done, the common resize/rescale code can
-% be employed.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_resize_aux:Nnn #1#2#3
- {
- \dim_compare:nNnTF {#2} > \c_zero_dim
- { \dim_set:Nn \l_box_right_new_dim {#2} }
- { \dim_set:Nn \l_box_right_new_dim { \c_zero_dim - ( #2 ) } }
- \dim_compare:nNnTF {#3} > \c_zero_dim
- {
- \dim_set:Nn \l_box_top_new_dim
- { \fp_use:N \l_box_scale_y_fp \l_box_top_dim }
- \dim_set:Nn \l_box_bottom_new_dim
- { \fp_use:N \l_box_scale_y_fp \l_box_bottom_dim }
- }
- {
- \dim_set:Nn \l_box_top_new_dim
- { - \fp_use:N \l_box_scale_y_fp \l_box_top_dim }
- \dim_set:Nn \l_box_bottom_new_dim
- { - \fp_use:N \l_box_scale_y_fp \l_box_bottom_dim }
- }
- \box_resize_common:N #1
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\box_resize_to_ht_plus_dp:Nn, \box_resize_to_ht_plus_dp:cn}
-% \begin{macro}{\box_resize_to_wd:Nn, \box_resize_to_wd:cn}
-% Scaling to a total height or to a width is a simplified version of the main
-% resizing operation, with the scale simply copied between the two parts. The
-% internal auxiliary is called using the scaling value twice, as the sign for
-% both parts is needed (as this allows the same internal code to be used as
-% for the general case).
-% \begin{macrocode}
-\cs_new_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2
- {
- \hbox_set:Nn #1
- {
- \group_begin:
- \dim_set:Nn \l_box_top_dim { \box_ht:N #1 }
- \dim_set:Nn \l_box_bottom_dim { -\box_dp:N #1 }
- \dim_set:Nn \l_box_right_dim { \box_wd:N #1 }
- \dim_zero:N \l_box_left_dim
- \fp_set_from_dim:Nn \l_box_scale_y_fp {#2}
- \fp_set_from_dim:Nn \l_box_internal_fp
- { \l_box_top_dim - \l_box_bottom_dim }
- \fp_div:Nn \l_box_scale_y_fp { \l_box_internal_fp }
- \fp_set_eq:NN \l_box_scale_x_fp \l_box_scale_y_fp
- \fp_compare:NNNTF \l_box_scale_y_fp = \c_one_fp
- { \box_use:N #1 }
- { \box_resize_aux:Nnn #1 {#2} {#2} }
- \group_end:
- }
- }
-\cs_generate_variant:Nn \box_resize_to_ht_plus_dp:Nn { c }
-\cs_new_protected:Npn \box_resize_to_wd:Nn #1#2
- {
- \hbox_set:Nn #1
- {
- \group_begin:
- \dim_set:Nn \l_box_top_dim { \box_ht:N #1 }
- \dim_set:Nn \l_box_bottom_dim { -\box_dp:N #1 }
- \dim_set:Nn \l_box_right_dim { \box_wd:N #1 }
- \dim_zero:N \l_box_left_dim
- \fp_set_from_dim:Nn \l_box_scale_x_fp {#2}
- \fp_set_from_dim:Nn \l_box_internal_fp { \l_box_right_dim }
- \fp_div:Nn \l_box_scale_x_fp { \l_box_internal_fp }
- \fp_set_eq:NN \l_box_scale_y_fp \l_box_scale_x_fp
- \fp_compare:NNNTF \l_box_scale_x_fp = \c_one_fp
- { \box_use:N #1 }
- { \box_resize_aux:Nnn #1 {#2} {#2} }
- \group_end:
- }
- }
-\cs_generate_variant:Nn \box_resize_to_wd:Nn { c }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\box_scale:Nnn, \box_scale:cnn}
-% \begin{macro}[aux]{\box_scale_aux:Nnn}
-% When scaling a box, setting the scaling itself is easy enough. The
-% new dimensions are also relatively easy to find, allowing only for
-% the need to keep them positive in all cases. Once that is done then
-% after a check for the trivial scaling a hand-off can be made to the
-% common code. The dimension scaling operations are carried out using
-% the \TeX{} mechanism as it avoids needing to use \texttt{fp}
-% operations.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_scale:Nnn #1#2#3
- {
- \hbox_set:Nn #1
- {
- \group_begin:
- \fp_set:Nn \l_box_scale_x_fp {#2}
- \fp_set:Nn \l_box_scale_y_fp {#3}
- \dim_set:Nn \l_box_top_dim { \box_ht:N #1 }
- \dim_set:Nn \l_box_bottom_dim { -\box_dp:N #1 }
- \dim_set:Nn \l_box_right_dim { \box_wd:N #1 }
- \dim_zero:N \l_box_left_dim
- \fp_compare:NNNTF \l_box_scale_x_fp = \c_one_fp
- {
- \fp_compare:NNNTF \l_box_scale_y_fp = \c_one_fp
- { \box_use:N #1 }
- { \box_scale_aux:Nnn #1 {#2} {#3} }
- }
- { \box_scale_aux:Nnn #1 {#2} {#3} }
- \group_end:
- }
- }
-\cs_generate_variant:Nn \box_scale:Nnn { c }
-\cs_new_protected:Npn \box_scale_aux:Nnn #1#2#3
- {
- \fp_compare:NNNTF \l_box_scale_y_fp > \c_zero_fp
- {
- \dim_set:Nn \l_box_top_new_dim { #3 \l_box_top_dim }
- \dim_set:Nn \l_box_bottom_new_dim { #3 \l_box_bottom_dim }
- }
- {
- \dim_set:Nn \l_box_top_new_dim { -#3 \l_box_bottom_dim }
- \dim_set:Nn \l_box_bottom_new_dim { -#3 \l_box_top_dim }
- }
- \fp_compare:NNNTF \l_box_scale_x_fp > \c_zero_fp
- { \l_box_right_new_dim #2 \l_box_right_dim }
- { \l_box_right_new_dim -#2 \l_box_right_dim }
- \box_resize_common:N #1
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}[int]{\box_resize_common:N}
-% The main resize function places in input into a box which will start
-% of with zero width, and includes the handles for engine rescaling.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_resize_common:N #1
- {
- \hbox_set:Nn \l_box_internal_box
- {
- \driver_box_scale_begin:
- \hbox_overlap_right:n { \box_use:N #1 }
- \driver_box_scale_end:
- }
-% \end{macrocode}
-% The new height and depth can be applied directly.
-% \begin{macrocode}
- \box_set_ht:Nn \l_box_internal_box { \l_box_top_new_dim }
- \box_set_dp:Nn \l_box_internal_box { \l_box_bottom_new_dim }
-% \end{macrocode}
-% Things are not quite as obvious for the width, as the reference point
-% needs to remain unchanged. For positive scaling factors resizing the
-% box is all that is needed. However, for case of a negative scaling
-% the material must be shifted such that the reference point ends up in
-% the right place.
-% \begin{macrocode}
- \fp_compare:NNNTF \l_box_scale_x_fp < \c_zero_fp
- {
- \hbox_to_wd:nn { \l_box_right_new_dim }
- {
- \tex_kern:D \l_box_right_new_dim
- \box_use:N \l_box_internal_box
- \tex_hss:D
- }
- }
- {
- \box_set_wd:Nn \l_box_internal_box { \l_box_right_new_dim }
- \box_use:N \l_box_internal_box
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Viewing part of a box}
-%
-% \begin{macro}{\box_clip:N, \box_clip:c}
-% A wrapper around the driver-dependent code.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_clip:N #1
- { \hbox_set:Nn #1 { \driver_box_use_clip:N #1 } }
-\cs_generate_variant:Nn \box_clip:N { c }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\box_trim:Nnnnn, \box_trim:cnnnn}
-% Trimming from the left- and right-hand edges of the box is easy. The total
-% width is set to remove from the right, and a skip will shift the material
-% to remove from the left.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_trim:Nnnnn #1#2#3#4#5
- {
- \box_set_wd:Nn #1 { \box_wd:N #1 - \dim_eval:n {#4} - \dim_eval:n {#2} }
- \hbox_set:Nn #1
- {
- \skip_horizontal:n { - \dim_eval:n {#2} }
- \box_use:N #1
- }
-% \end{macrocode}
-% For the height and depth, there is a need to watch the baseline is
-% respected. Material always has to stay on the correct side, so trimming
-% has to check that there is enough material to trim.
-% \begin{macrocode}
- \dim_compare:nNnTF { \box_dp:N #1 } > {#3}
- { \box_set_dp:Nn #1 { \box_dp:N #1 - \dim_eval:n {#3} } }
- {
- \hbox_set:Nn #1
- {
- \box_move_down:nn { \dim_eval:n {#3} - \box_dp:N #1 }
- { \box_use:N #1 }
- }
- \box_set_dp:Nn #1 \c_zero_dim
- }
- \dim_compare:nNnTF { \box_ht:N #1 } > {#5}
- { \box_set_ht:Nn #1 { \box_ht:N #1 - \dim_eval:n {#5} } }
- {
- \hbox_set:Nn #1
- {
- \box_move_up:nn { \dim_eval:n {#5} - \box_ht:N #1 }
- { \box_use:N #1 }
- }
- \box_set_ht:Nn #1 \c_zero_dim
- }
- }
-\cs_generate_variant:Nn \box_trim:Nnnnn { c }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\box_viewport:Nnnnn, \box_viewport:cnnnn}
-% The same general logic as for clipping, but with absolute dimensions.
-% Thus again width is easy and height is harder.
-% \begin{macrocode}
-\cs_new_protected:Npn \box_viewport:Nnnnn #1#2#3#4#5
- {
- \box_set_wd:Nn #1 { \dim_eval:n {#4} - \dim_eval:n {#2} }
- \hbox_set:Nn #1
- {
- \skip_horizontal:n { - \dim_eval:n {#2} }
- \box_use:N #1
- }
- \dim_compare:nNnTF {#3} > \c_zero_dim
- {
- \hbox_set:Nn #1 { \box_move_down:nn {#3} { \box_use:N #1 } }
- \box_set_dp:Nn #1 \c_zero_dim
- }
- { \box_set_dp:Nn #1 { - \dim_eval:n {#3} } }
- \dim_compare:nNnTF {#5} > \c_zero_dim
- { \box_set_ht:Nn #1 {#5} }
- {
- \hbox_set:Nn #1
- { \box_move_up:nn { -\dim_eval:n {#5} } { \box_use:N #1 } }
- \box_set_ht:Nn #1 \c_zero_dim
- }
- }
-\cs_generate_variant:Nn \box_viewport:Nnnnn { c }
+ { \tex_setbox:D #1 \tex_vsplit:D #2 to \__dim_eval:w #3 \__dim_eval_end: }
% \end{macrocode}
% \end{macro}
%
@@ -1982,7 +1265,9 @@
% \begin{variable}{\l_last_box}
% Deprecated 2011-11-13, for removal by 2012-02-28.
% \begin{macrocode}
+%<*deprecated>
\cs_new_eq:NN \l_last_box \tex_lastbox:D
+%</deprecated>
% \end{macrocode}
% \end{variable}
%