5

It seems that there is no way to give a name to a tblr table. Because of that, with the tikz library for tblr tables it is impossible to draw things implying other tables than the first that latex finds after the tblrtikzabove environment.

Here I have made two tables with some tikz elements. I want to draw lines from one table to the other. Like in the drawing here: two tblr tables with tikz elements

by the way... if anybody could find the actual rows/columns corner nodes, not the middle segment between them. Since I set a non-null rowsep and colsep, a separation should be seen between the two rectangles.

mwe:

\documentclass[aspectratio=169]{beamer}

\mode<presentation>
\usetheme{metropolis}

\usepackage{tabularray,tikz}

\UseTblrLibrary{booktabs,tikz}


\tikzset{
      styleall/.style = {rounded corners=.4ex,thick}
}


\setlength{\parindent}{0pt}
\begin{document}
\begin{frame}{aaa}
  \begin{columns}[t]
    \begin{column}{.45\textwidth}

      \frametitle{beamer}
      
      \textbf{letters}


      \begin{tblrtikzabove}
        \draw[red,styleall]
        (1-1.north west) rectangle (1-4.south east);
        
        \draw[green,styleall]
        (2-1.north west) rectangle (2-4.south east);
      \end{tblrtikzabove}
      
      \SetTblrInner{rowsep=6pt}
      \begin{tblr}{colspec={cccc},rowsep={4pt},colsep={4pt}}
        a & e & i & o\\
        b & c & d & f\\
      \end{tblr}
 
    \end{column}


    \begin{column}{.45\textwidth}
      \textbf{letters again}
      
     
      \begin{tblrtikzabove}
        \draw[red,styleall]
        (1-1.north west) rectangle (1-2.south east);
          
        \draw[green,styleall]
        (2-1.north west) rectangle (2-4.south east);
      \end{tblrtikzabove}
      
      \begin{tblr}{cccc}
        u & y &   &\\
        g & h & j & k\\
      \end{tblr}
      
    \end{column}
  \end{columns}
    
\end{frame}
\end{document}
4
  • You can use name to give the table a name and then use tblr<name>- as prefix in the TikZ code as far as I know. The table node (that is, the node that contains the complete table) has the name tblr<name>-table where <name> is the name you give via the name key to the tblr environment. (This is at least how it is supposed to be working to my knowledge.) Commented Oct 11 at 7:51
  • 1
    I need to try that in detail, but I think you can use the fit library to create nodes in a tblr making use of name (see above comment) for each row of this table. Then you should be able to connect these nodes in a tikzpicture that you put after the two tblr environments (or maybe in the last tblrtikzabove environment). Commented Oct 11 at 8:06
  • Please note that the metropolis theme is outdated. You shouldn't use it with current versions of latex. The moloch theme is an updated fork. Commented Oct 11 at 10:03
  • Why use \setlength{\parindent}{0pt} in beamer? Commented Oct 11 at 10:04

3 Answers 3

5

Here is a solution (using name to name the tblrs and using fit, calc and meta.arrows TikZ libraries):

\documentclass[aspectratio=169]{beamer}

\mode<presentation>
\usetheme{metropolis}

\usepackage{tabularray,tikz}
\usetikzlibrary{fit,calc,arrows.meta}
\UseTblrLibrary{booktabs,tikz}


\tikzset{
      styleall/.style = {rounded corners=.4ex,thick}
}

\setlength{\parindent}{0pt}
\begin{document}
\begin{frame}{aaa}
  \begin{columns}[t]
    \begin{column}{.45\textwidth}

      \frametitle{beamer}
      
      \textbf{letters}


      \begin{tblrtikzabove}
        \node[fit=(1-1)(1-4),inner ysep=-.5ex,inner xsep=0] (l1) {}; % <== fit
        \draw[red,styleall] (l1.north west) rectangle (l1.south east); 
        
        \node[fit=(2-1)(2-4),inner ysep=-.5ex,inner xsep=0] (l2) {}; % <== fit
        \draw[green,styleall] (l2.north west) rectangle (l2.south east);
      \end{tblrtikzabove}
      
      \SetTblrInner{rowsep=6pt}
      \begin{tblr}{name=a,colspec={cccc},rowsep={4pt},colsep={4pt}} % <== name
        a & e & i & o\\
        b & c & d & f\\
      \end{tblr}
 
    \end{column}


    \begin{column}{.45\textwidth}
      \textbf{letters again}
      
     
      \begin{tblrtikzabove}
        \node[fit=(1-1)(1-4),inner ysep=-.5ex,inner xsep=0] (l1) {}; % <== fit
        \draw[red,styleall] (l1.north west) rectangle (l1.south east);
        
        \node[fit=(2-1)(2-4),inner ysep=-.5ex,inner xsep=0] (l2) {}; % <== fit
        \draw[green,styleall] (l2.north west) rectangle (l2.south east);
      \end{tblrtikzabove}
      
      \begin{tblr}{name=b,colspec={cccc}} % <== name
        u & y &   &\\
        g & h & j & k\\
      \end{tblr}
      
    \end{column}

    \begin{tikzpicture}[overlay,remember picture]
      \draw[red,styleall,shorten <=1ex,shorten >=1ex,Circle-LaTeX] (tblra-l1) -| ($(tblra-l1)!.5!(tblrb-l1)$) |- (tblrb-l1);
      \draw[green,styleall,shorten <=1ex,shorten >=1ex,Circle-LaTeX] (tblra-l2) -| ($(tblra-l2)!.5!(tblrb-l2)$) |- (tblrb-l2);
    \end{tikzpicture}
    
  \end{columns}
    
