Reutilizar parte de tabular como tabular (más pequeño)

Reutilizar parte de tabular como tabular (más pequeño)

Basado en estoentorno-tabular-creado-en-tikz, Estaba buscando envolver un simple tabularcon TikZ (probablemente se podría usar tcolorbox, pero la documentación parece un Everest que escalar para mí).

mi problematica

El "largo" tabularestá separado en 4 bloques (para este ejemplo, más en la realidad). Cada bloque será analizado en una conferencia. Al final de las 4 conferencias, la larga tabulartendrá sentido en su conjunto.

ingrese la descripción de la imagen aquí

Mi pregunta

¿Qué debo hacer (tengo la sensación de que tomé las cosas con el pie izquierdo) para escribir esta tabla grande solo una vez, pero en realidad uso cada bloque (mal separado entre \hline en el ejemplo, pero imagino que hay una manera mucho mejor de hacer esto? ), con el mismo formato que el original ?

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

MWE a continuación

\documentclass{standalone}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{array}
\usepackage{environ}
\usepackage{tikz}

\usepackage{caption}

\newsavebox{\tablebox}
\definecolor{tablecolor}{named}{orange}

\NewEnviron{rndtable}[1]{%
  \addtolength{\extrarowheight}{1ex}%
  \rowcolors{2}{tablecolor!5}{tablecolor!20}%
  \sffamily
  \newcommand{\header}[1]{%
    \multicolumn{1}{l}{%
      \cellcolor{tablecolor}%
      \color{white}%
      \bfseries##1%
    }%
  }%
  \savebox{\tablebox}{%
    \begin{tabular}{#1}%
      \BODY
    \end{tabular}%
  }%
%
  \begin{tikzpicture}
    \begin{scope}
      \clip[rounded corners=1ex]
        (0,-\dp\tablebox) rectangle (\wd\tablebox,\ht\tablebox);
      \node at (0,-\dp\tablebox) [anchor=south west,inner sep=0pt]
            {\usebox{\tablebox}};
    \end{scope}
    \draw[tablecolor,very thick,rounded corners=1ex]
      (0,-\dp\tablebox) rectangle (\wd\tablebox,\ht\tablebox);
  \end{tikzpicture}%
}

\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}

\begin{rndtable}{r P{5cm}} %  
    \multicolumn{2}{l}{Block 2} \\ \hline
Block 1 Field 1 & Description that can be long, very long, even longer\\ 
Block 1 Field 2 & Description \\ 
Block 1 Field 3 & Description \\ 
Block 1 Field 4 & Description \\ 
    \hline
Block 2 Field 1 & Description that can be long, very long, even longer\\ 
Block 2 Field 2 & Description \\ 
Block 2 Field 3 & Description \\ 
Block 2 Field 4 & Description \\ 
    \hline
Block 3 Field 1 & Description that can be long, very long, even longer\\ 
Block 3 Field 2 & Description \\ 
Block 3 Field 3 & Description \\ 
Block 3 Field 4 & Description \\ 
    \hline
Block 4 Field 1 & Description that can be long, very long, even longer\\ 
Block 4 Field 2 & Description \\ 
Block 4 Field 3 & Description \\ 
Block 4 Field 4 & Description \\ 
    \hline
\end{rndtable}    

\end{document}

Respuesta1

Un enfoque, quizás poco elegante, sería definir comandos para mostrar los bloques. Con esto, podría hacer que un comando lleve toda la tabla (como en el MWE a continuación), o tener un comando en cada tabla pequeña y luego crear la grande recopilando esos comandos.

Ver tambiénesta pregunta.

\documentclass{article}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{array}
\usepackage{environ}
\usepackage{tikz}

\usepackage{caption}

\newsavebox{\tablebox}
\definecolor{tablecolor}{named}{orange}

