tabularray로 긴 테이블을 생성하는 방법은 무엇입니까?

tabularray로 긴 테이블을 생성하는 방법은 무엇입니까?

아래와 같은 색다른 테이블을 생성하려고 합니다.

원하는 테이블

내 시도는 다음과 같습니다.

\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}

생성된 테이블이 충분히 길지 않거나 내부에 페이지 번호를 포함하는 방식으로 페이지 끝으로 이동됩니다. 이 문제를 해결하는 방법이 있나요?

답변1

  • 제공된 MWE를 사용하면 테이블이 한 페이지에 잘 맞을 수 있습니다.
  • MWE를 다음과 같이 변경하면 테이블이 긴 테이블로 변환될 수 있습니다.
    • table환경 제거
    • tblr사용하는 대신longtblr
    • longtblr테이블 앞에 자동으로 레이블을 삽입하므로 ( caption캡션이 첫 번째 테이블 행으로 이동하므로 레이블이 있어서는 안 됨) 테이블 앞에 레이블을 삽입해야 합니다.
\DefTblrTemplate{firsthead, middlehead,lasthead}{default}{} % <---
\DefTblrTemplate{contfoot-text}{normal}{\scriptsize\textit{Continued on the next page}}
 \SetTblrTemplate{contfoot-text}{normal}
  • 다음 테이블의 캡션 번호를 적절하게 지정하려면 테이블 끝 뒤에 가 와야 합니다 \addtocounter{table}{-1}.

긴 테이블로 변환된 완전한 MWE는 다음과 같습니다.

\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}

여기에 이미지 설명을 입력하세요

관련 정보