适合非常宽的桌子的景观长桌

适合非常宽的桌子的景观长桌

我很抱歉 - 我意识到这个问题已经被问过无数次了,但是我一直在努力,因为我对 LaTeX 不是很精通。

我有一个跨多页的宽表,我想将其放入该页面。我使用虚拟文本重新创建了该表(并缩短了许多行)。

从 excel 复制粘贴到 word 中告诉我,当所有内容换行时,它应该适合 A4 页面。desired output

但这是我在 overleaf 中得到的输出

output

我用的是表格生成器,这对于我在其他桌子上使用很有效。

我目前并不担心第二页上的文本会浮动 - 我以前遇到过这种情况,我只需强制分页即可解决这个问题(或者缺少 leftrightarrow 的反斜杠 - 这只是一个查找/替换工作)

我想我正在试图弄清楚如何让列的内容换行?

最后,代码:我用模板(现在回想起来我非常后悔)

\documentclass[
11pt, % The default document font size, options: 10pt, 11pt, 12pt
oneside, % Two side (alternating margins) for binding by default, uncomment to switch to one side
english, % ngerman for German
doublespacing, % Single line spacing, alternatives: onehalfspacing or doublespacing
%draft, % Uncomment to enable draft mode (no pictures, no links, overfull hboxes indicated)
nolistspacing, % If the document is onehalfspacing or doublespacing, uncomment this to set spacing in lists to single
liststotoc, % Uncomment to add the list of figures/tables/etc to the table of contents
%toctotoc, % Uncomment to add the main table of contents to the table of contents
parskip, % Uncomment to add space between paragraphs
%nohyperref, % Uncomment to not load the hyperref package
headsepline, % Uncomment to get a line under the header
%chapterinoneline, % Uncomment to place the chapter title next to the number on one line
consistentlayout, % Uncomment to change the layout of the declaration, abstract and acknowledgements pages to match the default layout
]{MastersDoctoralThesis} % The class file specifying the document structure

\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{pdflscape}
% i think these are all the relevant packages to my question - there are a lot in the preamble since it's a whole thesis using a template 

\begin{landscape}
\begin{longtable}[c]{|c|c|c|c|c|c|c|c|c|c|}
\caption{}
\label{tab:my-table}\\
\hline
\rowcolor[HTML]{D0CECE} 
\textbf{Reference} &
  \textbf{Column 1} &
  \textbf{Column 2 that is   descriptive} &
  \textbf{Column 3 that   also contains more information and is long} &
  \textbf{Column 4 is also   long and needs space} &
  \textbf{Column 5} &
  \textbf{Column 6} &
  \textbf{Column 7} &
  \textbf{Column 8 ABC} &
  \textbf{Column9 ABCDE} \\ \hline
\endhead
%
 &
   &
   &
   &
   &
   &
  Male &
  ↑   Result &
   &
  results   that are a little long too \\ \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  \multirow{-2}{*}{short description} &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100} &
  Female &
  leftrightarrow No Change &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too \\ \hline
 &
   &
   &
   &
   &
   &
  Male &
  leftrightarrow No Change &
   &
  results   that are a little long too \\ \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  \multirow{-2}{*}{long description bla bla bla bla} &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100} &
  Female &
  ↑   Result &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  leftrightarrow No Change \\ \hline
 &
   &
   &
   &
   &
   &
  Male &
  ↑   Result &
   &
   \\ \cline{7-8}
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  \multirow{-2}{*}{long description bla bla bla bla} &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100} &
  Female &
  ↑   Result &
  \multirow{-2}{*}{NOT TESTED} &
  \multirow{-2}{*}{NOT TESTED} \\ \hline
 &
   &
   &
  long   description bla bla bla bla &
   &
   &
  Male &
  ↑   Result &
   &
  results   that are a little longer and need to go here too ABCD 1234 \\ \cline{4-4} \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  long description bla bla bla bla &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100 but more detail required} &
  Female &
  leftrightarrow No Change &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
 &
   &
   &
  long   description bla bla bla bla &
   &
   &
  Male &
  leftrightarrow No Change &
   &
  results   that are a little longer and need to go here too ABCD 1234 \\ \cline{4-4} \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  long description bla bla bla bla &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100 but more detail required} &
  Female &
  ↑   Result &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
 &
   &
   &
  long   description bla bla bla bla &
   &
   &
  Male &
  leftrightarrow No Change &
   &
  results   that are a little longer and need to go here too ABCD 1234 \\ \cline{4-4} \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  long description bla bla bla bla &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100 but more detail required} &
  Female &
  ↑   Result &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
 &
   &
   &
  long   description bla bla bla bla &
   &
   &
  Male &
  leftrightarrow No Change &
   &
  results   that are a little longer and need to go here too ABCD 1234 \\ \cline{4-4} \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  long description bla bla bla bla &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100 but more detail required} &
  Female &
  ↑   Result &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
 &
   &
   &
  long   description bla bla bla bla &
   &
   &
  Male &
  leftrightarrow No Change &
   &
  results   that are a little longer and need to go here too ABCD 1234 \\ \cline{4-4} \cline{7-8} \cline{10-10} 
