我有一张宽表,可以放在横向页面中。我正在尝试组合
- 更改标题段落的字体大小
- 更改表格内容的字体大小
- 调整表格大小
resizebox
tabular
设置环境的宽度
有没有更好的方法?将这样的表格放入页面的最佳方法是什么?到目前为止,我只是在反复\resizebox{1.0\linewidth}{!}{
试验\begin{tabular*}{1.6\linewidth}{@{
\documentclass[12pt]{article}
\usepackage{graphics}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{eurosym}
\usepackage{pdflscape}
\usepackage{lscape}
\usepackage{lipsum}
\begin{document}
\begin{landscape}
\begin{table}
\renewcommand{\arraystretch}{1}
\caption{My Caption}
\label{table:ufukFour}
\footnotesize %Option (a)
\lipsum[1-2]
\begin{center}
\scriptsize %Option (b)
\resizebox{1.0\linewidth}{!}{ %Option (c)
\begin{tabular*}{1.6\linewidth}{@{ %Option (d)
\global\let\restorecr=\\
\extracolsep{\fill} } cc rrrrr rrrrr rrrrr}
\toprule
%\global\let\oldcr=\\
%\global\def\crsng{\global\let\\ =\crtri\oldcr}
%\global\def\crdbl{\global\let\\ =\crsng\oldcr}
%\global\def\crtri{\global\let\\ =\crdbl\oldcr[10pt]}
%\global\let\\=\crtri
\global\let\oldcr=\\
\global\def\crsng{\global\let\\ =\crqua\oldcr}
\global\def\crdbl{\global\let\\ =\crsng\oldcr}
\global\def\crtri{\global\let\\ =\crdbl\oldcr}
\global\def\crqua{\global\let\\ =\crtri\oldcr[10pt]}
\global\let\\=\crqua
&&\multicolumn{5}{c}{\textbf{One}}
& \multicolumn{5}{c}{\textbf{Two}}
& \multicolumn{5}{c}{\textbf{Three}} \vspace{-0.3cm}\\
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
&&\multicolumn{1}{c}{Cat 1} & \multicolumn{1}{c}{Cat 2} & \multicolumn{1}{c}{Cat 3} & \multicolumn{1}{c}{Cat 4} & \multicolumn{1}{c}{Cat 5}
& \multicolumn{1}{c}{Cat 1} & \multicolumn{1}{c}{Cat 2} & \multicolumn{1}{c}{Cat 3} & \multicolumn{1}{c}{Cat 4} & \multicolumn{1}{c}{Cat 5}
& \multicolumn{1}{c}{Cat 1} & \multicolumn{1}{c}{Cat 2} & \multicolumn{1}{c}{Cat 3} & \multicolumn{1}{c}{Cat 4} & \multicolumn{1}{c}{Cat 5} \tabularnewline
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
&&\multicolumn{15}{c}{\textbf{Panel A: First Panel}}\tabularnewline
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
~First & A & 47\% & 34\% & 21\% & 21\% & 18\% & 40\% & 31\% & 25\% & 19\% & 18\% & 26\% & 24\% & 19\% & 14\% & 12\% \\
~ & B & 29\% & 38\% & 49\% & 50\% & 52\% & 43\% & 48\% & 51\% & 55\% & 56\% & 63\% & 61\% & 64\% & 68\% & 67\% \\
~ & C & 24\% & 28\% & 30\% & 30\% & 30\% & 17\% & 21\% & 24\% & 26\% & 26\% & 10\% & 15\% & 17\% & 18\% & 21\% \\
~ & N & \textit{11494} & \textit{4089} & \textit{3239} & \textit{1904} & \textit{1322} & \textit{4801} & \textit{2471} & \textit{1795} & \textit{1438} & \textit{1187} & \textit{808} & \textit{651} & \textit{557} & \textit{529} & \textit{459} \\
Second & A & 25\% & 18\% & 14\% & 11\% & 10\% & 18\% & 13\% & 9\% & 8\% & 8\% & 14\% & 8\% & 6\% & 5\% & 4\% \\
~ & B & 55\% & 59\% & 63\% & 64\% & 64\% & 65\% & 68\% & 72\% & 73\% & 73\% & 76\% & 81\% & 83\% & 84\% & 85\% \\
~ & C & 20\% & 23\% & 23\% & 26\% & 26\% & 17\% & 19\% & 19\% & 19\% & 20\% & 9\% & 11\% & 11\% & 12\% & 11\% \\
~ & N & \textit{7801} & \textit{6363} & \textit{4018} & \textit{3166} & \textit{2643} & \textit{6279} & \textit{6151} & \textit{5336} & \textit{5208} & \textit{4861} & \textit{1707} & \textit{2268} & \textit{2615} & \textit{2905} & \textit{3053} \\
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
%
&&\multicolumn{15}{c}{\textbf{Panel B: Second Panel}} \tabularnewline
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
~First & A & 47\% & 34\% & 21\% & 21\% & 18\% & 40\% & 31\% & 25\% & 19\% & 18\% & 26\% & 24\% & 19\% & 14\% & 12\% \\
~ & B & 29\% & 38\% & 49\% & 50\% & 52\% & 43\% & 48\% & 51\% & 55\% & 56\% & 63\% & 61\% & 64\% & 68\% & 67\% \\
~ & C & 24\% & 28\% & 30\% & 30\% & 30\% & 17\% & 21\% & 24\% & 26\% & 26\% & 10\% & 15\% & 17\% & 18\% & 21\% \\
~ & N & \textit{11494} & \textit{4089} & \textit{3239} & \textit{1904} & \textit{1322} & \textit{4801} & \textit{2471} & \textit{1795} & \textit{1438} & \textit{1187} & \textit{808} & \textit{651} & \textit{557} & \textit{529} & \textit{459} \\
Second & A & 25\% & 18\% & 14\% & 11\% & 10\% & 18\% & 13\% & 9\% & 8\% & 8\% & 14\% & 8\% & 6\% & 5\% & 4\% \\
~ & B & 55\% & 59\% & 63\% & 64\% & 64\% & 65\% & 68\% & 72\% & 73\% & 73\% & 76\% & 81\% & 83\% & 84\% & 85\% \\
~ & C & 20\% & 23\% & 23\% & 26\% & 26\% & 17\% & 19\% & 19\% & 19\% & 20\% & 9\% & 11\% & 11\% & 12\% & 11\% \\
~ & N & \textit{7801} & \textit{6363} & \textit{4018} & \textit{3166} & \textit{2643} & \textit{6279} & \textit{6151} & \textit{5336} & \textit{5208} & \textit{4861} & \textit{1707} & \textit{2268} & \textit{2615} & \textit{2905} & \textit{3053} \\
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
%
&&\multicolumn{15}{c}{\textbf{Panel C: Third Panel}} \tabularnewline
\cmidrule(lr){3-7}
\cmidrule(lr){8-12}
\cmidrule(lr){13-17}
~First & A & 47\% & 34\% & 21\% & 21\% & 18\% & 40\% & 31\% & 25\% & 19\% & 18\% & 26\% & 24\% & 19\% & 14\% & 12\% \\
~ & B & 29\% & 38\% & 49\% & 50\% & 52\% & 43\% & 48\% & 51\% & 55\% & 56\% & 63\% & 61\% & 64\% & 68\% & 67\% \\
~ & C & 24\% & 28\% & 30\% & 30\% & 30\% & 17\% & 21\% & 24\% & 26\% & 26\% & 10\% & 15\% & 17\% & 18\% & 21\% \\
~ & N & \textit{11494} & \textit{4089} & \textit{3239} & \textit{1904} & \textit{1322} & \textit{4801} & \textit{2471} & \textit{1795} & \textit{1438} & \textit{1187} & \textit{808} & \textit{651} & \textit{557} & \textit{529} & \textit{459} \\
Second & A & 25\% & 18\% & 14\% & 11\% & 10\% & 18\% & 13\% & 9\% & 8\% & 8\% & 14\% & 8\% & 6\% & 5\% & 4\% \\
~ & B & 55\% & 59\% & 63\% & 64\% & 64\% & 65\% & 68\% & 72\% & 73\% & 73\% & 76\% & 81\% & 83\% & 84\% & 85\% \\
~ & C & 20\% & 23\% & 23\% & 26\% & 26\% & 17\% & 19\% & 19\% & 19\% & 20\% & 9\% & 11\% & 11\% & 12\% & 11\% \\
~ & N & \textit{7801} & \textit{6363} & \textit{4018} & \textit{3166} & \textit{2643} & \textit{6279} & \textit{6151} & \textit{5336} & \textit{5208} & \textit{4861} & \textit{1707} & \textit{2268} & \textit{2615} & \textit{2905} & \textit{3053} \\
\bottomrule
\end{tabular*}
}
\end{center}
\end{table}
\end{landscape}
\end{document}
答案1
假设纸张尺寸为“正常”(即 A4 或 US-Letter)且边距为 1 英寸,如果您使用\footnotesize
并将默认的列间空白量设置为非常小的值,则表格将适合横向模式;通过使用tabular*
环境和@{\extracolsep{\fill}}
指令,您可以告诉 LaTeX 执行使表格完全适合文本块宽度的任务。(顺便说一下,此设置的一个很好的副作用是您不需要为指令提供任何修剪选项\cmidrule
。)
为了创造更“开放”的外观,请\addlinespace
在这里和那里插入一些说明。
\documentclass[12pt]{article}
\usepackage{booktabs,dcolumn,eurosym,caption}
\usepackage{rotating} % for 'sidewaystable' environment
\usepackage[margin=1in]{geometry}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shorcut macro
\begin{document}
\begin{sidewaystable}
\renewcommand{\arraystretch}{1}
\caption{My Caption}
\label{table:Four}
\footnotesize
\setlength\tabcolsep{0.1mm} % let LaTeX calculate intercolumn whitespace
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}}
c *{15}{r} }
\toprule
&&\multicolumn{5}{c}{\textbf{One}}
& \multicolumn{5}{c}{\textbf{Two}}
& \multicolumn{5}{c}{\textbf{Three}} \\
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
&&\mc{Cat 1} & \mc{Cat 2} & \mc{Cat 3} & \mc{Cat 4} & \mc{Cat 5}
& \mc{Cat 1} & \mc{Cat 2} & \mc{Cat 3} & \mc{Cat 4} & \mc{Cat 5}
& \mc{Cat 1} & \mc{Cat 2} & \mc{Cat 3} & \mc{Cat 4} & \mc{Cat 5} \\
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
\addlinespace
&&\multicolumn{15}{c}{\textbf{Panel A: First Panel}}\\
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
First & A & 47\% & 34\% & 21\% & 21\% & 18\% & 40\% & 31\% & 25\% & 19\% & 18\% & 26\% & 24\% & 19\% & 14\% & 12\% \\
& B & 29\% & 38\% & 49\% & 50\% & 52\% & 43\% & 48\% & 51\% & 55\% & 56\% & 63\% & 61\% & 64\% & 68\% & 67\% \\
& C & 24\% & 28\% & 30\% & 30\% & 30\% & 17\% & 21\% & 24\% & 26\% & 26\% & 10\% & 15\% & 17\% & 18\% & 21\% \\
& N & \textit{11494} & \textit{4089} & \textit{3239} & \textit{1904} & \textit{1322} & \textit{4801} & \textit{2471} & \textit{1795} & \textit{1438} & \textit{1187} & \textit{808} & \textit{651} & \textit{557} & \textit{529} & \textit{459} \\
\addlinespace
Second & A & 25\% & 18\% & 14\% & 11\% & 10\% & 18\% & 13\% & 9\% & 8\% & 8\% & 14\% & 8\% & 6\% & 5\% & 4\% \\
& B & 55\% & 59\% & 63\% & 64\% & 64\% & 65\% & 68\% & 72\% & 73\% & 73\% & 76\% & 81\% & 83\% & 84\% & 85\% \\
& C & 20\% & 23\% & 23\% & 26\% & 26\% & 17\% & 19\% & 19\% & 19\% & 20\% & 9\% & 11\% & 11\% & 12\% & 11\% \\
& N & \textit{7801} & \textit{6363} & \textit{4018} & \textit{3166} & \textit{2643} & \textit{6279} & \textit{6151} & \textit{5336} & \textit{5208} & \textit{4861} & \textit{1707} & \textit{2268} & \textit{2615} & \textit{2905} & \textit{3053} \\
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
\addlinespace
&&\multicolumn{15}{c}{\textbf{Panel B: Second Panel}} \\
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
First & A & 47\% & 34\% & 21\% & 21\% & 18\% & 40\% & 31\% & 25\% & 19\% & 18\% & 26\% & 24\% & 19\% & 14\% & 12\% \\
& B & 29\% & 38\% & 49\% & 50\% & 52\% & 43\% & 48\% & 51\% & 55\% & 56\% & 63\% & 61\% & 64\% & 68\% & 67\% \\
& C & 24\% & 28\% & 30\% & 30\% & 30\% & 17\% & 21\% & 24\% & 26\% & 26\% & 10\% & 15\% & 17\% & 18\% & 21\% \\
& N & \textit{11494} & \textit{4089} & \textit{3239} & \textit{1904} & \textit{1322} & \textit{4801} & \textit{2471} & \textit{1795} & \textit{1438} & \textit{1187} & \textit{808} & \textit{651} & \textit{557} & \textit{529} & \textit{459} \\
\addlinespace
Second & A & 25\% & 18\% & 14\% & 11\% & 10\% & 18\% & 13\% & 9\% & 8\% & 8\% & 14\% & 8\% & 6\% & 5\% & 4\% \\
& B & 55\% & 59\% & 63\% & 64\% & 64\% & 65\% & 68\% & 72\% & 73\% & 73\% & 76\% & 81\% & 83\% & 84\% & 85\% \\
& C & 20\% & 23\% & 23\% & 26\% & 26\% & 17\% & 19\% & 19\% & 19\% & 20\% & 9\% & 11\% & 11\% & 12\% & 11\% \\
& N & \textit{7801} & \textit{6363} & \textit{4018} & \textit{3166} & \textit{2643} & \textit{6279} & \textit{6151} & \textit{5336} & \textit{5208} & \textit{4861} & \textit{1707} & \textit{2268} & \textit{2615} & \textit{2905} & \textit{3053} \\
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
\addlinespace
&&\multicolumn{15}{c}{\textbf{Panel C: Third Panel}} \tabularnewline
\cmidrule{3-7} \cmidrule{8-12} \cmidrule{13-17}
First & A & 47\% & 34\% & 21\% & 21\% & 18\% & 40\% & 31\% & 25\% & 19\% & 18\% & 26\% & 24\% & 19\% & 14\% & 12\% \\
& B & 29\% & 38\% & 49\% & 50\% & 52\% & 43\% & 48\% & 51\% & 55\% & 56\% & 63\% & 61\% & 64\% & 68\% & 67\% \\
& C & 24\% & 28\% & 30\% & 30\% & 30\% & 17\% & 21\% & 24\% & 26\% & 26\% & 10\% & 15\% & 17\% & 18\% & 21\% \\
& N & \textit{11494} & \textit{4089} & \textit{3239} & \textit{1904} & \textit{1322} & \textit{4801} & \textit{2471} & \textit{1795} & \textit{1438} & \textit{1187} & \textit{808} & \textit{651} & \textit{557} & \textit{529} & \textit{459} \\
\addlinespace
Second & A & 25\% & 18\% & 14\% & 11\% & 10\% & 18\% & 13\% & 9\% & 8\% & 8\% & 14\% & 8\% & 6\% & 5\% & 4\% \\
& B & 55\% & 59\% & 63\% & 64\% & 64\% & 65\% & 68\% & 72\% & 73\% & 73\% & 76\% & 81\% & 83\% & 84\% & 85\% \\
& C & 20\% & 23\% & 23\% & 26\% & 26\% & 17\% & 19\% & 19\% & 19\% & 20\% & 9\% & 11\% & 11\% & 12\% & 11\% \\
& N & \textit{7801} & \textit{6363} & \textit{4018} & \textit{3166} & \textit{2643} & \textit{6279} & \textit{6151} & \textit{5336} & \textit{5208} & \textit{4861} & \textit{1707} & \textit{2268} & \textit{2615} & \textit{2905} & \textit{3053}
\\
\bottomrule
\end{tabular*}
\end{sidewaystable}
\end{document}
答案2
如果要使表格适合页面,则必须使用 atabularx
和它的 X 列。但是,您的表格太大,您必须删除一些内容或将其输入得非常小。我不会这样做。
我帮你缩小了表格的宽度。请将示例缩小到最小,并提出具体问题。例如:“如何将表格设置为全宽 \textwidth?”
% arara: pdflatex
\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{pdflscape}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{etoolbox}
\robustify\itshape
\begin{document}
\begin{landscape}
\begin{table}
\sisetup{detect-all}
\caption{My Caption (all values in \si{\percent})}\label{table:Four}
\footnotesize
\lipsum[1]\vspace{1ex}
\centering\scriptsize
\begin{tabular}{%
@{}rc
S[table-format=5.0,group-four-digits]
*{4}{S[table-format=4.0]}
*{5}{S[table-format=4.0]}
*{5}{S[table-format=4.0]}@{}
}\toprule
& & \multicolumn{5}{c}{\textbf{One}} & \multicolumn{5}{c}{\textbf{Two}} & \multicolumn{5}{c}{\textbf{Three}}\\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
& & {Cat 1} & {Cat 2} & {Cat 3} & {Cat 4} & {Cat 5}
& {Cat 1} & {Cat 2} & {Cat 3} & {Cat 4} & {Cat 5}
& {Cat 1} & {Cat 2} & {Cat 3} & {Cat 4} & {Cat 5} \\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
&&\multicolumn{15}{c}{\textbf{Panel A: First Panel}} \\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
First & A & 47 & 34 & 21 & 21 & 18 & 40 & 31 & 25 & 19 & 18 & 26 & 24 & 19 & 14 & 12 \\
& B & 29 & 38 & 49 & 50 & 52 & 43 & 48 & 51 & 55 & 56 & 63 & 61 & 64 & 68 & 67 \\
& C & 24 & 28 & 30 & 30 & 30 & 17 & 21 & 24 & 26 & 26 & 10 & 15 & 17 & 18 & 21 \\
& N & \itshape11494 & \itshape4089 & \itshape3239 & \itshape1904 & \itshape1322 & \itshape4801 & \itshape2471 & \itshape1795 & \itshape1438 & \itshape1187 & \itshape808 & \itshape 651 & \itshape557 & \itshape529 & \itshape459 \\\addlinespace
Second & A & 25 & 18 & 14 & 11 & 10 & 18 & 13 & 9 & 8 & 8 & 14 & 8 & 6 & 5 & 4 \\
& B & 55 & 59 & 63 & 64 & 64 & 65 & 68 & 72 & 73 & 73 & 76 & 81 & 83 & 84 & 85 \\
& C & 20 & 23 & 23 & 26 & 26 & 17 & 19 & 19 & 19 & 20 & 9 & 11 & 11 & 12 & 11 \\
& N & \itshape7801 & \itshape6363 & \itshape4018 & \itshape3166 & \itshape2643 & \itshape6279 & \itshape6151 & \itshape5336 & \itshape5208 & \itshape4861 & \itshape1707 & \itshape2268 & \itshape2615 & \itshape2905 & \itshape3053 \\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
& & \multicolumn{15}{c}{\textbf{Panel B: Second Panel}} \\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
First & A & 47 & 34 & 21 & 21 & 18 & 40 & 31 & 25 & 19 & 18 & 26 & 24 & 19 & 14 & 12 \\
& B & 29 & 38 & 49 & 50 & 52 & 43 & 48 & 51 & 55 & 56 & 63 & 61 & 64 & 68 & 67 \\
& C & 24 & 28 & 30 & 30 & 30 & 17 & 21 & 24 & 26 & 26 & 10 & 15 & 17 & 18 & 21 \\
& N & \itshape11494 & \itshape4089 & \itshape3239 & \itshape1904 & \itshape1322 & \itshape4801 & \itshape2471 & \itshape1795 & \itshape1438 & \itshape1187 & \itshape808 & \itshape651 & \itshape557 & \itshape529 & \itshape459 \\\addlinespace
Second & A & 25 & 18 & 14 & 11 & 10 & 18 & 13 & 9 & 8 & 8 & 14 & 8 & 6 & 5 & 4 \\
& B & 55 & 59 & 63 & 64 & 64 & 65 & 68 & 72 & 73 & 73 & 76 & 81 & 83 & 84 & 85 \\
& C & 20 & 23 & 23 & 26 & 26 & 17 & 19 & 19 & 19 & 20 & 9 & 11 & 11 & 12 & 11 \\
& N & \itshape7801 & \itshape6363 & \itshape4018 & \itshape3166 & \itshape2643 & \itshape6279 & \itshape6151 & \itshape5336 & \itshape5208 & \itshape4861 & \itshape1707 & \itshape2268 & \itshape2615 & \itshape2905 & \itshape3053 \\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
& & \multicolumn{15}{c}{\textbf{Panel C: Third Panel}} \\\cmidrule(lr){3-7}\cmidrule(lr){8-12}\cmidrule(l){13-17}
First & A & 47 & 34 & 21 & 21 & 18 & 40 & 31 & 25 & 19 & 18 & 26 & 24 & 19 & 14 & 12 \\
& B & 29 & 38 & 49 & 50 & 52 & 43 & 48 & 51 & 55 & 56 & 63 & 61 & 64 & 68 & 67 \\
& C & 24 & 28 & 30 & 30 & 30 & 17 & 21 & 24 & 26 & 26 & 10 & 15 & 17 & 18 & 21 \\
& N & \itshape11494 & \itshape4089 & \itshape3239 & \itshape1904 & \itshape1322 & \itshape4801 & \itshape2471 & \itshape1795 & \itshape1438 & \itshape1187 & \itshape808 & \itshape651 & \itshape557 & \itshape529 & \itshape459 \\\addlinespace
Second & A & 25 & 18 & 14 & 11 & 10 & 18 & 13 & 9 & 8 & 8 & 14 & 8 & 6 & 5 & 4 \\
& B & 55 & 59 & 63 & 64 & 64 & 65 & 68 & 72 & 73 & 73 & 76 & 81 & 83 & 84 & 85 \\
& C & 20 & 23 & 23 & 26 & 26 & 17 & 19 & 19 & 19 & 20 & 9 & 11 & 11 & 12 & 11 \\
& N & \itshape7801 & \itshape6363 & \itshape4018 & \itshape3166 & \itshape2643 & \itshape6279 & \itshape6151 & \itshape5336 & \itshape5208 & \itshape4861 & \itshape1707 & \itshape2268 & \itshape2615 & \itshape2905 & \itshape3053 \\
\bottomrule
\end{tabular}
\end{table}
\end{landscape}
\end{document}