Skip to content

Commit

Permalink
draft for multirow
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Jul 28, 2024
1 parent 16bba8b commit 918ce80
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
Binary file added experiments/multirow-cell.pdf
Binary file not shown.
113 changes: 113 additions & 0 deletions experiments/multirow-cell.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
\DocumentMetadata{testphase={phase-III,table},uncompress}
%\input{regression-test}
\documentclass{article}
%\usepackage{hyperref}
\ExplSyntaxOn
\prop_new:N\g__tbl_skip_cells_prop
\prop_new:N\l__tbl_saved_skip_cells_prop

\cs_set_protected:Npn \__tbl_init_struct_data: {
\tl_set_eq:NN \l__tbl_saved_struct_table_tl \g__tbl_struct_table_tl
\seq_set_eq:NN \l__tbl_saved_struct_rows_seq \g__tbl_struct_rows_seq
\seq_set_eq:NN \l__tbl_saved_struct_cells_seq \g__tbl_struct_cells_seq
\seq_set_eq:NN \l__tbl_saved_struct_cur_seq \g__tbl_struct_cur_seq
\prop_set_eq:NN\l__tbl_saved_skip_cells_prop \g__tbl_skip_cells_prop
\prop_gclear:N \g__tbl_skip_cells_prop
\seq_gclear:N\g__tbl_struct_rows_seq
\seq_gclear:N\g__tbl_struct_cells_seq
\seq_gclear:N\g__tbl_struct_cur_seq
}

\cs_set_protected:Npn \__tbl_restore_struct_data: {
\tl_gset_eq:NN \g__tbl_struct_table_tl \l__tbl_saved_struct_table_tl
\seq_gset_eq:NN \g__tbl_struct_rows_seq \l__tbl_saved_struct_rows_seq
\seq_gset_eq:NN \g__tbl_struct_cells_seq\l__tbl_saved_struct_cells_seq
\seq_gset_eq:NN \g__tbl_struct_cur_seq \l__tbl_saved_struct_cur_seq
\prop_gset_eq:NN\g__tbl_skip_cells_prop \l__tbl_saved_skip_cells_prop
}

\cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {one}
\cs_new_protected:Npn \__tbl_add_multirow:n #1
{
\prop_get:NeNF \g__tag_attr_entries_prop
{rowspan-\int_eval:n{#1}}
\l__tbl_tmpa_tl
{
\__tag_attr_new_entry:ee
{rowspan-\int_eval:n{#1}}
{/O /Table /RowSpan~\int_eval:n{#1}}
}
\seq_gput_left:Ne\g__tag_attr_class_used_seq
{\pdf_name_from_unicode_e:n{rowspan-\int_eval:n{#1}}}
\seq_get_right:NN\g__tbl_struct_cur_seq \l__tbl_tmpb_tl
\prop_get:cnNTF
{ g__tag_struct_\l__tbl_tmpb_tl _prop }
{ C }
\l__tbl_tmpa_tl
{
\tl_remove_once:Nn \l__tbl_tmpa_tl {[}
\tl_remove_once:Nn \l__tbl_tmpa_tl {]}
\__tag_struct_prop_gput:one{ \l__tbl_tmpb_tl }
{C}
{[/rowspan-\int_eval:n{#1}~\l__tbl_tmpa_tl]}
}
{
\__tag_struct_prop_gput:one{ \l__tbl_tmpb_tl }
{C}
{[/rowspan-\int_eval:n{#1}]}
}
\int_step_inline:nn {#1-1}
{
\prop_gput:Nee \g__tbl_skip_cells_prop
{ \int_use:N\g__tbl_col_int-\int_eval:n {\g__tbl_row_int +##1}}{}
}
}
\socket_set_plug:nnn{tagsupport/tbl/cell/begin}{TD}
{
\__tbl_show_curr_cell_data:
\clist_if_in:NVT \l__tbl_header_columns_clist\g__tbl_col_int
{
\tl_set:Nn \l__tbl_celltag_tl {TH}
\tl_set:Ne \l__tbl_cellattribute_tl {\l__tbl_cellattribute_tl,TH-row}
}
\tl_set:Ne \l__tbl_tmpa_tl {\int_eval:n { \g__tbl_col_int - 1 - \g__tbl_table_cols_tl }}
\clist_if_in:NoT \l__tbl_header_columns_clist { \l__tbl_tmpa_tl }
{
\tl_set:Nn \l__tbl_celltag_tl {TH}
\tl_set:Ne \l__tbl_cellattribute_tl {\l__tbl_cellattribute_tl,TH-row}
}
\tl_set:Ne\l_tmpb_tl{\int_use:N\g__tbl_col_int-\int_eval:n {\g__tbl_row_int}}
\prop_gpop:NoNTF \g__tbl_skip_cells_prop
{ \l_tmpb_tl}\l_tmpa_tl
{\AssignSocketPlug{tagsupport/tbl/cell/end}{noop}}
{
\tag_struct_begin:n
{
tag =\l__tbl_celltag_tl,
attribute-class ={\l__tbl_cellattribute_tl}
}
\seq_gput_right:Ne \g__tbl_struct_cur_seq { \tag_get:n {struct_num} }
\int_step_inline:nn { \g__tbl_span_tl - 1 }
{
\seq_gput_right:Ne \g__tbl_struct_cur_seq { -\tag_get:n {struct_num} }
}
\tag_mc_begin:n{}
}

}

\keys_define:nn{ __tag / setup }
{ table/multirow .code:n = {\__tbl_add_multirow:n {#1} }
,table/multirow .default:n = 1
}
\ExplSyntaxOff
\begin{document}
\tagpdfsetup{table/header-rows={1,-1}, table/header-columns={1,-1}}
\begin{tabular}{lp{3cm}ll}
text & \multicolumn{2}{c}{multi}& colhead\\
\tagpdfsetup{table/multirow={2}}
text & text & text & colhead\\
& text & text & colhead\\
head & head & head & colhead\\
\end{tabular}
\end{document}

0 comments on commit 918ce80

Please sign in to comment.