Skip to content

Commit

Permalink
handle minipage inside tabular (#1429)
Browse files Browse the repository at this point in the history
* improve minipage handling in tabular

* improve handling of minipage in tables, latex3/tagging-project#37

* set seed ...

* from review, use tagging sockets

* tagging sockets are less noisy ...
  • Loading branch information
u-fischer authored Aug 8, 2024
1 parent 8662371 commit 413eb8d
Show file tree
Hide file tree
Showing 40 changed files with 1,378 additions and 116 deletions.
5 changes: 5 additions & 0 deletions required/latex-lab/changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-08-08 Ulrike Fischer <[email protected]>
* latex-lab-minipage.dtx, latex-lab-table.dtx: improve support for minipage in tables.
handle issue #37


2024-08-06 Ulrike Fischer <[email protected]>
* latex-lab-table.dtx: add support for header-columns
* latex-lab-table.dtx: add support for multirows
Expand Down
51 changes: 39 additions & 12 deletions required/latex-lab/latex-lab-minipage.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
%
% for those people who are interested or want to report an issue.
%
\def\ltlabminipagedate{2023-10-30}
\def\ltlabminipageversion{0.81c}
\def\ltlabminipagedate{2024-08-08}
\def\ltlabminipageversion{0.81d}
%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
Expand Down Expand Up @@ -120,12 +120,18 @@
% \end{macrocode}
% insert the socket
% \begin{macrocode}
\socket_use:n{tagsupport/minipage/before}% new
\UseTaggingSocket{minipage/before}% new
\setbox\@tempboxa\vbox\bgroup
\color@begingroup
\hsize\@tempdima
\textwidth\hsize \columnwidth\hsize
\@parboxrestore
% \end{macrocode}
% minipages are perhaps used in environments where the tagging of paragraphs
% has been altered. So we try to restore this. TODO: this should
% perhaps be done in \cs{@parboxrestore} directly.
% \begin{macrocode}
\UseTaggingSocket{para/restore}
\def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
\socket_assign_plug:nn{fntext/process}{mp}%
\let\@listdepth\@mplistdepth \@mplistdepth\z@
Expand Down Expand Up @@ -153,7 +159,7 @@
\tag_stop:n{minipage}
\expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}%
\tag_start:n{minipage}
\socket_use:n{tagsupport/minipage/after} %new end ...
\UseTaggingSocket{minipage/after} %new end ...
}
% \end{macrocode}
%
Expand All @@ -164,8 +170,15 @@
\leavevmode
\@pboxswfalse
\setlength\@tempdima{#4}%
\socket_use:n{tagsupport/parbox/before}
\@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}%
\UseTaggingSocket{parbox/before}
\@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore
% \end{macrocode}
% parbox are perhaps used in environments where the tagging of paragraphs
% has been altered. So we try to restore this. TODO: this should
% perhaps be done in \cs{@parboxrestore} directly.
% \begin{macrocode}
\UseTaggingSocket{para/restore}
#5\@@par}%
\ifx\relax#2\else
\setlength\@tempdimb{#2}%
\edef\@parboxto{to\the\@tempdimb}%
Expand All @@ -179,7 +192,7 @@
\csname bm@#3\endcsname}%
\if@pboxsw \m@th$\fi
\@end@tempboxa%
\socket_use:n{tagsupport/parbox/after}
\UseTaggingSocket{parbox/after}
}
% \end{macrocode}
%
Expand All @@ -191,9 +204,11 @@
\socket_new_plug:nnn{tagsupport/minipage/before}{tag/dflt}
{
% \end{macrocode}
% As there was a \cs{leavevmode} before that is a P/text open that we have to close.
% As there was a \cs{leavevmode} before that is a P/text open that we have to close
% if para tagging is active:
% \begin{macrocode}
\tag_mc_end_push:\tag_struct_end:
\tag_mc_end_push:
\bool_if:NT \l__tag_para_bool {\tag_struct_end:}
% \end{macrocode}
% TODO: the P can be further up, we need a proper method to test and handle this.
% \begin{macrocode}
Expand All @@ -203,13 +218,25 @@
% similar for the other sockets:
% \begin{macrocode}
\socket_new_plug:nnn{tagsupport/minipage/after}{tag/dflt}
{\tag_struct_end:\tag_struct_begin:n{tag=\l__tag_para_tag_tl}\tag_mc_begin_pop:n{}}
{
\tag_struct_end:
\bool_if:NT \l__tag_para_bool {\tag_struct_begin:n{tag=\l__tag_para_tag_tl}}
\tag_mc_begin_pop:n{}
}

\socket_new_plug:nnn{tagsupport/parbox/before}{tag/dflt}
{\tag_mc_end_push:\tag_struct_end:\tag_struct_begin:n{tag=\l__ltboxes_tag_tl}}
{
\tag_mc_end_push:
\bool_if:NT \l__tag_para_bool {\tag_struct_end:}
\tag_struct_begin:n{tag=\l__ltboxes_tag_tl}
}

\socket_new_plug:nnn{tagsupport/parbox/after}{tag/dflt}
{\tag_struct_end:\tag_struct_begin:n{tag=\l__tag_para_tag_tl}\tag_mc_begin_pop:n{}}
{
\tag_struct_end:
\bool_if:NT \l__tag_para_bool {\tag_struct_begin:n{tag=\l__tag_para_tag_tl}}
\tag_mc_begin_pop:n{}
}
% \end{macrocode}
% Activate the default tagging plug
% \begin{macrocode}
Expand Down
30 changes: 22 additions & 8 deletions required/latex-lab/latex-lab-table.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
%
% for those people who are interested or want to report an issue.
%
\def\ltlabtbldate{2024-08-06}
\def\ltlabtblversion{0.85k}
\def\ltlabtbldate{2024-08-08}
\def\ltlabtblversion{0.85l}
%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
Expand Down Expand Up @@ -546,20 +546,34 @@
% \enquote{vmode} tables like longtable.
%
% \begin{plugdecl}{Table}
% Inside a TD or TR Part is not allowed as child. For structures that restore
% paragraph settings we therefore need a special plug that adjust the settings.
% Currently we set the para main tag to Div. This leads to double Div-structures
% but flattening the paragraph doesn't work, it errors if there is a list inside.
% \begin{macrocode}
\NewSocketPlug{tagsupport/para/restore}{Table}
{
\tl_set:Nn \l__tag_para_main_tag_tl {Div}
\tl_set_eq:NN \l__tag_para_tag_tl\l__tag_para_tag_default_tl
\bool_set_true:N \l__tag_para_bool
\bool_set_false:N \l__tag_para_flattened_bool
}
% \end{macrocode}
% \end{plugdecl}
%
% \begin{plugdecl}{Table}
% Inside a table we currently only disable paratagging. We assume
% that these sockets are in an environment group, so there is no
% that these sockets are called in a group, so there is no
% need to reenable paratagging.
% \begin{macrocode}
\NewSocketPlug{tagsupport/tbl/init}{Table}
{
\tag_if_active:T
{
\bool_set_false:N \l__tag_para_bool
\bool_set_false:N \l__tag_para_bool
\AssignSocketPlug{tagsupport/para/restore}{Table}
% \end{macrocode}
% We also initialize the structure data variables a this point.
% \begin{macrocode}
\@@_init_struct_data:
}
\@@_init_struct_data:
}
% \end{macrocode}
% \end{plugdecl}
Expand Down
40 changes: 0 additions & 40 deletions required/latex-lab/testfiles-minipage/minipage-001.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,10 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 7 begin ignored with options: tag=\l__ltboxes_tag_tl
(tagpdf DEBUG)
(tagpdf DEBUG) [on line ...]
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 7 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 7 tagged /Div
Expand Down Expand Up @@ -373,14 +365,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 15 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 15 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 15 tagged /Div
Expand Down Expand Up @@ -561,14 +545,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 23 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 23 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 23 tagged /Div
Expand Down Expand Up @@ -749,14 +725,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 31 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 31 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 31 tagged /Div
Expand Down Expand Up @@ -1860,14 +1828,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 73 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 73 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 73 tagged /Div
Expand Down
40 changes: 0 additions & 40 deletions required/latex-lab/testfiles-minipage/minipage-001.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,10 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 7 begin ignored with options: tag=\l__ltboxes_tag_tl
(tagpdf DEBUG)
(tagpdf DEBUG) [on line ...]
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 7 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 7 tagged /Div
Expand Down Expand Up @@ -390,14 +382,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 15 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 15 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 15 tagged /Div
Expand Down Expand Up @@ -587,14 +571,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 23 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 23 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 23 tagged /Div
Expand Down Expand Up @@ -784,14 +760,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 31 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 31 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 31 tagged /Div
Expand Down Expand Up @@ -1946,14 +1914,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 73 begin ignored with options:
(tagpdf DEBUG) tag=\l__ltboxes_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 73 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 73 tagged /Div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 5 begin ignored with options: tag=\l__ltboxes_tag_tl
(tagpdf DEBUG)
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 5 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 5 tagged /Div
Expand Down
8 changes: 0 additions & 8 deletions required/latex-lab/testfiles-minipage/minipage-002-todo.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ braces):
> {{Root}{StructTreeRoot}}.
tagpdf DEBUG Info: Tagging stopped
(tagpdf DEBUG) level: 0 ==> 1, label: minipage [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 5 begin ignored with options: tag=\l__ltboxes_tag_tl
(tagpdf DEBUG)
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Struct end ignored [on line ...]
tagpdf DEBUG Info: Struct 5 begin ignored with options:
(tagpdf DEBUG) tag=\l__tag_para_tag_tl
(tagpdf DEBUG) [on line ...]
tagpdf DEBUG Info: Tagging restarted
(tagpdf DEBUG) level: 1 ==> 0, label: minipage [on line ...]
Package tagpdf Info: closing structure 5 tagged /Div
Expand Down
4 changes: 4 additions & 0 deletions required/latex-lab/testfiles-table-luatex/table-001.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
==> Table has 1 columns
[Sockets] ==> Socket 'tagsupport/tbl/init' containing plug 'Table' used.
[Sockets] ==> Replacing plug 'default' with 'Table' in socket 'tagsupport/para/restore'.
==> saved cell data: 0,0,1 (outer level)
[Sockets] ==> Socket 'tagsupport/tbl/init/celldata' containing plug 'default' used.
[Sockets] ==> Socket 'tagsupport/tbl/row/begin' containing plug 'TR' used.
Expand All @@ -35,6 +36,7 @@ LaTeX Font Info: External font `cmex10' loaded for size
[Sockets] ==> Socket 'tag/struct/tag' containing plug 'latex-tags' used.
==> Table has 1 columns
[Sockets] ==> Socket 'tagsupport/tbl/init' containing plug 'Table' used.
[Sockets] ==> Replacing plug 'default' with 'Table' in socket 'tagsupport/para/restore'.
==> saved cell data: 0,0,1 (outer level)
[Sockets] ==> Socket 'tagsupport/tbl/init/celldata' containing plug 'default' used.
[Sockets] ==> Socket 'tagsupport/tbl/row/begin' containing plug 'TR' used.
Expand All @@ -59,6 +61,7 @@ LaTeX Font Info: External font `cmex10' loaded for size
[Sockets] ==> Socket 'tag/struct/tag' containing plug 'latex-tags' used.
==> Table has 1 columns
[Sockets] ==> Socket 'tagsupport/tbl/init' containing plug 'Table' used.
[Sockets] ==> Replacing plug 'default' with 'Table' in socket 'tagsupport/para/restore'.
==> saved cell data: 0,0,1 (outer level)
[Sockets] ==> Socket 'tagsupport/tbl/init/celldata' containing plug 'default' used.
[Sockets] ==> Socket 'tagsupport/tbl/row/begin' containing plug 'TR' used.
Expand All @@ -83,6 +86,7 @@ LaTeX Font Info: External font `cmex10' loaded for size
[Sockets] ==> Socket 'tag/struct/tag' containing plug 'latex-tags' used.
==> Table has 1 columns
[Sockets] ==> Socket 'tagsupport/tbl/init' containing plug 'Table' used.
[Sockets] ==> Replacing plug 'default' with 'Table' in socket 'tagsupport/para/restore'.
==> saved cell data: 0,0,1 (outer level)
[Sockets] ==> Socket 'tagsupport/tbl/init/celldata' containing plug 'default' used.
[Sockets] ==> Socket 'tagsupport/tbl/row/begin' containing plug 'TR' used.
Expand Down
1 change: 1 addition & 0 deletions required/latex-lab/testfiles-table-luatex/table-002.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
==> Table has 3 columns
[Sockets] ==> Socket 'tagsupport/tbl/init' containing plug 'Table' used.
[Sockets] ==> Replacing plug 'default' with 'Table' in socket 'tagsupport/para/restore'.
==> saved cell data: 0,0,1 (outer level)
[Sockets] ==> Socket 'tagsupport/tbl/init/celldata' containing plug 'default' used.
[Sockets] ==> Socket 'tagsupport/tbl/row/begin' containing plug 'TR' used.
Expand Down
Loading

0 comments on commit 413eb8d

Please sign in to comment.