diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3box.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3box.sty | 324 |
1 files changed, 323 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3box.sty b/Master/texmf-dist/tex/latex/l3kernel/l3box.sty index 57415ec278d..cb83228019a 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3box.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3box.sty @@ -46,7 +46,7 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3box.dtx 2665 2011-08-25 22:15:27Z joseph $ +\GetIdInfo$Id: l3box.dtx 2711 2011-09-02 12:15:53Z joseph $ {L3 Experimental boxes} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -214,6 +214,328 @@ \cs_generate_variant:Nn \vbox_unpack_clear:N { c } \cs_new_protected_nopar: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: } +\fp_new:N \l_box_angle_fp +\fp_new:N \l_box_cos_fp +\fp_new:N \l_box_sin_fp +\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 +\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 +\box_new:N \l_box_tmp_box +\fp_new:N \l_box_tmp_fp +\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 +\cs_new_protected_nopar: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: + } + } +\cs_new_protected_nopar: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 + \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: } + } + \hbox_set:Nn \l_box_tmp_box { \box_use:N #1 } + \hbox_set:Nn \l_box_tmp_box + { + \tex_kern:D -\l_box_left_new_dim + \hbox:n + { + \driver_box_rotate_begin: + \box_use:N \l_box_tmp_box + \driver_box_rotate_end: + } + } + \box_set_ht:Nn \l_box_tmp_box { \l_box_top_new_dim } + \box_set_dp:Nn \l_box_tmp_box { -\l_box_bottom_new_dim } + \box_set_wd:Nn \l_box_tmp_box + { \l_box_right_new_dim - \l_box_left_new_dim } + \box_use:N \l_box_tmp_box + } +\cs_set_protected_nopar:Npn \box_rotate:Nn #1#2 + { \hbox_set:Nn #1 { \rotatebox {#2} { \box_use:N #1 } } } +\cs_new_protected_nopar:Npn \box_rotate_set_sin_cos: + { + \fp_set_eq:NN \l_box_tmp_fp \l_box_angle_fp + \fp_div:Nn \l_box_tmp_fp { 180 } + \fp_mul:Nn \l_box_tmp_fp { \c_pi_fp } + \fp_sin:Nn \l_box_sin_fp { \l_box_tmp_fp } + \fp_cos:Nn \l_box_cos_fp { \l_box_tmp_fp } + } +\cs_new_protected_nopar: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_tmp_fp \l_box_y_fp + \fp_mul:Nn \l_box_x_new_fp { \l_box_cos_fp } + \fp_mul:Nn \l_box_tmp_fp { \l_box_sin_fp } + \fp_sub:Nn \l_box_x_new_fp { \l_box_tmp_fp } + \dim_set:Nn #3 { \fp_to_dim:N \l_box_x_new_fp } + } +\cs_new_protected_nopar: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_tmp_fp \l_box_x_fp + \fp_mul:Nn \l_box_y_new_fp { \l_box_cos_fp } + \fp_mul:Nn \l_box_tmp_fp { \l_box_sin_fp } + \fp_add:Nn \l_box_y_new_fp { \l_box_tmp_fp } + \dim_set:Nn #3 { \fp_to_dim:N \l_box_y_new_fp } +} +\cs_new_protected_nopar: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_nopar: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_nopar: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_nopar: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 + } +\fp_new:N \l_box_scale_x_fp +\fp_new:N \l_box_scale_y_fp +\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 + \fp_set_from_dim:Nn \l_box_scale_x_fp {#2} + \fp_set_from_dim:Nn \l_box_tmp_fp { \l_box_right_dim } + \fp_div:Nn \l_box_scale_x_fp { \l_box_tmp_fp } + \fp_set_from_dim:Nn \l_box_scale_y_fp {#3} + \fp_set_from_dim:Nn \l_box_tmp_fp + { \l_box_top_dim - \l_box_bottom_dim } + \fp_div:Nn \l_box_scale_y_fp { \l_box_tmp_fp } + \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 } +\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 + } +\cs_set_protected_nopar:Npn \box_resize:Nnn #1#2#3 + { + \hbox_set:Nn #1 + { + \resizebox * + { \etex_dimexpr:D #2 \scan_stop: } + { \etex_dimexpr:D #3 \scan_stop: } + { \box_use:N #1 } + } + } +\cs_new_protected_nopar: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_tmp_fp + { \l_box_top_dim - \l_box_bottom_dim } + \fp_div:Nn \l_box_scale_y_fp { \l_box_tmp_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_nopar: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_tmp_fp { \l_box_right_dim } + \fp_div:Nn \l_box_scale_x_fp { \l_box_tmp_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 } +\cs_set_protected_nopar:Npn \box_resize_to_ht_plus_dp:Nn #1#2 + { + \hbox_set:Nn #1 + { + \resizebox * { ! } { \etex_dimexpr:D #2 \scan_stop: } { \box_use:N #1 } + } + } +\cs_set_protected_nopar:Npn \box_resize_to_wd:Nn #1#2 + { + \hbox_set:Nn #1 + { + \resizebox * { \etex_dimexpr:D #2 \scan_stop: } { ! } { \box_use:N #1 } + } + } +\cs_new_protected_nopar: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_nopar: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 + } +\cs_set_protected_nopar:Npn \box_scale:Nnn #1#2#3 + { \hbox_set:Nn #1 { \scalebox {#2} [#3] { \box_use:N #1 } } } +\cs_new_protected_nopar:Npn \box_resize_common:N #1 + { + \hbox_set:Nn \l_box_tmp_box + { + \driver_box_scale_begin: + \hbox_overlap_right:n { \box_use:N #1 } + \driver_box_scale_end: + } + \box_set_ht:Nn \l_box_tmp_box { \l_box_top_new_dim } + \box_set_dp:Nn \l_box_tmp_box { \l_box_bottom_new_dim } + \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_tmp_box + \tex_hss:D + } + } + { + \box_set_wd:Nn \l_box_tmp_box { \l_box_right_new_dim } + \box_use:N \l_box_tmp_box + } + } %% %% %% End of file `l3box.sty'. |