\NewEnviron{rndtable}[1]{%
  \addtolength{\extrarowheight}{1ex}%
  \rowcolors{2}{tablecolor!5}{tablecolor!20}%
  \sffamily
  \newcommand{\header}[1]{%
    \multicolumn{1}{l}{%
      \cellcolor{tablecolor}%
      \color{white}%
      \bfseries##1%
    }%
  }%
  \savebox{\tablebox}{%
    \begin{tabular}{#1}%
      \BODY
    \end{tabular}%
  }%
%
  \begin{tikzpicture}
    \begin{scope}
      \clip[rounded corners=1ex]
        (0,-\dp\tablebox) rectangle (\wd\tablebox,\ht\tablebox);
      \node at (0,-\dp\tablebox) [anchor=south west,inner sep=0pt]
            {\usebox{\tablebox}};
    \end{scope}
    \draw[tablecolor,very thick,rounded corners=1ex]
      (0,-\dp\tablebox) rectangle (\wd\tablebox,\ht\tablebox);
  \end{tikzpicture}%
}

\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}

\newcommand{\block}[1]{
    \ifcase#1\or% https://tex.stackexchange.com/questions/17676/conditional-cases-expression
        \hline
        Block 1 Field 1 & Description that can be long, very long, even longer\\ 
        Block 1 Field 2 & Description \\ 
        Block 1 Field 3 & Description \\ 
        Block 1 Field 4 & Description \\ 
    \or
        \hline
        Block 2 Field 1 & Description that can be long, very long, even longer\\ 
        Block 2 Field 2 & Description \\ 
        Block 2 Field 3 & Description \\ 
        Block 2 Field 4 & Description \\ 
    \or
        \hline
        Block 3 Field 1 & Description that can be long, very long, even longer\\ 
        Block 3 Field 2 & Description \\ 
        Block 3 Field 3 & Description \\ 
        Block 3 Field 4 & Description \\
    \or
        \hline
        Block 4 Field 1 & Description that can be long, very long, even longer\\ 
        Block 4 Field 2 & Description \\ 
        Block 4 Field 3 & Description \\ 
        Block 4 Field 4 & Description \\ 
    \else
        block #1 not defined
    \fi
}

\begin{rndtable}{r P{5cm}} %  
    \multicolumn{2}{l}{All Blocks} \\ \hline
    \block{1}
    \block{2}
    \block{3}
    \block{4}
    \hline
\end{rndtable}

\vspace{\baselineskip}

\begin{rndtable}{r P{5cm}} %  
    \multicolumn{2}{l}{Block 2} \\ \hline
    \block{2}
    \hline
\end{rndtable}

\end{document}

captura de pantalla

Editar: Si desea darle un nombre a cada bloque, puede usar, por ejemploetoolboxel \ifstrequalcomando (§3.6.3 del manual).

\newcommand{\block}[1]{
    \ifstrequal{#1}{block1}{%
        Block 1 Field 1 & Description that can be long, very long, even longer\\
        Block 1 Field 2 & Description \\
        Block 1 Field 3 & Description \\
        Block 1 Field 4 & Description
    }{}\ifstrequal{#1}{block2}{%
        Block 2 Field 1 & Description that can be long, very long, even longer\\ 
        Block 2 Field 2 & Description \\
        Block 2 Field 3 & Description \\ 
        Block 2 Field 4 & Description
    }{}\ifstrequal{#1}{block3}{%
        Block 3 Field 1 & Description that can be long, very long, even longer\\ 
        Block 3 Field 2 & Description \\ 
        Block 3 Field 3 & Description \\ 
        Block 3 Field 4 & Description
    }{}\ifstrequal{#1}{block4}{%
        Block 4 Field 1 & Description that can be long, very long, even longer\\ 
        Block 4 Field 2 & Description \\ 
        Block 4 Field 3 & Description \\ 
        Block 4 Field 4 & Description
    }
}

\begin{rndtable}{r P{5cm}} %  
    \multicolumn{2}{l}{All Blocks} \\ \hline
    \block{block1} \\ \hline
    \block{block2} \\ \hline
    \block{block3} \\ \hline
    \block{block4} \\
\end{rndtable}

\begin{rndtable}{r P{5cm}} %  
    \multicolumn{2}{l}{Block 2} \\ \hline
    \block{block2} \\
    \hline
\end{rndtable}

información relacionada