Tabularx 表格-跨页拆分

Tabularx 表格-跨页拆分

我使用创建的表格tabularx太大,无法放在一页上。是否可以让它跨页显示,同时保持当前样式?

我试图移除table环境并保留tabularx此链接中的建议TEX 链接但仍然存在问题。

梅威瑟:

    \documentclass[a4paper,11pt]{article}
\usepackage{booktabs, makecell, tabularx}
\usepackage{caption}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\tabularxcolumn[1]{m{#1}}

\usepackage[table]{xcolor}

\usepackage{pdflscape,afterpage}

\begin{document}
    \begin{landscape}% Landscape page
\begin{table}[ht]
\caption{Cognitive walkthrough goals, tasks and actions}
\label{table:comparison of techniques}
    \small
    \setlength\extrarowheight{2pt}
\begin{tabularx}{\linewidth}{
       >{\columncolor{red!30}} l
                          *{4}{X}
                            }
    \Xhline{1pt}
    \rowcolor{red!30}
\multicolumn{1}{c}{}
    & \thead{Column 2} & \thead{Column 3}
    & \thead{Column 4} & \thead{Column 5}       \\
    \rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{Title 1}}  \\
Part 1
    &   To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.                      \\
    \Xhline{0.25pt}
Part 2
   &   To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.                      \\
    \rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{Title 2}}  \\
Part 3
    &   To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.                      \\
        \rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{Title 3}}  \\
Part 1
    &   To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.                      \\
    \Xhline{0.25pt}
Part 2
    &   To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.                      \\
    \Xhline{0.25pt}
Part 3
    &   To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.                      \\
    \Xhline{1pt}
\end{tabularx}%
    \end{table}
\end{landscape}
\end{document}

图片-电流输出 在此处输入图片描述

谢谢您的任何建议,并提前致谢!

答案1

以下是带有 的代码。请注意,语法(尤其是标题)与(等)ltablex相同:longtable\endhead\endfoot

\documentclass[a4paper,11pt]{article}
\usepackage{geometry}
\usepackage{booktabs, makecell, ltablex}
\usepackage{caption}
\renewcommand\theadfont{\small\bfseries \cellcolor{red!30}}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage[usestackEOL]{stackengine}

\usepackage[table]{xcolor}

\usepackage{pdflscape,afterpage}

\begin{document}

    \begin{landscape}% Landscape page
    \small
    \setlength\extrarowheight{2pt}
\begin{tabularx}{\linewidth}{
       >{\columncolor{red!30}} l
                          *{3}{X}X@{}
                            }\caption{Cognitive walkthrough goals, tasks and actions}
\label{table:comparison of techniques}\\
  \Xhline{1pt}
\multicolumn{1}{c}{\cellcolor{red!30}}
    &\thead{Column 2} &\thead{Column 3}
    & \thead{Column 4} &\multicolumn{1}{>{\columncolor{red!30}[6pt][0pt]\bfseries}c@{}}{\Centerstack{Column 5\\Lalala}} \\
    \Xhline{0.25pt}
 \endfirsthead
  \Xhline{1pt}
% \rowcolor{red!30}
\multicolumn{1}{c}{\cellcolor{red!30}}
    &\thead{Column 2} &\thead{Column 3}
    & \thead{Column 4} &\multicolumn{1}{>{\columncolor{red!30}[6pt][0pt]\bfseries}c@{}}{\Centerstack{Column 5\\Lalala}} \\
    \Xhline{0.25pt}
 \endhead
 \Xhline{0.25pt}
 \endfoot
 \Xhline{1pt}
 \endlastfoot
    \rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Title 1}} \\
Part 1
    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. \\
    \Xhline{0.25pt}
Part 2
   & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. \\
    \rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Title 2}} \\*
Part 3
    & To make your document look professionally pro\bfseries duced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. \\
        \rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Title 3}} \\
Part 1
    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. \\
    \Xhline{0.25pt}
Part 2
    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. \\
    \Xhline{0.25pt}
Part 3
    & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
        & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
            & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
                & To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
\end{tabularx}%
% \end{table}
\end{landscape}

\end{document} 

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

相关内容