表格包含太多列和太多文本

表格包含太多列和太多文本

我有以下表格,想将其显示在整页上。表格有很多列,其中一些列很长——所以我的想法是旋转它,因此我使用了adjustbox。但这并没有多大帮助。所以我寻找一些进一步的改进方法,并找到了tabularx。但是,它看起来还不够好。表格溢出了页面的边缘。

\documentclass[a4paper,12pt,parskip=half]{report}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{array,hhline}
\setlength\extrarowheight{2.5pt}

\begin{document}

\begin{adjustbox}{angle=90}
\begin{tabularx}{\textwidth}{lrXllrlrrlXrl}
\toprule
{} &  ProjectID & ProjectName &                                                                                                              ProjectURL &         BranchName &  CommitterID &        CommitterName &  CommitterNumOfCommits &  CommitID &                                 CommitKey &                                                                                                                                                              CommitMessage &  CommitNumOfFiles &  CommitDate \\
\midrule
0 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            1 &  Evgeny Gerashchenko &                     76 &         1 &  04a6b10f7a7fcb6daee5963ff4cdec3010b20f8c &                                                                                                     Minor. Renamed annotationDeserializer -> deserializers.\textbackslash n &                 5 &  2014-03-31 \\
1 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            1 &  Evgeny Gerashchenko &                     76 &         2 &  dadc8351b61be2c0f8f85f45f85799fa6d340c8e &                                                                                    Added tests for compiling Java against TraitImpl and extension members.\textbackslash n &                 7 &  2014-03-31 \\
2 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            1 &  Evgeny Gerashchenko &                     76 &         3 &  93dfc00880377c4a76e15e15c6a1fd89da86eeb3 &                                                                                                           Minor. Renamed enum constants for clarification.\textbackslash n &                 4 &  2014-03-31 \\
3 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            2 &   Natalia Ukhorskaya &                     55 &         4 &  4a79bfa16dc4224260e1acec5b498fe2f13a93d7 &                                                     Generate static accessors fro protected functions in different packages\textbackslash n \#KT-4617 Fixed\textbackslash n &                 7 &  2014-03-31 \\
4 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            3 &     Mikhael Bogdanov &                     89 &         5 &  5b5ecca12ae85060e1900e67a3dd2590d7305eb4 &                                                                                            Inline test: check that no any inline method is called directly\textbackslash n &                 8 &  2014-03-31 \\
5 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            3 &     Mikhael Bogdanov &                     89 &         6 &  0d239a3e0e047efff470235ddf5cd28f0024a39f &                                                                                                         Moving local fun callee generation to CallReceiver\textbackslash n &                 6 &  2014-03-31 \\
6 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            3 &     Mikhael Bogdanov &                     89 &         7 &  7dc662f6132fef321a5881a9d8d8477f75581e20 &                                                                                                   Optimization for const closures: access it via GETSTATIC\textbackslash n &                 5 &  2014-03-31 \\
7 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            3 &     Mikhael Bogdanov &                     89 &         8 &  c7c1e3365524dc63dd5e5e720e5f817dc4705c0f &  Move local fun callee generation to pushArgumentsWithCallReceiver.\textbackslash n\textbackslash nLocal fun callee generation via resolvedCall.resultingDescriptor not... &                 3 &  2014-03-31 \\
8 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            3 &     Mikhael Bogdanov &                     89 &         9 &  94e4c2f0c1fcba83dfa9088e2b39aeb64e3ad9de &                                                                                Move call receiver wrapping and generation to pushArgumentsWithCallReceiver\textbackslash n &                 2 &  2014-03-31 \\
9 &          1 &      kotlin &  C:\textbackslash Users\textbackslash NAME32\textbackslash Downloads\textbackslash SomeDirectory\textbackslash kotlin &  refs/heads/master &            3 &     Mikhael Bogdanov &                     89 &        10 &  e1e28558876ba6e9426cfc72840e4898114fc1f1 &                                                                                                                             Removed obsolete pop operation\textbackslash n &                 1 &  2014-03-31 \\
\bottomrule
\end{tabularx}
\end{adjustbox}

\end{document}

有什么建议可以克服这些限制吗?

答案1

我将把它实现为一系列表格:

\documentclass[a4paper]{report}
\usepackage{geometry}
\usepackage{xparse,url,booktabs,tabularx,array}

