我正在尝试将表格放入其中Latex
。我的表格太宽了,所以我尝试将页面改为横向。但是,这不起作用。我使用了这些包:
\usepackage{amsmath}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{adjustbox}
表格如下:
%\begin{landscape}
%\begin{sidewaystable}
\begin{table}[ht]
\caption{My caption}
\label{my-label}
\centering
\begin{adjustbox}{width=1\textwidth}
\small
\begin{tabular}{l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\cline{2-16}
\multicolumn{1}{c|}{} & \multicolumn{3}{c|}{{\bf prediction at baseline}} & \multicolumn{3}{c|}{{\bf prediction at 3 months}} & \multicolumn{3}{c|}{{\bf prediction at 6 months}} & \multicolumn{3}{c|}{{\bf prediction at 9 months}} & \multicolumn{3}{c|}{{\bf prediction for 44 patients}} \\ \cline{2-16}
\multicolumn{1}{c|}{} & \multicolumn{3}{c|}{{\bf N = 44, n\_0 =26 n\_1 =18}} & \multicolumn{3}{c|}{{\bf N = 22, n\_0 = 13 n\_1 =9}} & \multicolumn{3}{c|}{{\bf N = 40, n\_0 =24 n\_1 =16}} & \multicolumn{3}{c|}{{\bf N = 24, n\_0 =15 n\_1 =9}} & \multicolumn{3}{c|}{{\bf N = 44, n\_0 =26 n\_1 =18}} \\ \hline
\multicolumn{1}{|l|}{Models} & {\bf Sen.\%} & {\bf Spe.\%} & {\bf ER.\%} & {\bf Sen.\%} & {\bf Spe.\%} & {\bf ER.\%} & {\bf Sen.\%} & {\bf Spe.\%} & {\bf ER.\%} & {\bf Sen.\%} & {\bf Spe.\%} & {\bf ER.\%} & {\bf Sen.\%} & {\bf Spe.\%} & {\bf ER.\%} \\ \hline
\multicolumn{1}{|l|}{{\bf Linear DA}} & 6 & 88 & 45 & 22 & 85 & 41 & 25 & 88 & 38 & 22 & 80 & 42 & 22 & 81 & 43 \\ \hline
\multicolumn{1}{|l|}{{\bf Quadratic DA}} & 17 & 88 & 41 & 56 & 77 & 32 & 88 & 67 & 25 & 89 & 80 & 17 & 78 & 73 & 25 \\ \hline
\multicolumn{1}{|l|}{{\bf Marginal Pred.}} & 22 & 88 & 39 & 22 & 92 & 36 & 75 & 92 & 15 & 78 & 93 & 13 & 67 & 92 & 18 \\ \hline
\multicolumn{1}{|l|}{{\bf Condition Pred.}} & zero & 100 & 41 & 11 & 92 & 41 & 56 & 96 & 20 & 67 & 100 & 13 & 61 & 100 & 16 \\ \hline
\multicolumn{1}{|l|}{{\bf Random effects Pred.}} & 17 & 100 & 34 & 22 & 92 & 36 & 38 & 92 & 30 & 44 & 93 & 25 & 44 & 92 & 27 \\ \hline
\end{tabular}}
\end{{adjustbox}}
\end{table}
%\end{sidewaystable}
%\end{landscape}
或者至少该表格可以很好地适合一页。你能帮帮我吗?
答案1
\documentclass[a4paper]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{rotating}
\begin{document}
\begin{sidewaystable}
\caption{My caption}
\label{my-label}
\centering
\begin{tabular}{|l*{15}{|c}|}
\hline
\multicolumn{1}{|l|}{\textbf{Prediction}} & \multicolumn{3}{c|}{\textbf{At baseline}} & \multicolumn{3}{c|}{\textbf{At 3 months}} & \multicolumn{3}{c|}{\textbf{At 6 months}} & \multicolumn{3}{c|}{\textbf{At 9 months}} & \multicolumn{3}{c|}{\textbf{For 44 patients}} \\ \hline
\multicolumn{1}{|l|}{\textbf{(N,n\_0,n\_1)}} & \multicolumn{3}{c|}{\textbf{(44,26,18)}} & \multicolumn{3}{c|}{\textbf{(22,13,9)}} & \multicolumn{3}{c|}{\textbf{(40,24,16)}} & \multicolumn{3}{c|}{\textbf{(24,15,9)}} & \multicolumn{3}{c|}{\textbf{(44,26,18)}} \\ \hline
\multicolumn{1}{|l|}{\textbf{Models (\%)}} & \textbf{Sen.} & \textbf{Spe.} & \textbf{ER.} & \textbf{ Sen.} & \textbf{Spe.} & \textbf{ER.} & \textbf{Sen.} & \textbf{Spe.} & \textbf{ER.} & \textbf{Sen.} & \textbf{Spe.} & \textbf{ER.} & \textbf{Sen.} & \textbf{Spe.} & \textbf{ER.} \\ \hline
\multicolumn{1}{|l|}{\textbf{Linear DA}} & 6 & 88 & 45 & 22 & 85 & 41 & 25 & 88 & 38 & 22 & 80 & 42 & 22 & 81 & 43 \\ \hline
\multicolumn{1}{|l|}{\textbf{Quadratic DA}} & 17 & 88 & 41 & 56 & 77 & 32 & 88 & 67 & 25 & 89 & 80 & 17 & 78 & 73 & 25 \\ \hline
\multicolumn{1}{|l|}{\textbf{Marginal Pred.}} & 22 & 88 & 39 & 22 & 92 & 36 & 75 & 92 & 15 & 78 & 93 & 13 & 67 & 92 & 18 \\ \hline
\multicolumn{1}{|l|}{\textbf{Condition Pred.}} & zero & 100 & 41 & 11 & 92 & 41 & 56 & 96 & 20 & 67 & 100 & 13 & 61 & 100 & 16 \\ \hline
\multicolumn{1}{|l|}{\textbf{Random effects Pred.}} & 17 & 100 & 34 & 22 & 92 & 36 & 38 & 92 & 30 & 44 & 93 & 25 & 44 & 92 & 27 \\ \hline
\end{tabular}
\end{sidewaystable}
\end{document}
我的主要想法是删除不必要的重复单词和条目。具体来说,、、%
都是重复的。仅此Prediction
一点(N,n_0,n_1)
就可以使表格很好地适合一页。可以按照@Zarko 的建议进一步减少。
为了美观,你也可以考虑使用booktabs
。
答案2
您的表格太大,如果不使用小技巧就无法放在页面上:首先,您需要使用几何包声明测试宽度和高度(正如我在下面的 MWE 中所做的那样),其次,使用较小的字体,第三,如果允许的话sffamily
(它们通常比罗马字体窄一点),第四,缩小tabcolsep
。当然,把它放在sidewaytable
环境中。
\documentclass{article}
\usepackage[left=30mm,right=20mm,
top=20mm,bottom=20mm,
a4paper]{geometry}
\usepackage{amsmath}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{graphicx}
%\usepackage{lscape}
%\usepackage{adjustbox}
\begin{document}
\begin{sidewaystable}
\small\sffamily
\setlength{\tabcolsep}{5pt}
\caption{My caption}
\label{my-label}
\centering
\begin{tabular}{|l*{15}{|c}|}
\cline{2-16}
\multicolumn{1}{c|}{} & \multicolumn{3}{c|}{\textbf{prediction at baseline}} & \multicolumn{3}{c|}{\textbf{prediction at 3 months}} & \multicolumn{3}{c|}{\textbf{ prediction at 6 months}} & \multicolumn{3}{c|}{\textbf{prediction at 9 months}} & \multicolumn{3}{c|}{\textbf{prediction for 44 patients}} \\ \cline{2-16}
\multicolumn{1}{c|}{} & \multicolumn{3}{c|}{\textbf{N = 44, n\_0 =26 n\_1 =18}} & \multicolumn{3}{c|}{\textbf{N = 22, n\_0 = 13 n\_1 =9}} & \multicolumn{3}{c|}{\textbf{N = 40, n\_0 =24 n\_1 =16}} & \multicolumn{3}{c|}{\textbf{N = 24, n\_0 =15 n\_1 =9}} & \multicolumn{3}{c|}{\textbf{N = 44, n\_0 =26 n\_1 =18}} \\ \hline
\multicolumn{1}{|l|}{Models} & \textbf{Sen.\%} & \textbf{Spe.\%} & \textbf{ER.\%} & \textbf{ Sen.\%} & \textbf{Spe.\%} & \textbf{ER.\%} & \textbf{Sen.\%} & \textbf{Spe.\%} & \textbf{ER.\%} & \textbf{Sen.\%} & \textbf{Spe.\%} & \textbf{ER.\%} & \textbf{Sen.\%} & \textbf{Spe.\%} & \textbf{ER.\%} \\ \hline
\multicolumn{1}{|l|}{\textbf{Linear DA}} & 6 & 88 & 45 & 22 & 85 & 41 & 25 & 88 & 38 & 22 & 80 & 42 & 22 & 81 & 43 \\ \hline
\multicolumn{1}{|l|}{\textbf{Quadratic DA}} & 17 & 88 & 41 & 56 & 77 & 32 & 88 & 67 & 25 & 89 & 80 & 17 & 78 & 73 & 25 \\ \hline
\multicolumn{1}{|l|}{\textbf{Marginal Pred.}} & 22 & 88 & 39 & 22 & 92 & 36 & 75 & 92 & 15 & 78 & 93 & 13 & 67 & 92 & 18 \\ \hline
\multicolumn{1}{|l|}{\textbf{Condition Pred.}} & zero & 100 & 41 & 11 & 92 & 41 & 56 & 96 & 20 & 67 & 100 & 13 & 61 & 100 & 16 \\ \hline
\multicolumn{1}{|l|}{\textbf{Random effects Pred.}} & 17 & 100 & 34 & 22 & 92 & 36 & 38 & 92 & 30 & 44 & 93 & 25 & 44 & 92 & 27 \\ \hline
\end{tabular}
\end{sidewaystable}
\end{document}
如果这没有帮助,你在第二行有一点保留,尝试借助包makcell
和它的宏将其写在两行中\thead
(参见它的文档)
\documentclass{article}
\usepackage[left=30mm,right=20mm,
top=20mm,bottom=20mm,
a4paper]{geometry}
\usepackage{amsmath}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{rotating}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries\sffamily}
%\usepackage{lscape}
%\usepackage{adjustbox}
\begin{document}
\begin{sidewaystable}
\small\sffamily
\setlength{\tabcolsep}{5pt}
\caption{My caption}
\label{my-label}
\centering
\begin{tabular}{|l*{15}{|c}|}
\cline{2-16}
\multicolumn{1}{c|}{}
& \multicolumn{3}{c|}{\textbf{prediction at baseline}}
& \multicolumn{3}{c|}{\textbf{prediction at 3 months}}
& \multicolumn{3}{c|}{\textbf{ prediction at 6 months}}
& \multicolumn{3}{c|}{\textbf{prediction at 9 months}}
& \multicolumn{3}{c|}{\textbf{prediction for 44 patients}} \\ \cline{2-16}
\multicolumn{1}{c|}{}
& \multicolumn{3}{c|}{\thead{N = 44,\\ $n_0 =26\ n_1 =18$}}
& \multicolumn{3}{c|}{\thead{N = 22,\\ $n_0 = 13\ n_1 =9$}}
& \multicolumn{3}{c|}{\thead{N = 40,\\ $n_0 =24\ n_1 =16$}}
& \multicolumn{3}{c|}{\thead{N = 24,\\ $n_0 =15\ n_1 =9$}}
& \multicolumn{3}{c|}{\thead{N = 44, $n_0 =26\ n_1 =18$}} \\ \hline
(以上只是序言和前两行表格的片段)或通过其他方式。