Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tikz library #29

Open
projetmbc opened this issue Jul 2, 2021 · 43 comments
Open

Improve tikz library #29

projetmbc opened this issue Jul 2, 2021 · 43 comments
Labels
feature request New feature or request long term This will be kept open for a long time
Milestone

Comments

@projetmbc
Copy link

projetmbc commented Jul 2, 2021

nicematrix use of names of the cells to play with TikZ for (even if this fine-tunings is used in some rare situations).

This could be a feature proposed only when using \UseTblrLibrary{tikz}.

@lvjr lvjr added the future plan 🚀 Something for the future label Jul 2, 2021
@lvjr
Copy link
Owner

lvjr commented Jul 2, 2021

Tabularray doesn't have this feature at this moment. Maybe in the future. Seems it need some hooks too (see also #27).

@lvjr
Copy link
Owner

lvjr commented Jan 14, 2023

In fact, nicematrix could create three nodes for each cell; the names of them are of the type i-j, i-j-medium and i-j-large. I am inclined to create only one node for each cell in tabularray.

Moreover, nicematrix creates a coordinate node i at each intersection of the ith hline and ith vline, hence coordinate i-|j is at the intersection of the ith hline and jth vline. (What if the number of rows is not equal to the number of columns? I haven't checked the code yet.)

First of all, we need to decide whether or not tabularray will adopt all the above interfaces of nicematrix.

@lvjr lvjr changed the title Suggestion - TikZ naming of cells Suggestion - TikZ naming of cells and borders Jan 14, 2023
@lvjr
Copy link
Owner

lvjr commented Jan 14, 2023

Also, nicematrix loads pgfcore but not tikz. Maybe tabularray could do the same and call it pgf library but not tikz library.

@lvjr lvjr added feature request New feature or request and removed future plan 🚀 Something for the future labels Dec 18, 2024
@lvjr lvjr changed the title Suggestion - TikZ naming of cells and borders Improve tikz library Dec 18, 2024
@lvjr
Copy link
Owner

lvjr commented Dec 18, 2024

I have merged pull request #554 (Add tikz library) contributed by Jasper Habicht. We can discuss further improvements to this library in this issue.

@jasperhabicht
Copy link
Contributor

jasperhabicht commented Dec 18, 2024

I just read issue #27 about PDF tagging and I think it might be a good idea to add another hook directly before tabularray/cell/after where the TikZ node is inserted to make sure the TikZ node (which should be handled as artifact in terms of tagging) is not being placed outside the cell.

@lvjr
Copy link
Owner

lvjr commented Dec 18, 2024

As far as I know, by default contents not tagged as mcs by some code are treated as artifects by tagpdf. So tblrlibtagpdf needs only to put its hook before tblrlibtikz by using \DeclareHookRule.

@lvjr
Copy link
Owner

lvjr commented Dec 21, 2024

In above commit I have added tblrtikzbefore and rename tblrtikz as tblrtikzafter. Here is an example:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{tikz}
\usetikzlibrary{patterns}
\begin{document}
BEFORE%
\begin{tblrtikzbefore}
  \fill[pattern color=lightgray,pattern=bricks]
    (table.north east) rectangle (table.south west);
\end{tblrtikzbefore}%
\begin{tblr}{
    hlines, vlines, 
    colspec={ l l l l },
    hline{1} = {2pt},
    vline{1} = {1}{2pt},
    vline{2} = {2}{-}{1pt},
    hline{Z} = {2pt},
    cell{2}{2} = {r=2, c=2}{c}
}
    1 & 2 & 3 & 5 \\
    4 & foo bar baz & 6 \\
    7 & 8 & 9 & 10 
\end{tblr}%
\begin{tblrtikzafter}
    \draw[green] (1-1.north west) circle[radius=1pt];
    \draw[green] (1-1.north east) circle[radius=1pt];
    \draw[green] (1-1.south west) circle[radius=1pt];
    \draw[green] (1-1.south east) circle[radius=1pt];
    \draw[red] (2-2.north west) circle[radius=1pt];
    \draw[red] (2-2.north east) circle[radius=1pt];
    \draw[red] (2-2.south west) circle[radius=1pt];
    \draw[red] (2-2.south east) circle[radius=1pt];
    \draw[blue] (3-1.north west) circle[radius=1pt];
    \draw[blue] (3-1.north east) circle[radius=1pt];
    \draw[blue] (3-1.south west) circle[radius=1pt];
    \draw[blue] (3-1.south east) circle[radius=1pt];
    \draw[yellow] (table.north west) circle[radius=1pt];
    \draw[yellow] (table.north east) circle[radius=1pt];
    \draw[yellow] (table.south west) circle[radius=1pt];
    \draw[yellow] (table.south east) circle[radius=1pt];
\end{tblrtikzafter}%
AFTER
\par\vspace{1em}
\begin{tblrtikzbefore}
  \fill[color=red]
    (table.north east) rectangle (table.south west);
\end{tblrtikzbefore}%
\begin{tblr}{|l|c|c|r|}
\hline
 Alpha   & Beta  & Gamma  & Delta \\
\hline
 Epsilon & Zeta  & Eta    & Theta \\
\hline
 Iota    & Kappa & Lambda & Mu    \\
\hline
\end{tblr}
\end{document}
image

@lvjr
Copy link
Owner

lvjr commented Dec 21, 2024

@jasperhabicht From above example, it seems tikz table node is a bit larger than the table box. Any idea?

@muzimuzhi
Copy link
Collaborator

muzimuzhi commented Dec 21, 2024

You also need /tikz/outer sep=0pt.

This option adds an additional (invisible) separation space of ⟨dimension⟩ outside the background path. The main effect of this option is that all anchors will move a little “to the outside”.
https://tikz.dev/tikz-shapes#pgf./pgf/outer:sep

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
% default "outer sep"
\begin{tikzpicture}[line width=3pt]
  \node[draw=none, fill=none, inner sep=0pt, text width=3cm, text height=2cm] (a) at (0,0) {};
  \draw[red] (a.north east) rectangle (a.south west);
  \draw (-1.5, 0) -- (1.5, 0);
\end{tikzpicture}

% "outer sep=0pt"
\begin{tikzpicture}[line width=3pt]
  \node[draw=none, fill=none, inner sep=0pt, outer sep=0pt, text width=3cm, text height=2cm] (a) at (0,0) {};
  \draw[red] (a.north east) rectangle (a.south west);
  \draw (-1.5, 0) -- (1.5, 0);
\end{tikzpicture}
\end{document}

image

As a cross reference, see how tcolorbox provides tikz nodes for different parts of a tcolorbox.

Update: I just opened #559 to address this.

@jasperhabicht
Copy link
Contributor

jasperhabicht commented Dec 21, 2024

You also need /tikz/outer sep=0pt.

...

As a cross reference, see how tcolorbox provides tikz nodes for different parts of a tcolorbox.

...

True, I missed that. Thanks!

Interesting that the tcolorbox package uses minimum width and minimum height in combination with line height. Having again read the TikZ manual, I think in the case of cells and tables, text width is better, because it will set a fixed width of the node, no matter what its contents are.

Of course, if the node is empty (which it is supposed to be anyways), the result will be the same. But we also need to take into account depth here, so using the text ... options feels more appropriate.

@lvjr
Copy link
Owner

lvjr commented Dec 21, 2024

It seems there is a bug with multispan cells and omitted cells. Here is an example for showing the problem:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{tikz}
\usetikzlibrary{patterns}
\begin{document}

\section{Normal cells}

\begin{tblr}{|c|c|c|[2pt]|c|c|}
\hline
 \SetCell[r=2]{c} 2 Rows
     & \SetCell[c=2]{c} 2 Columns
           &     & \SetCell[r=2,c=2]{c} 2 Rows 2 Columns & \\
\hline
     & 2-2 & 2-3 &     &     \\
\hline\hline[1pt]
 3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
\cline[2pt]{1-2}\cline[1pt]{3}\cline[3pt]{4-5}
\end{tblr}%

\section{Multispan cells}

\begin{tblr}{|c|c|c|[2pt]|c|c|}
\hline
 \SetCell[r=2]{c} 2 Rows
     & \SetCell[c=2]{c} 2 Columns
           &     & \SetCell[r=2,c=2]{c} 2 Rows 2 Columns & \\
\hline
     & 2-2 & 2-3 &     &     \\
\hline\hline[1pt]
 3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
\cline[2pt]{1-2}\cline[1pt]{3}\cline[3pt]{4-5}
\end{tblr}%
\begin{tblrtikzafter}
  \fill[blue7] (1-4.north west) rectangle (1-4.south east);
\end{tblrtikzafter}

\section{Omitted cells}

\begin{tblr}{|c|c|c|[2pt]|c|c|}
\hline
 \SetCell[r=2]{c} 2 Rows
     & \SetCell[c=2]{c} 2 Columns
           &     & \SetCell[r=2,c=2]{c} 2 Rows 2 Columns & \\
\hline
     & 2-2 & 2-3 &     &     \\
\hline\hline[1pt]
 3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
\cline[2pt]{1-2}\cline[1pt]{3}\cline[3pt]{4-5}
\end{tblr}%
\begin{tblrtikzafter}
  \fill[red7] (1-3.north west) rectangle (1-3.south east);
  \fill[yellow7] (2-1.north west) rectangle (2-1.south east);
  \fill[teal7] (1-5.north west) rectangle (1-5.south east);
  \fill[brown7] (2-4.north west) rectangle (2-4.south east);
  \fill[purple7] (2-5.north west) rectangle (2-5.south east);
\end{tblrtikzafter}

\end{document}
image

lvjr added a commit that referenced this issue Dec 21, 2024
@lvjr lvjr added the long term This will be kept open for a long time label Jan 18, 2025
@lvjr
Copy link
Owner

lvjr commented Jan 19, 2025

Since corner nodes work only with new node code, I have removed old node code.

@lvjr lvjr marked this as a duplicate of #565 Jan 20, 2025
@lvjr
Copy link
Owner

lvjr commented Jan 20, 2025

It seems these lines can be removed:

\box_set_trim:Nnnnn \l__tblr_tikz_node_box
    { 0pt } { 0pt } { 0pt } { 0pt }

@jasperhabicht
Copy link
Contributor

jasperhabicht commented Jan 20, 2025

It seems these lines can be removed:

\box_set_trim:Nnnnn \l__tblr_tikz_node_box
    { 0pt } { 0pt } { 0pt } { 0pt }

I originally added these to absolutely make sure that the box created for the TikZ stuff is zero-sized. In theory, since the tikzpicture environment has the overlay option, it should already be zero-sized.

If we rely on this, we can indeed omit \box_set_trim:Nnnnn, especially if we don't use it for shifting the contents of the box (which we probably should not do anyways as it can be done with TikZ, but I saw that you changed the code and only use \box_set_trim:Nnnnn with 0pt values.).

As for the calc library, I think it is indeed the most straight-forward way to set the coordinates.

lvjr added a commit that referenced this issue Jan 22, 2025
@lvjr
Copy link
Owner

lvjr commented Jan 22, 2025

Removed. Also I have added labels to the hooks.

@lvjr
Copy link
Owner

lvjr commented Jan 25, 2025

Recently I have been considering long table support. Here are some ideas:

  1. A long table normally consists of several boxes in different pages. So we need to execute tblrtikzbefore and tblrtikzafter code several times. Therefore we have to also put tblrtikzafter before tblr, so that we can collect its body code with +b argument type. And it is better to rename them as tblrtikzbelow and tblrtikzabove.
  2. A long table may have lots of rows. So it is clumsy to use row numbers directly in drawing. Therefore I have implemented \SetChild command for setting ids and classes of rows/columns/cells (see Naming cells, rows and columns #381). The concepts of ids and classes are from html/css).
  3. In drawing, users are responsible for making sure the elements to draw are in the same page (by using \\*). Also we need to provide some public variables:
    • \lTblrRowHeadInt (from \l__tblr_row_head_tl) (count of head rows);
    • \lTblrRowFootInt (from \l__tblr_row_foot_tl) (count of foot rows);
    • \lTblrRowFirstInt (start rownum in current page);
    • \lTblrRowLastInt (end rownum in curent page);
    • \lTblrTablePageInt (from \l__tblr_table_page_int) (number of page).
  4. The page table nodes for long tables will be missing if rowfoot>0.

@lvjr
Copy link
Owner

lvjr commented Jan 25, 2025

I have enabled tikz drawing for long tables in above commit. The good news is that everything works well if the longtblr has only one page and rowhead=0, rowfoot=0.

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{tikz}
\usetikzlibrary{patterns}
\begin{document}

\begin{tblrtikzbelow}
  \fill[pattern color=lightgray,pattern=crosshatch]
    (table.north east) rectangle (table.south west);
  \fill[yellow7] (3-1.north west) rectangle (3-1.south east);
  \fill[red7] (3-3.north west) rectangle (3-3.south east);
  \fill[purple7] (3-5.north west) rectangle (3-5.south east);
  \fill[teal7] (4-2.north west) rectangle (4-2.south east);
  \fill[brown7] (4-4.north west) rectangle (4-4.south east);
\end{tblrtikzbelow}%
\begin{tblrtikzabove}
  \draw[brown7,ultra thick] (7-2.north west) -- (7-2.south east)
                     (7-2.south west) -- (7-2.north east);
  \draw[yellow7,ultra thick] (7-4.north west) -- (7-4.south east)
                     (7-4.south west) -- (7-4.north east);
  \draw[purple7,ultra thick] (8-1.north west) -- (8-1.south east)
                     (8-1.south west) -- (8-1.north east);
  \draw[cyan3,ultra thick] (8-3.north west) -- (8-3.south east)
                     (8-3.south west) -- (8-3.north east);
  \draw[teal7,ultra thick] (8-5.north west) -- (8-5.south east)
                     (8-5.south west) -- (8-5.north east);
  \draw[color=white,thick]
       (h5-|v1) -- (h5-|v2) -- (h6-|v2)
    -- (h6-|v3) -- (h7-|v3) -- (h7-|v4)
    -- (h5-|v4) -- (h5-|v5) -- (h6-|v5)
    -- (h6-|v6) -- (h5-|v6);
\end{tblrtikzabove}%
\begin{longtblr}[
  caption = Long Table Tikz 
]{
  %rowhead=2, rowfoot=1,
  hlines={wd=4pt},vlines={wd=3pt},colspec={XXXXX}
}
  1-1 & 1-2 & 1-3 & 1-4 & 1-5 \\
  2-1 & 2-2 & 2-3 & 2-4 & 2-5 \\
  3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
  4-1 & 4-2 & 4-3 & 4-4 & 4-5 \\%\pagebreak
  5-1 & 5-2 & 5-3 & 5-4 & 5-5 \\
  6-1 & 6-2 & 6-3 & 6-4 & 6-5 \\
  7-1 & 7-2 & 7-3 & 7-4 & 7-5 \\
  8-1 & 8-2 & 8-3 & 8-4 & 8-5 \\
  9-1 & 9-2 & 9-3 & 9-4 & 9-5 \\
\end{longtblr}

\end{document}

Image

lvjr added a commit that referenced this issue Jan 25, 2025
@lvjr
Copy link
Owner

lvjr commented Jan 25, 2025

The bad news is that if we enable rowhead, rowfoot or \pagebreak in the above example, we get some warnings and errors:

LaTeX Warning: Label `pgfid1' multiply defined.
LaTeX Warning: Label `pgfid2' multiply defined.
...
! Package pgf Error: No shape named `table' is known.
! Package pgf Error: No shape named `5-1' is known.
! Package pgf Error: No shape named `5-1-single' is known.
...

@jasperhabicht
Copy link
Contributor

jasperhabicht commented Jan 26, 2025

The bad news is that if we enable rowhead, rowfoot or \pagebreak in the above example, we get some warnings and errors:

LaTeX Warning: Label `pgfid1' multiply defined.
LaTeX Warning: Label `pgfid2' multiply defined.
...
! Package pgf Error: No shape named `table' is known.
! Package pgf Error: No shape named `5-1' is known.
! Package pgf Error: No shape named `5-1-single' is known.
...

It seems that the code defined via tblrtikzabove (probably also that of tblrtikzbelow is added to both parts of the longtblr, that is to both \l__tblr_table_boxes. For longtblrs, we need to somehow allow the user to state which part they want the TikZ environments to apply to.

At least, we need separate TikZ environments for every page that may only refer to nodes that exist on this page. Also, the table node seems to only exist for the last part currently. There should be one for every part.

@lvjr
Copy link
Owner

lvjr commented Jan 27, 2025

I have provided some public variables:

  • \lTblrPortraitTypeTl : table type (short, tall, or long);
  • \lTblrTablePageInt: index of current page table;
  • \lTblrRowHeadInt: count of head rows;
  • \lTblrRowFootInt: count of foot rows;
  • \lTblrRowFirstInt: start rownum in current page;
  • \lTblrRowLastInt: end rownum in curent page.

Therefore uses can do conditional tikz drawing on tables.

@lvjr lvjr pinned this issue Jan 27, 2025
@lvjr
Copy link
Owner

lvjr commented Jan 27, 2025

With above public variables, we can do conditional drawing (by making sure used cell nodes are actually in current page) in tblrtikzbelow and tblrtikzabove environments:

\documentclass{article}
\usepackage[a6paper,margin=15mm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{tikz}
\usetikzlibrary{patterns}
\begin{document}

\ExplSyntaxOn
\cs_set_eq:NN \boolifnT \bool_if:nT
\cs_set_eq:NN \intcomparepn \int_compare_p:n
\ExplSyntaxOff

\begin{tblrtikzbelow}
  \fill[pattern color=lightgray,pattern=crosshatch]
    (table.north east) rectangle (table.south west);
  \boolifnT{
    \intcomparepn{\lTblrRowFirstInt <= 3} && \intcomparepn{\lTblrRowLastInt >= 4}
  }{
    \fill[yellow7] (3-1.north west) rectangle (3-1.south east);
    \fill[red7] (3-3.north west) rectangle (3-3.south east);
    \fill[purple7] (3-5.north west) rectangle (3-5.south east);
    \fill[teal7] (4-2.north west) rectangle (4-2.south east);
    \fill[brown7] (4-4.north west) rectangle (4-4.south east);
  }
\end{tblrtikzbelow}%
\begin{tblrtikzabove}
  \boolifnT{
    \intcomparepn{\lTblrRowFirstInt <= 7} && \intcomparepn{\lTblrRowLastInt >= 8}
  }{
    \draw[brown7,ultra thick] (7-2.north west) -- (7-2.south east)
                       (7-2.south west) -- (7-2.north east);
    \draw[yellow7,ultra thick] (7-4.north west) -- (7-4.south east)
                       (7-4.south west) -- (7-4.north east);
    \draw[purple7,ultra thick] (8-1.north west) -- (8-1.south east)
                       (8-1.south west) -- (8-1.north east);
    \draw[cyan3,ultra thick] (8-3.north west) -- (8-3.south east)
                       (8-3.south west) -- (8-3.north east);
    \draw[teal7,ultra thick] (8-5.north west) -- (8-5.south east)
                       (8-5.south west) -- (8-5.north east);
  }
\end{tblrtikzabove}%
\begin{longtblr}[
  caption = Long Table Tikz 
]{
  rowhead=2,
  rowfoot=1,
  hlines={wd=4pt},vlines={wd=3pt},colspec={XXXXX}
}
  1-1 & 1-2 & 1-3 & 1-4 & 1-5 \\
  2-1 & 2-2 & 2-3 & 2-4 & 2-5 \\
  3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
  4-1 & 4-2 & 4-3 & 4-4 & 4-5 \\\pagebreak
  5-1 & 5-2 & 5-3 & 5-4 & 5-5 \\
  6-1 & 6-2 & 6-3 & 6-4 & 6-5 \\
  7-1 & 7-2 & 7-3 & 7-4 & 7-5 \\
  8-1 & 8-2 & 8-3 & 8-4 & 8-5 \\
  9-1 & 9-2 & 9-3 & 9-4 & 9-5 \\
\end{longtblr}

\end{document}

Image

@lvjr
Copy link
Owner

lvjr commented Jan 27, 2025

The bad news is that if we enable rowhead, rowfoot or \pagebreak in the above example, we get some warnings and errors:

LaTeX Warning: Label `pgfid1' multiply defined.
LaTeX Warning: Label `pgfid2' multiply defined.
...
! Package pgf Error: No shape named `table' is known.
! Package pgf Error: No shape named `5-1' is known.
! Package pgf Error: No shape named `5-1-single' is known.
...

It seems that the code defined via tblrtikzabove (probably also that of tblrtikzbelow is added to both parts of the longtblr, that is to both \l__tblr_table_boxes. For longtblrs, we need to somehow allow the user to state which part they want the Ti_k_Z environments to apply to.

At least, we need separate Ti_k_Z environments for every page that may only refer to nodes that exist on this page. Also, the table node seems to only exist for the last part currently. There should be one for every part.

I am inclined to try current tblrtikzbelow and tblrtikzabove environments first (we can create new envs if really needed). The above example demonstrates the possibility.

For a multipage long table, cell nodes works as expected. But the table node is wrong, so I have temporarily disabled corner nodes for multipage long tables in the commit above.

@lvjr
Copy link
Owner

lvjr commented Jan 27, 2025

With \SetChild (see #381) and \ExpTblrChildClass (see 23987ef) commands, we can avoid writing row numbers explicitly in tikz drawing:

\documentclass{article}
\usepackage[a6paper,margin=15mm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{tikz}
\usetikzlibrary{patterns}
\begin{document}
\ExplSyntaxOn
\cs_generate_variant:Nn \clist_map_inline:nn {e}
\cs_new_protected:Npn \mymagic #1
  {
    \clist_map_inline:en {\ExpTblrChildClass {#1}}
      {
        \bool_lazy_and:nnT
          { \int_compare_p:n {\lTblrRowFirstInt <= \use_i:nn ##1} } 
          { \int_compare_p:n {\lTblrRowLastInt >= \use_i:nn ##1} }
          { \exp_args:Noo \mymagicfill {\use_i:nn ##1} {\use_ii:nn ##1} }
      }
  }
\ExplSyntaxOff
\newcommand\mymagicfill[2]{
  \fill[teal7] (#1-#2.north west) rectangle (#1-#2.south east);
}
\begin{tblrtikzbelow}
  \fill[pattern color=lightgray,pattern=crosshatch]
    (table.north east) rectangle (table.south west);
  \mymagic{magic}
\end{tblrtikzbelow}%
\begin{longtblr}[
  caption = Long Table Tikz 
]{
  rowhead=2,
  rowfoot=1,
  hlines={wd=4pt},vlines={wd=3pt},colspec={*{5}{X[r]}}
}
  Head1 & Head2 & Head3 & Head4 & Head5 \\
  Head1 & Head2 & Head3 & Head4 & Head5 \\
    3-1 &   3-2 &   3-3 &   3-4 &   3-5 \\
    4-1 &   4-2 &   4-3 &   \SetChild{class=magic}4-4
                                &   4-5 \\
    5-1 &   5-2 &   5-3 &   5-4 &   5-5 \\
    6-1 &   6-2 &   6-3 &   6-4 &   6-5 \\
    7-1 &   \SetChild{class=magic}7-2
                &   7-3 &   7-4 &   7-5 \\
    8-1 &   8-2 &   8-3 &   8-4 & \SetChild{class=magic}8-5 \\
    9-1 &   9-2 &   9-3 &   9-4 &   9-5 \\
   10-1 &  10-2 &  10-3 &  10-4 &  10-5 \\
   11-1 &  11-2 &  11-3 &  11-4 &  11-5 \\
   \SetChild{class=magic}12-1
        &  12-2 &  12-3 &  12-4 &  12-5 \\
   13-1 &  13-2 &  13-3 &  13-4 &  13-5 \\
   14-1 &  14-2 &  14-3 &  14-4 &  14-5 \\
   15-1 &  15-2 &  15-3 &  15-4 &  \SetChild{class=magic}15-5 \\
   16-1 &  16-2 &  16-3 &  16-4 &  16-5 \\
   17-1 &  17-2 &  17-3 &  17-4 &  17-5 \\
   18-1 &  18-2 &  18-3 &  18-4 &  18-5 \\
   19-1 &  19-2 & \SetChild{class=magic}19-3
                        &  19-4 &  19-5 \\
   20-1 &  20-2 &  20-3 &  20-4 &  20-5 \\
   21-1 &  21-2 &  21-3 &  21-4 &  21-5 \\
   22-1 &  \SetChild{class=magic}22-2
                &  22-3 &  22-4 &  22-5 \\
   23-1 &  23-2 &  23-3 &  23-4 &  23-5 \\
   24-1 &  24-2 &  24-3 &  24-4 &  24-5 \\
   \SetChild{class=magic}25-1
        &  25-2 &  25-3 &  25-4 &  25-5 \\
   26-1 &  26-2 &  26-3 &  26-4 &  26-5 \\
   27-1 &  27-2 &  27-3 &  27-4 &  27-5 \\
   28-1 &  28-2 &  28-3 &  28-4 &  28-5 \\
   29-1 &  29-2 &  29-3 &  29-4 &  29-5 \\
   30-1 &  30-2 &  30-3 &  \SetChild{class=magic}30-4
                                &  30-5 \\
   31-1 &  31-2 &  31-3 &  31-4 &  31-5 \\
   32-1 &  32-2 &  32-3 &  32-4 &  32-5 \\
   33-1 &  33-2 &  33-3 &  33-4 &  33-5 \\
   34-1 &  \SetChild{class=magic}34-2
                &  34-3 &  34-4 &  34-5 \\
   35-1 &  35-2 &  35-3 &  35-4 &  35-5 \\
   36-1 &  36-2 &  36-3 &  36-4 &  36-5 \\
   37-1 &  37-2 &  \SetChild{class=magic}37-3
                        &  37-4 &  37-5 \\
   38-1 &  38-2 &  38-3 &  38-4 &  38-5 \\
  Foot1 & Foot2 & Foot3 & Foot4 & Foot5 \\
\end{longtblr}
\end{document}

Image

In this example, the clist expanded from \ExpTblrChildClass {#1} is

{4}{4},{7}{2},{8}{5},{12}{1},{15}{5},{19}{3},{22}{2},{25}{1},{30}{4},{34}{2},{37}{3}

@lvjr
Copy link
Owner

lvjr commented Jan 27, 2025

The main problem is the table nodes. At this time table nodes are created after the last cells in cell/after hook. To solve this problem, I think it may be possible to create table nodes in private/output/before hook. But table_head_box and table_foot_box are obstacles for tall and long tables: they can not be included into the table node.

\cs_new_protected:Npn \__tblr_build_short_table:n #1
  {
    \mode_leave_vertical:
    \__tblr_build_one_table:nnNN {1} {\c@rowcount} \c_true_bool \c_true_bool
    \__tblr_hook_use:n { private/output/before }
    \__tblr_valign_whole:Nn \l__tblr_table_box {#1}
    \__tblr_hook_use:n { private/output/after }
  }
\cs_new_protected:Npn \__tblr_build_tall_table:n #1
  {
    \mode_leave_vertical:
    \__tblr_build_tall_table_head_foot:
    \__tblr_build_one_table:nnNN {1} {\c@rowcount} \c_true_bool \c_true_bool
    \vbox_set:Nn \l__tblr_table_box
      {
        \box_use:N \l__tblr_table_firsthead_box
        \hrule height ~ 0pt
        \box_use:N \l__tblr_table_box
        \hrule height ~ 0pt
        \box_use:N \l__tblr_table_lastfoot_box
      }
    \__tblr_hook_use:n { private/output/before }
    \__tblr_valign_whole:Nn \l__tblr_table_box {#1}
    \__tblr_hook_use:n { private/output/after }
  }
\cs_new_protected:Npn \__tblr_build_page_table:nnn #1 #2 #3
  {
    \int_set:Nn \lTblrRowFirstInt {#2}
    \int_set:Nn \lTblrRowLastInt {#3}
    \__tblr_build_one_table:nnNN {#2} {#3} \c_false_bool \c_false_bool
    \vbox_set:Nn \l__tblr_table_box
      {
        \box_use:N \l__tblr_table_head_box
        \__tblr_cover_two_vboxes:NN \l__tblr_row_head_box \l__tblr_table_box
        \box_use:N \l__tblr_row_foot_box
        \hrule height ~ 0pt
        \box_use:N \l__tblr_table_foot_box
      }
    \__tblr_hook_use:n { private/output/before }
    \__tblr_halign_whole:Nn \l__tblr_table_box {#1}
    \__tblr_hook_use:n { private/output/after }
  }

@lvjr
Copy link
Owner

lvjr commented Jan 28, 2025

There is a catcode problem in loading tikz libraries: pgf-tikz/pgf#1213.

@jasperhabicht
Copy link
Contributor

There is a catcode problem in loading tikz libraries: pgf-tikz/pgf#1213.

Seems that it can be solved: latex3/latex3#235 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request long term This will be kept open for a long time
Projects
None yet
Development

No branches or pull requests

4 participants