\end{frame}
\end{document}

enter image description here

5

The nodes from a tabularray table are automatically available in other tikz pictures (internally, tblr uses the remember picture option), you just need to know the number of the tblr:

\documentclass[aspectratio=169]{beamer}

\usetheme{moloch}

\usepackage{tabularray,tikz}
\UseTblrLibrary{tikz}
\usetikzlibrary{ext.paths.ortho}
\usetikzlibrary{arrows.meta}

\tikzset{
      styleall/.style = {rounded corners=.4ex,thick},
      myarrow/.style={thick,shorten <=0.25cm,shorten >=0.25cm,Circle->}
}

\begin{document}
\begin{frame}
  \frametitle{beamer}
  \begin{columns}[t]
    \begin{column}{.45\textwidth}
      \vskip2cm
          
      \textbf{letters}
      
      \begin{tblrtikzabove}
        \draw[red,styleall]
        (1-1.north west) rectangle (1-4.south east);
        
        \draw[green,styleall]
        (2-1.north west) rectangle (2-4.south east);
      \end{tblrtikzabove}
      \SetTblrInner{rowsep=6pt}
      \begin{tblr}{cells={halign=c},rowsep={4pt},colsep={4pt}}
        a & e & i & o\\
        b & c & d & f\\
      \end{tblr}
 
    \end{column}


    \begin{column}{.45\textwidth}
      \textbf{letters again}
      
      \begin{tblrtikzabove}
        \draw[red,styleall]
        (1-1.north west) rectangle (1-2.south east);
        \draw[red,myarrow] ([email protected]) -|- (1-1.west); 
          
        \draw[green,styleall]
        (2-1.north west) rectangle (2-4.south east);
        \draw[green,myarrow] ([email protected]) -- ++(1.5,0) -|- (2-1.west); 
      \end{tblrtikzabove}
      \begin{tblr}{cells={halign=c}}
        u & y &   &\\
        g & h & j & k\\
      \end{tblr}
      
    \end{column}
  \end{columns}
    
\end{frame}
\end{document}

enter image description here

3
  • 1
    Yup, it should also be possible to set a name to the tblr environment and use this instead of @<id>. At least that was the idea … Commented Oct 11 at 13:26
  • 2
    @JasperHabicht The name approach is already covered in tex.stackexchange.com/a/752317/36296 Commented Oct 11 at 13:27
  • I just saw that! You are right. So it works which I am happy to see (having been involved in the making of the tikz library for the package and currently being unable to test all this …) 👍 Commented Oct 11 at 13:29
2

Yep, but tikz in tabularray is an experimental package, I try with tikzmark to minic what you want, maybe you could post Feature Request to tabularray:

\documentclass[aspectratio=169]{beamer}
\mode<presentation>
\usetheme{metropolis}
\usepackage{tabularray,tikz}
\usetikzlibrary{tikzmark,arrows.meta,ext.paths.ortho}
\UseTblrLibrary{booktabs,tikz}
\tikzset{styleall/.style = {rounded corners=.4ex,thick}}
\setlength{\parindent}{0pt}
\begin{document}
\begin{frame}{aaa}
  \begin{columns}[t]
    \begin{column}{.45\textwidth}

      \frametitle{beamer}
      
      \textbf{letters}


      \begin{tblrtikzabove}
        \draw[red,styleall]
        (1-1.north west) rectangle (1-4.south east);
        
        \draw[green,styleall]
        (2-1.north west) rectangle (2-4.south east);
      \end{tblrtikzabove}
      
      \SetTblrInner{rowsep=6pt}
      \begin{tblr}{colspec={cccc},rowsep={4pt},colsep={4pt}}
        a & e & i & \tikzmarknode{A1}{o}\\
        b & c & d & \tikzmarknode{B1}{f}\\
      \end{tblr}
 
    \end{column}


    \begin{column}{.45\textwidth}
      \textbf{letters again}
      
     
      \begin{tblrtikzabove}
        \draw[red,styleall]
        (1-1.north west) rectangle (1-2.south east);
          
        \draw[green,styleall]
        (2-1.north west) rectangle (2-4.south east);
      \end{tblrtikzabove}
      
      \begin{tblr}{cccc}
        \tikzmarknode{A2}{u} & y &   &\\
        \tikzmarknode{B2}{g} & h & j & k\\
      \end{tblr}
      
    \end{column}
    \begin{tikzpicture}[overlay,remember picture]
      \draw[Circle-latex,thick,red] ([xshift=.5cm]A1.east) -|- ([xshift=-.5cm]A2.west);
      \draw[Circle-latex,thick,green] ([xshift=.5cm]B1.east) -|- ([xshift=-.5cm]B2.west);
    \end{tikzpicture}
  \end{columns}
    
\end{frame}
\end{document}

result

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.