\multirow{-2}{*}{Smith et al., 2004} &
  \multirow{-2}{*}{Rat Rat Mouse} &
  \multirow{-2}{*}{Stress Type} &
  long description bla bla bla bla &
  \multirow{-2}{*}{ABC} &
  \multirow{-2}{*}{PND100 but more detail required} &
  Female &
  ↑   Result &
  \multirow{-2}{*}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
\end{longtable}
\end{landscape}

\结束{文档}

答案1

  • 您使用私有的 documentclass。相反,我使用packagebook来定义页面布局geometry
  • 您的表非常大,因此您需要执行以下操作:
    • 减小字体大小
    • 允许在具有规定列宽的定义列类型的单元格中换行
    • 当此单元格中的文本只有一行或宽度时替换\multirow{...}{*}{...}\multirow{-1}{=}{Rat Rat Mouse}\multirow{-1}[<number of lines in cell]{=}{Rat Rat Mouse}
    • \renewcommand\multirowsetup{\centering}使用表格前重新定义多行单元格的水平对齐方式

通过纠正表中的所有错误并通过反复试验和纠正错误来定义列宽,MWE 可以是:

\documentclass[11pt]{book} % The class file specifying the document structure
\usepackage[margin=20mm]{geometry}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{pdflscape}
% i think these are all the relevant packages to my question - there are a lot in the preamble since it's a whole thesis using a template
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}
\begin{landscape}
\footnotesize
\setlength\tabcolsep{3pt}
\setlength\extrarowheight{2pt}
\renewcommand\multirowsetup{\centering}
\begin{longtable}{|C{5.5em}|C{5.5em}|C{6em}
                  |C{9em}|  C{8em}|  C{5em}|
                  c|        C{5em}|  C{7em}|
                  C{10em}|}
\caption{}
\label{tab:my-table}\\
\hline
\rowcolor[HTML]{D0CECE}
\textbf{Reference} &
  \textbf{Column 1} &
  \textbf{Column 2 that is   descriptive} &
  \textbf{Column 3 that   also contains more information and is long} &
  \textbf{Column 4 is also   long and needs space} &
  \textbf{Column 5} &
  \textbf{Column 6} &
  \textbf{Column 7} &
  \textbf{Column 8 ABC} &
  \textbf{Column 9 ABCDE} \\ \hline
\endhead
%
    &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
     &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
    &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
    &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
    &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
    &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
    &   &   &   &   &   & Male
                            & Result
                                &   &   results that are a
                                        little long too     \\
    \cline{7-8} \cline{10-10}
\multirow{-1}[2]{=}{Smith et al., 2004} &
  \multirow{-1}[2]{=}{Rat Rat Mouse} &
  \multirow{-1}{=}{Stress Type} &
  \multirow{-1}{=}{short description} &
  \multirow{-1}{=}{ABC} &
  \multirow{-1}{=}{PND100} &
  Female &
  $\leftrightarrow$ No Change &
  \multirow{-1}[4]{=}{description that is a bit long to add detail} &
  results   that are a little longer and need to go here too ABCD 1234 \\ \hline
  \hline
Smith et al., 2004 &
  Rat   Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  NOT   TESTED &
  NOT   TESTED \\ \hline
Smith et al., 2004 &
  Rat Rat Mouse &
  Stress   Type &
  long   description bla bla bla bla &
  ABC &
  PND100 &
  Male &
  ↑   Result &
  description   that is a bit long to add detail &
  results   that are a little long too          \\
  \hline
\end{longtable}
\end{landscape}
\end{document}

enter image description here

相关内容