\ExplSyntaxOn
\NewDocumentCommand{\entry}{m}
 {
  \prop_clear:N \l_scientiaetveritas_entry_prop
  \keys_set:nn { scientiaetveritas/entries } { #1 }
  \seq_clear:N \l_scientiaetveritas_entry_seq
  \scientiaetveritas_make_entry:nnn { SerialNumber } { } { }
  \scientiaetveritas_make_entry:nnn { ProjectID } { } { }
  \scientiaetveritas_make_entry:nnn { ProjectName } { } { }
  \scientiaetveritas_make_entry:nnn { ProjectURL } { \url } { }
  \scientiaetveritas_make_entry:nnn { BranchName } { \texttt } { }
  \scientiaetveritas_make_entry:nnn { CommitterID } { } { }
  \scientiaetveritas_make_entry:nnn { CommitterName } { } { }
  \scientiaetveritas_make_entry:nnn { CommitterNumOfCommits } { } { }
  \scientiaetveritas_make_entry:nnn { CommitID } { } { }
  \scientiaetveritas_make_entry:nnn { CommitKey } { \texttt } { }
  \scientiaetveritas_make_entry:nnn { CommitMessage } { \texttt } { \tl_to_str:n { \n } }
  \scientiaetveritas_make_entry:nnn { CommitNumOfFiles } { } { }
  \scientiaetveritas_make_entry:nnn { CommitDate } { } { }

  \par\addvspace{\bigskipamount}
  \noindent
  \begin{tabularx}{\textwidth}{@{}l>{\raggedright}X@{}}
  \seq_use:Nn \l_scientiaetveritas_entry_seq { \tabularnewline }
  \end{tabularx}
 }
\keys_define:nn { scientiaetveritas/entries }
 {
  unknown .code:n = \prop_put:NVn \l_scientiaetveritas_entry_prop \l_keys_key_tl { #1 },
 }
\prop_new:N \l_scientiaetveritas_entry_prop
\seq_new:N \l_scientiaetveritas_entry_seq
\cs_new_protected:Nn \scientiaetveritas_make_entry:nnn
 {
  \seq_put_right:Nx \l_scientiaetveritas_entry_seq
   { #1 & \exp_not:N #2 { \prop_item:Nn \l_scientiaetveritas_entry_prop { #1 } #3 } }
 }
\ExplSyntaxOff


\begin{document}

\entry{
  SerialNumber         = 0,
  ProjectID             = 1,
  ProjectName           = kotlin,
  ProjectURL            = C:\Users\NAME32\Downloads\SomeDirectory\kotlin,
  BranchName            = refs/heads/master,
  CommitterID           = 1,
  CommitterName         = Evgeny Gerashchenko,
  CommitterNumOfCommits = 76,
  CommitID              = 1,
  CommitKey             = 04a6b10f7a7fcb6daee5963ff4cdec3010b20f8c,
  CommitMessage         = Minor. Renamed annotationDeserializer -> deserializers.,
  CommitNumOfFiles      = 5,
  CommitDate            = 2014-03-31,
}

\entry{
  Serial Number         = 1,
  ProjectID             = 1,
  ProjectName           = kotlin,
  ProjectURL            = C:\Users\NAME32\Downloads\SomeDirectory\kotlin,
  BranchName            = refs/heads/master,
  CommitterID           = 1,
  CommitterName         = Evgeny Gerashchenko,
  CommitterNumOfCommits = 76,
  CommitID              = 2,
  CommitKey             = dadc8351b61be2c0f8f85f45f85799fa6d340c8e,
  CommitMessage         = Added tests for compiling Java against TraitImpl and extension members.,
  CommitNumOfFiles      = 5,
  CommitDate            = 2014-03-31,
}

\end{document}

您可以准备一个\entry模板并用数据填充它。键的顺序并不重要;空项将被接受(但如果需要,也可以省略它们)。

与静态表相比,您有几个优势:正如您从代码中看到的那样,可以根据需要格式化每个项目。

在此处输入图片描述

答案2

您的表格太大了,怀疑能否将其放在 A3 纸张大小上……我强烈建议您重新考虑其重新设计。请参阅:

  • 如果可以的话,删除与表格标题或图例中相同的数据列,例如CommitDate & 2014-03-31等等
  • 转置表,即交换列和行,如下面的 MWE 所示
  • 使用ltablex允许表格跨越更多页面的包

在此处输入图片描述

\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage[demo]{graphicx}
\usepackage[skip=1ex]{caption}
\usepackage{rotating}
\usepackage{booktabs, ltablex}

\begin{document}
\begin{tabularx}{\linewidth}{ @{} l X @{} }
\toprule
ID                      &   0                   \\
Project Name            &   1                   \\
Project URL             &   kotlin              \\
Branch Name             &   C:\textbackslash Users\textbackslash NAME32\textbackslash
                            Downloads\textbackslash SomeDirectory\textbackslash
                            kotlin              \\
Committer ID            &   Evgeny Gerashchenko \\
Committer Name          &   76                  \\
CommitterNumOfCommits   &   1                   \\
CommitID                &   04a6b10f7a7fcb6daee5963ff4cdec3010b20f8c   
                                                \\ 
CommitKey               &   Minor. Renamed annotationDeserializer 
                            -> deserializers.\textbackslash n
                                                \\
CommitMessage           &   1                   \\
CommitNumOfFiles        &   5                   \\
CommitDate              &  2014-03-31           \\
\midrule
ID                      &   1                   \\
Project Name            &   1                   \\
Project URL             &   kotlin              \\
Branch Name             &   C:\textbackslash Users\textbackslash NAME32\textbackslash
                            Downloads\textbackslash SomeDirectory\textbackslash
                            kotlin              \\
Committer ID            &   Evgeny Gerashchenko \\
Committer Name          &   76                  \\
CommitterNumOfCommits   &   2                   \\
CommitID                &   dadc8351b61be2c0f8f85f45f85799fa6d340c8e
                                                \\
CommitKey               &   Added tests for compiling Java against TraitImpl 
                            and extension members.\textbackslash n
                                                \\
CommitMessage           &   1                   \\
CommitNumOfFiles        &   7                   \\
CommitDate              &  2014-03-31           \\
\midrule
ID                      &   2                   \\
Project Name            &   1                   \\
Project URL             &   kotlin              \\
Branch Name             &   C:\textbackslash Users\textbackslash NAME32\textbackslash
                            Downloads\textbackslash SomeDirectory\textbackslash
                            kotlin              \\
Committer ID            &   Evgeny Gerashchenko \\
Committer Name          &   76                  \\
CommitterNumOfCommits   &   3                   \\
CommitID                &   93dfc00880377c4a76e15e15c6a1fd89da86eeb3
                                                \\
CommitKey               &   Minor. Renamed enum constants 
                            for clarification.\textbackslash n
                                                \\
CommitMessage           &   1                   \\
CommitNumOfFiles        &   4                   \\
CommitDate              &  2014-03-31           \\
\midrule
ID                      &   3                   \\
Project Name            &   1                   \\
Project URL             &   kotlin              \\
Branch Name             &   C:\textbackslash Users\textbackslash NAME32\textbackslash
                            Downloads\textbackslash SomeDirectory\textbackslash
                            kotlin              \\
Committer ID            &   Natalia Ukhorskaya  \\
Committer Name          &   55                  \\
CommitterNumOfCommits   &   3                   \\
CommitID                &   4a79bfa16dc4224260e1acec5b498fe2f13a93d7
                                                \\
CommitKey               &   Minor. Renamed enum constants
                            for clarification.\textbackslash n
                                                \\
CommitMessage           &   1                   \\
CommitNumOfFiles        &   7                   \\
CommitDate              &  2014-03-31           \\
\midrule
ID                      &   4                   \\
Project Name            &   1                   \\
Project URL             &   kotlin              \\
Branch Name             &   C:\textbackslash Users\textbackslash NAME32\textbackslash
                            Downloads\textbackslash SomeDirectory\textbackslash
                            kotlin              \\
Committer ID            &   Evgeny Gerashchenko \\
Committer Name          &   76                  \\
CommitterNumOfCommits   &   3                   \\
CommitID                &   93dfc00880377c4a76e15e15c6a1fd89da86eeb3
                                                \\
CommitKey               &   Minor. Renamed enum constants
                            for clarification.\textbackslash n
                                                \\
CommitMessage           &   1                   \\
CommitNumOfFiles        &   4                   \\
CommitDate              &  2014-03-31           \\
\midrule
ID                      &   5                   \\
Project Name            &   1                   \\
Project URL             &   kotlin              \\
Branch Name             &   C:\textbackslash Users\textbackslash NAME32\textbackslash
                            Downloads\textbackslash SomeDirectory\textbackslash
                            kotlin              \\
Committer ID            &   Natalia Ukhorskaya  \\
Committer Name          &   55                  \\
CommitterNumOfCommits   &   3                   \\
CommitID                &   4a79bfa16dc4224260e1acec5b498fe2f13a93d7
                                                \\
CommitKey               &   Minor. Renamed enum constants
                            for clarification.\textbackslash n
                                                \\
CommitMessage           &   1                   \\
CommitNumOfFiles        &   7                   \\
CommitDate              &  2014-03-31           \\
\bottomrule
\end{tabularx}
\end{document}

笔记:

  • 表格不完整
  • 在我的表中转置出现(许多)错误的可能性很高
  • 我的目的只是展示一种可能的解决方案

相关内容