diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/cellprops/cellprops.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/cellprops/cellprops.sty | 360 |
1 files changed, 304 insertions, 56 deletions
diff --git a/Master/texmf-dist/tex/latex/cellprops/cellprops.sty b/Master/texmf-dist/tex/latex/cellprops/cellprops.sty index b7b4441aca3..398b773c696 100644 --- a/Master/texmf-dist/tex/latex/cellprops/cellprops.sty +++ b/Master/texmf-dist/tex/latex/cellprops/cellprops.sty @@ -15,8 +15,8 @@ \RequirePackage{expl3}[2016/01/19] \def\ExplFileName{cellprops} \def\ExplFileDescription{CSS-like cell and table properties} -\def\ExplFileDate{2018/06/12} -\def\ExplFileVersion{1.2} +\def\ExplFileDate{2018/06/14} +\def\ExplFileVersion{1.3} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -25,7 +25,7 @@ \RequirePackage{mdwtab} \cs_set_nopar:Npn \tab@pop #1 { \tl_set:Nx #1 { \tl_tail:N #1 } } -\cs_set:Nn \__cellprops_generic_setter:nnn { +\cs_new:Nn \__cellprops_generic_setter:nnn { \exp_not:N \tl_set:Nn \exp_not:c { l__cellprops_property_value_#2_tl } {#1 {#3}} @@ -35,24 +35,27 @@ \tl_use:c { l__cellprops_property_value_#1_tl } } -\cs_set_protected_nopar:Nn \__cellprops_get_property:nN { +\cs_new_protected_nopar:Nn \__cellprops_get_property:nN { \tl_if_exist:cTF { l__cellprops_property_value_#1_tl } { \tl_set_eq:Nc #2 { l__cellprops_property_value_#1_tl } }{ \tl_clear:N #2 } } -\cs_set_protected:Nn \__cellprops_define_properties:nn { +\cs_new_protected:Nn \__cellprops_define_properties:nn { \clist_map_inline:nn {#2} { \cs_set:cpn { __cellprops_property_type_##1:nn } {#1} } } -\cs_set_protected:Nn \__cellprops_use_setter:nn { +\cs_new:Nn \__cellprops_delegate_setter:nn { + \use:c {__cellprops_property_type_#1:nn} {#1} {#2} +} +\cs_new_protected:Nn \__cellprops_use_setter:nn { \use:x { - \use:c {__cellprops_property_type_#1:nn} {#1} {#2} + \__cellprops_delegate_setter:nn {#1} {#2} } } -\cs_set_protected:Nn \__cellprops_parse_properties:Nn { +\cs_new_protected:Nn \__cellprops_parse_properties:Nn { \tl_clear:N #1 \seq_set_split:Nnn \l_tmpa_seq {;} {#2} \seq_map_inline:Nn \l_tmpa_seq { @@ -64,9 +67,8 @@ \seq_get_right:NN \l_tmpb_seq \l_tmpa_tl \cs_if_exist:cTF { __cellprops_property_type_\l_tmpa_str :nn } { \tl_put_right:Nx #1 { - \exp_args:Nc \exp_args:NVV - { __cellprops_property_type_\l_tmpa_str :nn } - \l_tmpa_str \l_tmpa_tl + \exp_args:NVV \__cellprops_delegate_setter:nn + \l_tmpa_str \l_tmpa_tl } }{ % TODO: ERROR-no property with that name @@ -78,27 +80,36 @@ } } -\cs_set:Nn \__cellprops_fourdim_setter:nn { - \__cellprops_fourdim_setter_aux:w - {#1}#2~{\q_no_value}~{\q_no_value}~{\q_no_value}~\q_stop +\cs_new:Nn \__cellprops_fourval_setter:nnnnnn { + \__cellprops_fourval_setter_aux:w + {#1}{#2}{#3}{#4}#6~{\q_no_value}~{\q_no_value}~{\q_no_value}~\q_stop } -\cs_set:Npn \__cellprops_fourdim_setter_aux:w #1#2~#3~#4~#5~#6\q_stop { - \__cellprops_generic_setter:nnn \exp_not:n {#1-top} {#2} - \quark_if_no_value:nTF {#3} { - \__cellprops_generic_setter:nnn \exp_not:n {#1-right} {#2} - \__cellprops_generic_setter:nnn \exp_not:n {#1-left} {#2} +\cs_new:Npn \__cellprops_fourval_setter_aux:w #1#2#3#4#5~#6~#7~#8~#9\q_stop { + \__cellprops_delegate_setter:nn {#1} {#5} + \quark_if_no_value:nTF {#6} { + \__cellprops_delegate_setter:nn {#2} {#5} + \__cellprops_delegate_setter:nn {#4} {#5} }{ - \__cellprops_generic_setter:nnn \exp_not:n {#1-right} {#3} - \quark_if_no_value:nTF {#5} { - \__cellprops_generic_setter:nnn \exp_not:n {#1-left} {#3} + \__cellprops_delegate_setter:nn {#2} {#6} + \quark_if_no_value:nTF {#8} { + \__cellprops_delegate_setter:nn {#4} {#6} }{ - \__cellprops_generic_setter:nnn \exp_not:n {#1-left} {#5} + \__cellprops_delegate_setter:nn {#4} {#8} } } - \quark_if_no_value:nTF {#4} { - \__cellprops_generic_setter:nnn \exp_not:n {#1-bottom} {#2} + \quark_if_no_value:nTF {#7} { + \__cellprops_delegate_setter:nn {#3} {#5} + }{ + \__cellprops_delegate_setter:nn {#3} {#7} + } +} + +\cs_new_protected:Nn \__cellprops_define_fourval_properties:nnnnnn { + \__cellprops_define_properties:nn {#1} { #3, #4, #5, #6 } + \__cellprops_define_properties:nn { + \__cellprops_fourval_setter:nnnnnn {#3}{#4}{#5}{#6} }{ - \__cellprops_generic_setter:nnn \exp_not:n {#1-bottom} {#4} + #2 } } @@ -132,23 +143,70 @@ } } +\cs_new_nopar:Nn \__cellprops_linewidth_setter:nn { + \str_case:nnF {#2} { + {thin} { \__cellprops_generic_setter:nnn \exp_not:n {#1} { \fboxrule} } + {medium} { \__cellprops_generic_setter:nnn \exp_not:n {#1} { 2\fboxrule} } + {thick} { \__cellprops_generic_setter:nnn \exp_not:n {#1} { 3\fboxrule} } + }{ + \__cellprops_generic_setter:nnn \exp_not:n {#1} {#2} + } +} + +\cs_new_nopar:Nn \__cellprops_border_setter:nn { + \__cellprops_border_setter_aux:nw + {#1}#2~{\q_no_value}~{\q_no_value}~\q_stop +} +\cs_new:Npn \__cellprops_border_setter_aux:nw #1#2~#3~#4~#5\q_stop { + \quark_if_no_value:nTF {#4} { + \__cellprops_border_setter_isstyle:nTF {#2} { + \__cellprops_delegate_setter:nn {#1-width} {thin} + \__cellprops_delegate_setter:nn {#1-style} {#2} + \quark_if_no_value:nTF {#3} { + \__cellprops_delegate_setter:nn {#1-color} {inherit} + }{ + \__cellprops_delegate_setter:nn {#1-color} {#3} + } + }{ + \quark_if_no_value:nTF {#3} { + %% TODO: Error, one no-style value, ambiguous + }{ + \__cellprops_border_setter_isstyle:nTF {#3} { + \__cellprops_delegate_setter:nn {#1-width} {#2} + \__cellprops_delegate_setter:nn {#1-style} {#3} + \__cellprops_delegate_setter:nn {#1-color} {inherit} + }{ + \__cellprops_delegate_setter:nn {#1-width} {#2} + \__cellprops_delegate_setter:nn {#1-style} {none} + \__cellprops_delegate_setter:nn {#1-color} {#3} + } + } + } + }{ + \__cellprops_delegate_setter:nn {#1-width} {#2} + \__cellprops_delegate_setter:nn {#1-style} {#3} + \__cellprops_delegate_setter:nn {#1-color} {#4} + } +} +\cs_new:Npn \__cellprops_border_setter_isstyle:nTF #1 { + \str_case:nnTF {#1} { + {none}{} {hidden}{} {dotted}{} {dashed}{} {solid}{} + {double}{} {groove}{} {ridge}{} {inset}{} {outset}{} + } +} + \__cellprops_define_properties:nn { \__cellprops_generic_setter:nnn \exp_not:n }{ - padding-top, - padding-right, - padding-bottom, - padding-left, min-height, min-depth, min-width, } -\__cellprops_define_properties:nn { - \__cellprops_fourdim_setter:nn -}{ - padding -} +\__cellprops_define_fourval_properties:nnnnnn + { \__cellprops_generic_setter:nnn \exp_not:n } + {padding} + {padding-top}{padding-right}{padding-bottom}{padding-left} \__cellprops_define_properties:nn { \__cellprops_generic_setter:nnn \tl_to_str:n @@ -169,6 +227,30 @@ background-color, } +\__cellprops_define_fourval_properties:nnnnnn + { \__cellprops_linewidth_setter:nn } + {border-width} + {border-top-width}{border-right-width} + {border-bottom-width}{border-left-width} + +\__cellprops_define_fourval_properties:nnnnnn + { \__cellprops_generic_setter:nnn \tl_to_str:n } + {border-style} + {border-top-style}{border-right-style} + {border-bottom-style}{border-left-style} + +\__cellprops_define_fourval_properties:nnnnnn + { \__cellprops_color_setter:nn } + {border-color} + {border-top-color}{border-right-color} + {border-bottom-color}{border-left-color} + +\__cellprops_define_properties:nn { + \__cellprops_border_setter:nn +}{ + border, border-top, border-right, border-bottom, border-left +} + \NewDocumentCommand \cellprops { m } { \__cellprops_parse_css:n {#1} } @@ -279,17 +361,21 @@ } \dim_new:N \l__cellprops_colsep_dim +\dim_new:N \l__cellprops_strut_ht_dim +\dim_new:N \l__cellprops_strut_dp_dim + \ExplSyntaxOff \cellprops{ td { padding: 0pt \csname l__cellprops_colsep_dim\endcsname; - min-height: 0pt; - min-depth: 0pt; + min-height: \csname l__cellprops_strut_ht_dim\endcsname; + min-depth: \csname l__cellprops_strut_dp_dim\endcsname; min-width: 0pt; text-align: left; math-mode: auto; color: inherit; background-color: transparent; + border: thin none inherit; } tr { color: inherit; @@ -313,6 +399,7 @@ \skip_new:N \l__cellprops_right_skip \dim_new:N \g__cellprops_ht_dim \dim_new:N \g__cellprops_dp_dim +\tl_new:N \g__cellprops_borders_tl \tl_new:N \l__cellprops_restore_tl @@ -336,9 +423,12 @@ { \dim_use:N \g__cellprops_ht_dim } \exp_not:n { \dim_gset:Nn \g__cellprops_dp_dim } { \dim_use:N \g__cellprops_dp_dim } + \exp_not:n { \tl_gset:Nn \g__cellprops_borders_tl } + { \exp_not:V \g__cellprops_borders_tl } } \int_gzero:N \g__cellprops_row_int \bool_gset_false:N \g__cellprops_inrow_bool + \tl_gclear:N \g__cellprops_borders_tl \cs_set_eq:NN \__cellprops_orig_tab@readpreamble:n \tab@readpreamble \cs_set_eq:NN \tab@readpreamble \__cellprops_readpreamble:n \dim_set_eq:NN \l__cellprops_colsep_dim \col@sep @@ -357,6 +447,9 @@ \tl_set_eq:NN \l__cellprops_color_tl \g_tmpa_tl \tl_set_eq:NN \l__cellprops_bgcolor_tl \g_tmpb_tl \__cellprops_recall_properties:n {tr} + \dim_set:Nn \l__cellprops_strut_ht_dim { \box_ht:N \@arstrutbox } + \dim_set:Nn \l__cellprops_strut_dp_dim { \box_dp:N \@arstrutbox } + \box_clear:N \@arstrutbox } \cs_set_nopar:Nn \__cellprops_array_startcontent: { @@ -400,12 +493,13 @@ } } -\cs_set_protected_nopar:Nn \__cellprops_update_colors: { +\cs_new_protected_nopar:Nn \__cellprops_update_colors: { \__cellprops_update_color:Nn \l__cellprops_color_tl {color} \__cellprops_update_color:Nn \l__cellprops_bgcolor_tl {background-color} } -\cs_set_nopar:Nn \__cellprops_end_array:n { +\cs_new_nopar:Nn \__cellprops_end_array:n { + \tl_if_empty:NF \g__cellprops_borders_tl { \\ } \crcr \hlx{s[\l__cellprops_tablepadding_bottom_dim]} #1 @@ -416,13 +510,15 @@ \cs_set_nopar:Npn \endarray { \__cellprops_end_array:n { \__cellprops_orig_endarray: } } +\cs_set_eq:NN \endtabular \endarray +\cs_set_eq:cN {endtabular*} \endarray \cs_set_eq:NN \__cellprops_orig_endLT: \endlongtable \cs_set_nopar:Npn \endlongtable { \__cellprops_end_array:n { \__cellprops_orig_endLT: } } -\cs_set_protected_nopar:Nn \__cellprops_startrow: { +\cs_new_protected_nopar:Nn \__cellprops_startrow: { \bool_if:NF \g__cellprops_inrow_bool { \bool_gset_true:N \g__cellprops_inrow_bool \int_gincr:N \g__cellprops_row_int @@ -432,15 +528,33 @@ } } -\cs_set_protected_nopar:Npn \__cellprops_endrow: { +\cs_new_protected_nopar:Nn \__cellprops_endrow: { \bool_if:NT \g__cellprops_inrow_bool { \bool_gset_false:N \g__cellprops_inrow_bool - \__cellprops_fix_valign_end: } } -\cs_set_eq:NN \__cellprops_orig_tab@arraycr:n \tab@arraycr -\cs_set_nopar:Npn \tab@arraycr { \__cellprops_endrow:\__cellprops_orig_tab@arraycr:n } +\cs_new_protected_nopar:Nn \__cellprops_cr:n { + \__cellprops_endrow: + \tl_if_empty:NF \g__cellprops_borders_tl { + \cr + \noalign{\nobreak} + \tl_use:N \g__cellprops_borders_tl + \tl_gclear:N \g__cellprops_borders_tl + } + \cr + \__cellprops_fix_valign_end:n {#1} + \use_none:n +} + +\cs_set_protected_nopar:Npn \tab@tabcr #1#2 { \__cellprops_cr:n {#2} } +\cs_set_protected_nopar:Npn \@xargarraycr #1 { \__cellprops_cr:n {#1} } +\cs_set_protected_nopar:Npn \@yargarraycr #1 { \__cellprops_cr:n {#1} } +\tl_if_exist:NT \LT@echunk { + \tl_put_left:Nn \LT@echunk { + \tl_if_empty:NF \g__cellprops_borders_tl { \\ } + } +} \cs_set_eq:NN \__cellprops_orig_multicolumn:w \multicolumn \cs_set:Npn \multicolumn#1#2#3 { @@ -450,15 +564,15 @@ } } -\cs_new_protected_nopar:Nn \__cellprops_fix_valign_end: { - \exp_args:NV \tl_if_eq:nnTF \tab@hlstate {b} { - \dim_gadd:Nn \tab@endheight { - \g__cellprops_dp_dim - \box_dp:N \@arstrutbox - } - }{ - \int_compare:nNnT \g__cellprops_row_int = \c_one { - \dim_gadd:Nn \tab@endheight { - \g__cellprops_ht_dim - \box_ht:N \@arstrutbox +\cs_new_nopar:Nn \__cellprops_fix_valign_end:n { + \noalign{ + \dim_set:Nn \l_tmpa_dim {#1} + \skip_vertical:n {\l_tmpa_dim} + \exp_args:NV \tl_if_eq:nnTF \tab@hlstate {b} { + \dim_gadd:Nn \tab@endheight { \g__cellprops_dp_dim + \l_tmpa_dim } + }{ + \int_compare:nNnT \g__cellprops_row_int = \c_one { + \dim_gadd:Nn \tab@endheight { \g__cellprops_ht_dim } } } } @@ -616,21 +730,123 @@ \tl_use:N \l__cellprops_color_tl } +\cs_new_protected_nopar:Nn \__cellprops_make_solid_hborder:nnn { + \group_begin: + \hbox_set_to_wd:Nnn \l_tmpa_box {1pt} { + \hss + \hbox:n { + #3 % install color + \vrule height~\dim_eval:n{#1+#2} + ~depth~-\dim_eval:n{#2} + ~width~3pt + } + \hss + } + \box_set_ht:Nn \l_tmpa_box { \c_zero_dim } + \box_set_dp:Nn \l_tmpa_box { \c_zero_dim } + \kern 1pt + \box_use:N \l_tmpa_box + \xleaders + \box_use:N \l_tmpa_box + \skip_horizontal:n {-4pt~plus~1fil} + \box_use:N \l_tmpa_box + \kern 1pt + \skip_horizontal:n {0pt~plus~-1fil} + \group_end: +} +\cs_new_protected_nopar:Nn \__cellprops_make_solid_vborder:nnn { + \group_begin: + \hbox_set_to_wd:Nnn \l_tmpa_box {0pt} { + \hbox:n { + #3 % install color + \vrule height~\dim_eval:n{#2}~width~\dim_eval:n{#1} + } + \hss + } + \box_set_ht:Nn \l_tmpa_box { \c_zero_dim } + \box_set_dp:Nn \l_tmpa_box { \c_zero_dim } + \box_use:N \l_tmpa_box + \group_end: +} +\clist_map_inline:nn { + dotted, dashed, solid, double, + groove, ridge, inset, outset +}{ + \cs_set_eq:cN {__cellprops_make_#1_hborder:nnn} \__cellprops_make_solid_hborder:nnn + \cs_set_eq:cN {__cellprops_make_#1_vborder:nnn} \__cellprops_make_solid_vborder:nnn +} + +\dim_new:N \l__cellprops_border_width_dim +\str_new:N \l__cellprops_border_style_str +\tl_new:N \l__cellprops_border_color_tl +\cs_new_protected_nopar:Nn \__cellprops_get_border_info:n { + \dim_set:Nn \l__cellprops_border_width_dim {\__cellprops_get_property:n {border-#1-width}} + \__cellprops_get_property:nN {border-#1-style} \l_tmpa_tl + \exp_args:NNV \str_set:Nn \l__cellprops_border_style_str \l_tmpa_tl + \tl_clear:N \l__cellprops_border_color_tl + \cs_if_exist:cTF {__cellprops_make_\l__cellprops_border_style_str _hborder:nnn} { + \__cellprops_update_color:Nn \l__cellprops_border_color_tl {border-#1-color} + }{ + \dim_zero:N \l__cellprops_border_width_dim + } +} + +\cs_new_protected_nopar:Npn \__cellprops_make_hborder:nnnn #1 { + \use:c { __cellprops_make_#1_hborder:nnn } +} +\cs_new_protected_nopar:Npn \__cellprops_make_vborder:nnnn #1 { + \use:c { __cellprops_make_#1_vborder:nnn } +} + \cs_new_protected_nopar:Nn \__cellprops_end_raw_cell: { % Here \l__cellprops_cell_box must contain the contents of the cell % - % Handle vpadding and min-height/depth + % Prepare the borders token list + \int_compare:nNnT \g__cellprops_col_int = 1 { + \tl_gclear:N \g__cellprops_borders_tl + } + \tl_gput_right:Nx \g__cellprops_borders_tl { + \tl_if_empty:NF \g__cellprops_borders_tl { \exp_not:n {&} } + \exp_not:n { \omit \kern \c_zero_dim } + } + % Handle padding-top, min-height and border-top + \__cellprops_get_border_info:n {top} \box_set_ht:Nn \l__cellprops_cell_box { \dim_max:nn {\box_ht:N \l__cellprops_cell_box} {\__cellprops_get_property:n {min-height}} + (\__cellprops_get_property:n {padding-top}) + + \l__cellprops_border_width_dim + } + \dim_compare:nNnT \l__cellprops_border_width_dim > \c_zero_dim { + \tl_gput_right:Nx \g__cellprops_borders_tl { + \exp_not:N \__cellprops_make_hborder:nnnn + { \exp_not:V \l__cellprops_border_style_str } + { \dim_use:N \l__cellprops_border_width_dim } + { + \exp_not:n { \g__cellprops_dp_dim + \g__cellprops_ht_dim - } + \dim_use:N \l__cellprops_border_width_dim + } + { \exp_not:V \l__cellprops_border_color_tl } + } } + % Handle padding-bottom, min-depth and border-bottom + \__cellprops_get_border_info:n {bottom} \box_set_dp:Nn \l__cellprops_cell_box { \dim_max:nn {\box_dp:N \l__cellprops_cell_box} {\__cellprops_get_property:n {min-depth}} + (\__cellprops_get_property:n {padding-bottom}) + + \l__cellprops_border_width_dim + } + \dim_compare:nNnT \l__cellprops_border_width_dim > \c_zero_dim { + \tl_gput_right:Nx \g__cellprops_borders_tl { + \exp_not:N \__cellprops_make_hborder:nnnn + { \exp_not:V \l__cellprops_border_style_str } + { \dim_use:N \l__cellprops_border_width_dim } + { \exp_not:n { 0pt } } + { \exp_not:V \l__cellprops_border_color_tl } + } } % To fix vertical alignment later \dim_gset:Nn \g__cellprops_ht_dim { @@ -653,10 +869,42 @@ \skip_add:Nn \l_tmpa_skip { 0pt plus 1fil } + % padding-left and border-left + \__cellprops_get_border_info:n {left} \skip_set:Nn \l__cellprops_left_skip - {\__cellprops_get_property:n {padding-left}} + {\__cellprops_get_property:n {padding-left} + \l__cellprops_border_width_dim} + \dim_compare:nNnT \l__cellprops_border_width_dim > \c_zero_dim { + \tl_gput_right:Nx \g__cellprops_borders_tl { + \exp_not:N \__cellprops_make_vborder:nnnn + { \exp_not:V \l__cellprops_border_style_str } + { \dim_use:N \l__cellprops_border_width_dim } + { \exp_not:n { \g__cellprops_dp_dim + \g__cellprops_ht_dim } } + { \exp_not:V \l__cellprops_border_color_tl } + } + } + \tl_gput_right:Nx \g__cellprops_borders_tl { + \exp_not:n { + \skip_horizontal:n {0pt~plus~1fil} + \kern \c_zero_dim + } + } + \__cellprops_get_border_info:n {right} \skip_set:Nn \l__cellprops_right_skip - {\__cellprops_get_property:n {padding-right}} + {\__cellprops_get_property:n {padding-right} + \l__cellprops_border_width_dim} + \dim_compare:nNnT \l__cellprops_border_width_dim > \c_zero_dim { + \tl_gput_right:Nx \g__cellprops_borders_tl { + \exp_not:N \skip_horizontal:n + { - \dim_use:N \l__cellprops_border_width_dim } + \exp_not:N \__cellprops_make_vborder:nnnn + { \exp_not:V \l__cellprops_border_style_str } + { \dim_use:N \l__cellprops_border_width_dim } + { \exp_not:n { \g__cellprops_dp_dim + \g__cellprops_ht_dim } } + { \exp_not:V \l__cellprops_border_color_tl } + \exp_not:N \skip_horizontal:n + { \dim_use:N \l__cellprops_border_width_dim } + \exp_not:n { \kern \c_zero_dim } + } + } \str_case_x:nnF {\__cellprops_get_property:n {text-align}} { { right } { \skip_add:Nn \l__cellprops_left_skip { \l_tmpa_skip } |