¿Cómo generar tablas largas con tabularray?

¿Cómo generar tablas largas con tabularray?

Estoy intentando generar una tabla no convencional como la siguiente

mesa deseada

Aquí está mi intento:

\documentclass[12pt,reqno]{report}
\usepackage{siunitx}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{35pt}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{pdfcomment}
\usepackage{textcomp}
\usepackage{tabularx}
\usepackage{xcolor}
\definecolor{lavender}{rgb}{0.9, 0.9, 0.98}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{caption}

\begin{document}

\begin{table}
    \refstepcounter{table}
    \centering
    \begin{tblr}{
            colspec={|l l l},
            rows={rowsep=5pt},
            row{odd} = {bg=lavender},
            row{1,2} = {bg=white},
            row{2} = {rowsep=0pt},
            row{3} = {font=\bfseries},
            columns={colsep=6pt},
            column{1} = {bg=white, colsep=3pt},
            vline{1} = {abovepos = 1, belowpos = 1},
        }
        & \SetCell[c=2]{c} \textbf{Table \thetable}. Parameters for protein solvation calculations using APBSmem & \\
        \cline[1.5pt]{2,3} & & \\[-6pt]
        \cline[1.5pt]{2,3} & Parameter & Value \\
        \cline[1.5pt,gray]{2,3} & Calculation type & Protein solvation \\
        & Grid Dimensions & $\qtyproduct{289 x 289 x 257}{\angstrom}$ \\
        & Coarse Grid Lengths & $\qtyproduct{202.889 x 202.915 x 185.759}{\angstrom}$ \\
        & Fine Grid Lengths & $\qtyproduct{139.347 x 139.362 x 129.27}{\angstrom}$ \\
        & Counter-Ions & 1.0, 0.154, 1.65 \\
        & & -1.0, 0.154, 1.67 \\
        & Protein Dielectric & 2.0 \\
        & Solvent Dielectric & 80.0 \\
        & Membrane Dielectric & 8.0 \\
        & Headgroup Dielectric & 80.0 \\
        & Boundary Conditions & Focus \\
        & Solvent probe radius (srad) & 1.4 \\
        & Surface sphere density (sdens) & 10 \\
        & Temperature & 298.15 \\
        & Z-position of membrane bottom & -23.9 \\
        & Membrane thickness & 47.8 \\
        & Headgroup thickness & -- \\
        & Upper exclusion radius & 0 \\
        & Lower exclusion radius & 0 \\
        \cline[1.5pt]{2,3}
    \end{tblr}
    \label{table:1}
\end{table}

\end{document}

la tabla generada no es lo suficientemente larga o se desplaza hacia el final de la página, de manera que incluye el número de página dentro de ella. ¿Algún truco para abordar esto?

Respuesta1

  • Con el MWE proporcionado, su tabla puede caber perfectamente en una página.
  • Su tabla se puede transformar en una tabla larga mediante los siguientes cambios en su MWE:
    • eliminar tableel entorno
    • en lugar de tblrusarlongtblr
    • Dado que longtblrse inserta automáticamente captionla etiqueta antes de la tabla (donde no debería estar, ya que el título se mueve a la primera fila de la tabla), se debe insertar delante de la tabla:
\DefTblrTemplate{firsthead, middlehead,lasthead}{default}{} % <---
\DefTblrTemplate{contfoot-text}{normal}{\scriptsize\textit{Continued on the next page}}
 \SetTblrTemplate{contfoot-text}{normal}
  • Para una numeración adecuada de los títulos de las siguientes tablas, el final de la tabla debe ir seguido de \addtocounter{table}{-1}.

El MWE completo transformado en una tabla larga es:

\documentclass[12pt,reqno]{report}

\usepackage{pdfcomment}
\usepackage{textcomp}
\usepackage{xcolor}
\definecolor{lavender}{rgb}{0.9, 0.9, 0.98}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\usepackage{caption}

\usepackage{lipsum}

\begin{document}
\lipsum[1]

{
    \centering
    \refstepcounter{table}
\DefTblrTemplate{firsthead, middlehead,lasthead}{default}{} % <---
\DefTblrTemplate{contfoot-text}{normal}{\scriptsize\textit{Continued on the next page}}
\SetTblrTemplate{contfoot-text}{normal}
    \begin{longtblr}[
 label={table:1}   
                    ]{
            colspec={|l l l},
            colsep=6pt,
            rows=5pt,
            row{odd} = {bg=lavender},
            row{1,2} = {bg=white},
            row{2} = {rowsep=0pt},
            row{3} = {font=\bfseries},
            column{1} = {bg=white, colsep=3pt},
            vline{1} = {abovepos = 1, belowpos = 1},
            rowhead=3
        }
    & \SetCell[c=2]{c} \textbf{Table \thetable}. Parameters for protein solvation calculations using APBSmem & \\
    \cline[1.5pt]{2,3} & & \\[-6pt]
    \cline[1.5pt]{2,3} & Parameter & Value \\
    \cline[1.5pt,gray]{2,3} & Calculation type & Protein solvation \\
    & Grid Dimensions & $\qtyproduct{289 x 289 x 257}{\angstrom}$ \\
    & Coarse Grid Lengths & $\qtyproduct{202.889 x 202.915 x 185.759}{\angstrom}$ \\
    & Fine Grid Lengths & $\qtyproduct{139.347 x 139.362 x 129.27}{\angstrom}$ \\
    & Counter-Ions & 1.0, 0.154, 1.65 \\
    & & $-1.0$, 0.154, 1.67 \\
    & Protein Dielectric & 2.0 \\
    & Solvent Dielectric & 80.0 \\
    & Membrane Dielectric & 8.0 \\
    & Headgroup Dielectric & 80.0 \\
    & Boundary Conditions & Focus \\
    & Solvent probe radius (srad) & 1.4 \\
    & Surface sphere density (sdens) & 10 \\
    & Temperature & 298.15 \\
    & Z-position of membrane bottom & $-23.9$ \\
    & Membrane thickness & 47.8 \\
    & Headgroup thickness & -- \\
    & Upper exclusion radius & 0 \\
    & Lower exclusion radius & 0 \\
    \cline[1.5pt]{2,3}
\end{longtblr}
\addtocounter{table}{-1}
}

\begin{table}[ht]
\caption{For test of tables numbering}
\begin{tabular*}{\linewidth}{@{} p{\linewidth} @{}}
\hline
\lipsum[66] \\
\hline
\end{tabular*}
\end{table}

\end{document}

ingrese la descripción de la imagen aquí

información relacionada