我在 Overleaf 中有一个长表,但是我需要添加另外 2 列,因此我希望我的长表能够填满整个页面。我就是找不到改变表格的方法。有什么想法吗?
表格代码
\begin{center}
\begin{longtable}{|p{0.13\textwidth}|p{0.22\textwidth}|p{0.42\textwidth}|p{0.42\textwidth}|p{0.42\textwidth}|p{0.42\textwidth}}
\caption{xxxxxxxxxx} \label{xxxxxx} \\
\hline \rowcolor{lightgray} \multicolumn{1}{|c|}{\textbf{xxxxx}} & \multicolumn{1}{c|}{\textbf{xxxxx}} & \multicolumn{1}{c|}{\textbf{xxxxxx}} & \multicolumn{1}{c|}{\textbf{(xxxxx}} & \multicolumn{1}{c|}{\textbf{xxxxxx}} \\ \hline
\endfirsthead
\multicolumn{3}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \rowcolor{lightgray} \multicolumn{1}{|c|}{\textbf{xxxx}} & \multicolumn{1}{c|}{\textbf{xxxx}} & \multicolumn{1}{c|}{\textbf{xxxxx}} & \multicolumn{1}{c|}{\textbf{(xxxx}} & \multicolumn{1}{c|}{\textbf{xxxx}} \\ \hline
\endhead
\hline \multicolumn{3}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\hline \hline
\endlastfoot
\multirow{6}{*}{\rotatebox[origin=c]{90}{\textbf{Direct}}} & Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \par
& x \\
& Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \par
& x \\
& Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \par
& x\\
& Method & x &
Advantages: \par
(1) Tx \par
(2) x \par
Disadvantages: \par
(1) x \par
(2) x \par \\
& Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) x \par
(2) xxx \par
& x \\
& Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \par
& x \\
\multirow{1}{*}{\rotatebox[origin=c]{90}{\textbf{Indirect}}} & Method & x &
Advantages: \par
(1) x \par
(2) xx \par
Disadvantages: \par
(1) x \par
(2) x \par
(3) x. \par
& x \\
% & x & x &
% Advantages: \par
% (1) xxx \par
% % (2) xxx \par
% Disadvantages: \par
% (1) xxx \par
% (2) xxx \par
% x \\ \hline
\multirow{2}{*}{\rotatebox[origin=c]{90}{\textbf{Independent}}} & Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \par
& x \\
& Method & x &
Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \par
& x \\ \hline
\end{longtable}
\end{center}
套餐
\documentclass[a4paper]{report}
\usepackage{multirow} %table
\usepackage{xcolor,colortbl}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{graphicx}
使用 Zarko 的代码后的示例
编辑:我认为没有必要在这里重复我在答案中给出的 MWE 编译结果。特别是,如果它不考虑答案的最终版本。
因此我擅自删除了这张图片(不准确且具有误导性),因为任何人都可以从我的回答中看到结果。
答案1
我建议使用和包xltabular
的组合,而不是:tabularx
longtable
longtable
\documentclass[arpaper]{report}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{ragged2e}
\usepackage{rotating}
\usepackage{makecell, multirow, xltabular}
\renewcommand\theadfont{\bfseries\small}
\newcolumntype{R}{>{\RaggedRight}X}
\usepackage{pdflscape}
\usepackage{lipsum}
\begin{document}
\begin{landscape}
\setlength\LTcapwidth\linewidth
\settowidth\rotheadsize{\textbf{Independent}}
\setlength\extrarowheight{2pt}
\begin{xltabular}{\linewidth}{| c | *{6}{R|}}
\caption[blabla]{\lipsum*[66]}
\label{tab:primer} \\
\hline
\rowcolor{lightgray}
\thead{Category}
& \thead{Tehnique}
& \thead{Description}
& \thead{Dis)advantages}
& \thead{Example}
& \thead{xxxxx}
& \thead{xxxxxx} \\
\hline
\endfirsthead
\caption[]{\lipsum*[66] (Cont.)} \\
\hline
\rowcolor{lightgray}
\thead{xxxxx}
& \thead{xxxxx}
& \thead{xxxxxx}
& \thead{xxxxx}
& \thead{xxxxxx}
& \thead{xxxxx}
& \thead{xxxxxx} \\
\hline
\endhead
\hline
\multicolumn{7}{r}{\small\emph{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
\multirow{3}{*}[3ex]{\rothead{Direct}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[3ex]{\rothead{Indirect}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[1ex]{\rothead{Independent}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[3ex]{\rothead{Indirect}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\multirow{6}{*}[2ex]{\rothead{Direct}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[3ex]{\rothead{Indirect}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\end{xltabular}
\end{landscape}
\end{document}
附录: 关于您的评论:在列宽方面,文本宽度受到限制。因此,您无法定义任何列宽。您可以采取的一些合理措施是:
- 例如使用较小的字体
\small
或\footnotesize
(我不建议使用较小的字体) - 改变列宽之间的比例
- 对于第一列标题中的文本,请使用缩写,例如
C.
\documentclass[arpaper]{report}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{ragged2e}
\usepackage{rotating}
\usepackage{makecell, multirow, xltabular}
\renewcommand\theadfont{\bfseries\small}
\newcolumntype{C}{>{\Centering}X}
\newcolumntype{R}{>{\RaggedRight}X}
\usepackage{pdflscape}
\usepackage{lipsum}
\begin{document}
\begin{landscape}
\setlength\LTcapwidth\linewidth
\settowidth\rotheadsize{\textbf{Independent}}
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{3pt}
\small
\begin{xltabular}{\linewidth}{| >{\hsize=0.2\hsize}C |
*{2}{>{\hsize=0.7\hsize}R|}
*{4}{>{\hsize=1.10\hsize}R|}}
\caption[blabla]{\lipsum*[66]}
\label{tab:primer} \\
\hline
\rowcolor{lightgray}
\thead{C.}
& \thead{Tehnique}
& \thead{Description}
& \thead{Dis)advantages}
& \thead{Example}
& \thead{xxxxx}
& \thead{xxxxxx} \\
\hline
\endfirsthead
\caption[]{\lipsum*[66] (Cont.)} \\
\hline
\rowcolor{lightgray}
\thead{xxxxx}
& \thead{xxxxx}
& \thead{xxxxxx}
& \thead{xxxxx}
& \thead{xxxxxx}
& \thead{xxxxx}
& \thead{xxxxxx} \\
\hline
\endhead
\hline
\multicolumn{7}{r}{\small\emph{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
\multirow{11}{*}{\rothead{Direct}}
& \lipsum[1][1-1]
& \lipsum[1][1-2]
& \lipsum[1][1-3]
& \lipsum[1][1-4]Method
& \lipsum[66]
& \lipsum[66] \\
\hline
\multirow{6}{*}[4ex]{\rothead{Indirect}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[1ex]{\rothead{Independent}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[3ex]{\rothead{Indirect}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\hline
\multirow{6}{*}[2ex]{\rothead{Direct}}
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\end{xltabular}
\end{landscape}
\end{document}
如果您能够使用(最新版本的)tabularray 包,那么表格代码就会简单得多,并且不需要手动调整 \multirow 单元格,因为您的表格中不需要这些单元格。例如:
\documentclass[arpaper]{report}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\usepackage{pdflscape}
\usepackage{lipsum}
\begin{document}
\begin{landscape}
\begin{longtblr}[
caption = {\lipsum*[66]},
entry = {blabla},
label = {tab:primer}
]{hlines, vlines,
colspec = {Q[c,m]
*{2}{X[0.70, l,h]}
*{4}{X[1.15, l,h]}
},
colsep = 3pt,
cell{2-Z}{1} = {cmd=\rotcell[cc]},
row{1} = {font=\footnotesize\bfseries, c, bg=lightgray},
rowhead = 1,
vspan=even}
%%%% COLUMNS HEADERS
Cat.
& Tehnique
& Description
& advantages
& Example
& xxxxx
& xxxxxx \\
%%%% BODY
Direct
& \lipsum[1][1-1]
& \lipsum[1][1-2]
& \lipsum[1][1-3]
& \lipsum[1][1-4]
& \lipsum[66]
& \lipsum[66] \\
Indirect
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
Independent
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
Indirect
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx
& Method
& x & Advantages: \par
(1) xxx \par
(2) xxx \par
Disadvantages: \par
(1) xxx \par
(2) xxx \\
\end{longtblr}
\end{landscape}
\end{document}