使用 longtable 包增加表格宽度并在列内居中字

使用 longtable 包增加表格宽度并在列内居中字

问题:

  • 将表格宽度增加到 100%
  • 居中表格标题字(即标准)
  • 在每一页上重复表格标题

问题:

  1. 如何将表格宽度增加到 100%?
  2. 我如何将单词居中criteria以便它恰好位于center字母之间A to L
  3. 是否可以将标题打印在每页的表格下方?

最小工作示例(MWE):

\documentclass[12pt]{article}

\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{ctable}
\usepackage{hyphenat}
\usepackage{xfrac}

\begin{document}

\setlength\extrarowheight{4pt}

\begin{longtable}{cccccccccccccc}
\caption{Table caption here}\label{chap1:tab1}

\endfirsthead
\multicolumn{14}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\multicolumn{14}{c}{}\\
\hline
\endhead
\hline \multicolumn{14}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot

\toprule
   \multicolumn{12}{c}{\textbf{Criteria}} \\
\midrule
   \textbf{Solutions} & A & B & C & D & E & F & G & H & I & J & K & L \\
\midrule
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
\end{longtable}

\begin{tabularx}{\linewidth}{*{3}X}
    \fontsize{8}{11}\selectfont 
    \textbf{A:} Caption 1\newline 
    \textbf{B:} Caption 2\newline 
    \textbf{C:} Caption 3\newline 
    \textbf{D:} Caption 4\newline 
    \textbf{E:} Caption 5 & 
    \fontsize{8}{11}\selectfont 
    \textbf{F:} Caption 6\newline 
    \textbf{G:} Caption 7\newline 
    \textbf{H:} Caption 8\newline 
    \textbf{I:} Caption 9 & 
    \fontsize{8}{11}\selectfont 
    \textbf{J:} Caption 10\newline 
    \textbf{K:} Caption 11\newline 
    \textbf{L:} Caption 12\\
\end{tabularx}

\end{document}

答案1

我已经解决了 1 和 2。对于 3,我感到困惑,认为这不是一个好主意。但是,您可以在旁边添加自定义文本continued on next page

\documentclass[12pt]{article}
\usepackage{tabularx,longtable,booktabs}
%\usepackage{ctable}       %% don't use this



\begin{document}

\setlength\extrarowheight{4pt}

\begin{longtable}{@{\extracolsep{\fill}}ccccccccccccc}
\caption{Table caption here}\label{chap1:tab1}
\endfirsthead
\multicolumn{13}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\endhead
\hline \multicolumn{13}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot

\toprule
 &  \multicolumn{12}{c}{\textbf{Criteria}} \\
\midrule
   \textbf{Solutions} & A & B & C & D & E & F & G & H & I & J & K & L \\
\midrule
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
%------------------------------------------------------------------------------------
Testing & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$ & $\bullet$
%------------------------------------------------------------------------------------
\\
\end{longtable}
\begin{tabularx}{\linewidth}{*{3}X}
    \fontsize{8}{11}\selectfont
    \textbf{A:} Caption 1\newline
    \textbf{B:} Caption 2\newline
    \textbf{C:} Caption 3\newline
    \textbf{D:} Caption 4\newline
    \textbf{E:} Caption 5 &
    \fontsize{8}{11}\selectfont
    \textbf{F:} Caption 6\newline
    \textbf{G:} Caption 7\newline
    \textbf{H:} Caption 8\newline
    \textbf{I:} Caption 9 &
    \fontsize{8}{11}\selectfont
    \textbf{J:} Caption 10\newline
    \textbf{K:} Caption 11\newline
    \textbf{L:} Caption 12\\
\end{tabularx}

\end{document}

在此处输入图片描述

相关内容