水平表间距问题

水平表间距问题

我使用 tabular 包创建了一个水平表。rotation 包与我的其他包之一配合得不好,所以我无法使用\sidewaystable。但是,我的表仍然超出页面范围。有没有快速修复方法可以让我的列具有固定宽度并适合页面。谢谢

\documentclass[12pt]{article}
\usepackage{array,longtable,pdflscape}
\begin{document}

\begin{landscape}
\begin{table}
\begin{tabular}{lllllllllllllll}
 & \multicolumn{11}{l}{\begin{tabular}[c]{@{}c@{}}Current\\   Affiliation\end{tabular}} &  &  &  \\
Affiliation at Age 16 & \multicolumn{1}{c}{Evangelical Protestant} & \multicolumn{1}{c}{Mainline Protestant} & \multicolumn{1}{c}{Historically Black Protestant} & \multicolumn{1}{c}{Catholic} & \multicolumn{1}{c}{Mormon} & \multicolumn{1}{c}{Orthodox} & \multicolumn{1}{c}{Jewish} & \multicolumn{1}{c}{Muslim} & \multicolumn{1}{c}{Buddhist} & \multicolumn{1}{c}{Hindu} & \multicolumn{1}{c}{Unaffiliated} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} \\
Evangelical Protestant & 50.4 & 17.1 & 3.7 & 8.7 & 0.3 & 0.0 & 0.0 & 1.0 & 0.1 & 0.0 & 16.1 &  &  &  \\
Mainline Protestant & 17.7 & 48.0 & 3.4 & 9.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 21.2 &  &  &  \\
Historically Black Protestant & 11.5 & 2.5 & 62.9 & 7.9 & 0.0 & 0.0 & 0.0 & 1.6 & 0.6 & 0.0 & 10.8 &  &  &  \\
Catholic & 10.5 & 4.2 & 1.3 & 68.5 & 0.3 & 0.1 & 0.3 & 0.0 & 0.7 & 0.1 & 12.1 &  &  &  \\
Mormon & 4.0 & 3.7 & 0.0 & 7.4 & 61.6 & 0.0 & 5.5 & 0.0 & 2.5 & 0.0 & 15.3 &  &  &  \\
Orthodox & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 100.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 &  &  &  \\
Jewish & 0.0 & 0.0 & 0.0 & 11.3 & 0.0 & 0.0 & 48.3 & 0.0 & 0.0 & 0.0 & 40.4 &  &  &  \\
Muslim & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 70.9 & 0.0 & 0.0 & 29.2 &  &  &  \\
Buddhist & 0.0 & 0.0 & 0.0 & 0.0 & 38.7 & 0.0 & 0.0 & 0.0 & 61.3 & 0.0 & 0.0 &  &  &  \\
Hindu & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 100.0 & 0.0 &  &  &  \\
Unaffiliated & 20.9 & 2.5 & 4.3 & 19.7 & 2.6 & 0.0 & 0.8 & 0.0 & 1.9 & 0.0 & 41.8 &  &  &  \\
Net Loss & 4.7 & 165.7 & 16.6 & -26.0 & -11.9 & 80.4 & -14.8 & 27.9 & 278.9 & 32.7 & 221.0 &  &  &  \\
Proportion of the Population & 18.1 & 7.7 & 4.2 & 47.6 & 1.4 & 0.1 & 0.9 & 0.5 & 0.7 & 0.2 & 15.6 &  &  &  \\
 &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\
 &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\
 &  &  &  &  &  &  &  &  &  &  &  &  &  &
\end{tabular}
\end{table}
\end{landscape}

\end{document}

答案1

您可以使用类似这样的方法,但请注意,这会使表格中的文本变得非常小。请注意,我在 David Carlisle 编辑您的问题之前就这样做了,所以我的示例没有那么简单。我保留了字体包和页面布局,以防影响间距,但我当然可以进一步缩减。

我使用了一些规则和其他一些调整来提高可读性:

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{exscale}
\usepackage{booktabs,array}
\usepackage[margin=1in]{geometry}
\geometry{letterpaper}
\usepackage{float}
\usepackage{pdflscape}
\usepackage{setspace}
    \doublespacing
\begin{document}
\begin{landscape}
  \begin{table}
    \footnotesize
    \begin{tabular}{>{\raggedright}m{.15\linewidth}*{3}{>{\raggedleft}m{.075\linewidth}}*{7}{>{\raggedleft}m{.05\linewidth}}>{\raggedleft\arraybackslash}m{.075\linewidth}}
      \cmidrule[\heavyrulewidth]{2-12}
       & \multicolumn{11}{l}{Current Affiliation}\\\midrule
      Affiliation at Age 16 & \centering Evangelical Protestant & \centering Mainline Protestant& \centering Historically Black Protestant& \centering Catholic & \centering Mormon & \centering Orthodox & \centering Jewish & \centering Muslim & \centering Buddhist & \centering Hindu & \centering Unaffiliated \tabularnewline\midrule
      Evangelical Protestant & 50.4 & 17.1 & 3.7 & 8.7 & 0.3 & 0.0 & 0.0 & 1.0 & 0.1 & 0.0 & 16.1\\
      Mainline Protestant & 17.7 & 48.0 & 3.4 & 9.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 21.2\\
      Historically Black Protestant & 11.5 & 2.5 & 62.9 & 7.9 & 0.0 & 0.0 & 0.0 & 1.6 & 0.6 & 0.0 & 10.8\\
      Catholic & 10.5 & 4.2 & 1.3 & 68.5 & 0.3 & 0.1 & 0.3 & 0.0 & 0.7 & 0.1 & 12.1\\
      Mormon & 4.0 & 3.7 & 0.0 & 7.4 & 61.6 & 0.0 & 5.5 & 0.0 & 2.5 & 0.0 & 15.3\\
      Orthodox & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 100.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\
      Jewish & 0.0 & 0.0 & 0.0 & 11.3 & 0.0 & 0.0 & 48.3 & 0.0 & 0.0 & 0.0 & 40.4\\
      Muslim & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 70.9 & 0.0 & 0.0 & 29.2 \\
      Buddhist & 0.0 & 0.0 & 0.0 & 0.0 & 38.7 & 0.0 & 0.0 & 0.0 & 61.3 & 0.0 & 0.0\\
      Hindu & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 100.0 & 0.0\\
      Unaffiliated & 20.9 & 2.5 & 4.3 & 19.7 & 2.6 & 0.0 & 0.8 & 0.0 & 1.9 & 0.0 & 41.8 \\\midrule
      Net Loss & 4.7 & 165.7 & 16.6 & -26.0 & -11.9 & 80.4 & -14.8 & 27.9 & 278.9 & 32.7 & 221.0\\\midrule
      Proportion of the Population & 18.1 & 7.7 & 4.2 & 47.6 & 1.4 & 0.1 & 0.9 & 0.5 & 0.7 & 0.2 & 15.6\\\bottomrule
    \end{tabular}
  \end{table}
\end{landscape}
\end{document}

较小的表格

答案2

一种可能的布局(仍然会生成警告,但适合带有 article 类的页面)是

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{array,longtable,pdflscape,dcolumn}
\begin{document}
\newcommand\hd[1]{\rotatebox{90}{\small\textbf{#1}}}

\begin{landscape}
\vspace*{-2cm}
\begin{tabular}{>{\small\bfseries}l*{11}{D..{3.1}}}
Affiliation at Age 16 \hd{Current Affiliation}&
\hd{Evangelical Protestant} & \hd{Mainline Protestant} & \hd{Hist. Black Protestant} & \hd{Catholic} & \hd{Mormon} & \hd{Orthodox} & \hd{Jewish} & \hd{Muslim} & \hd{Buddhist} & \hd{Hindu} & \hd{Unaffiliated} \\

Evangelical Protestant & 50.4 & 17.1 & 3.7 & 8.7 & 0.3 & 0.0 & 0.0 & 1.0 & 0.1 & 0.0 & 16.1  \\
Mainline Protestant & 17.7 & 48.0 & 3.4 & 9.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 21.2  \\
Hist. Black Protestant & 11.5 & 2.5 & 62.9 & 7.9 & 0.0 & 0.0 & 0.0 & 1.6 & 0.6 & 0.0 & 10.8 \\
Catholic & 10.5 & 4.2 & 1.3 & 68.5 & 0.3 & 0.1 & 0.3 & 0.0 & 0.7 & 0.1 & 12.1 \\
Mormon & 4.0 & 3.7 & 0.0 & 7.4 & 61.6 & 0.0 & 5.5 & 0.0 & 2.5 & 0.0 & 15.3 \\
Orthodox & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 100.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0  \\
Jewish & 0.0 & 0.0 & 0.0 & 11.3 & 0.0 & 0.0 & 48.3 & 0.0 & 0.0 & 0.0 & 40.4 \\
Muslim & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 70.9 & 0.0 & 0.0 & 29.2 \\
Buddhist & 0.0 & 0.0 & 0.0 & 0.0 & 38.7 & 0.0 & 0.0 & 0.0 & 61.3 & 0.0 & 0.0 \\
Hindu & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 100.0 & 0.0 \\
Unaffiliated & 20.9 & 2.5 & 4.3 & 19.7 & 2.6 & 0.0 & 0.8 & 0.0 & 1.9 & 0.0 & 41.8 \\
Net Loss & 4.7 & 165.7 & 16.6 & -26.0 & -11.9 & 80.4 & -14.8 & 27.9 & 278.9 & 32.7 & 221.0  \\
\begin{tabular}[t]{@{}c@{}}Proportion of\\ the Population\end{tabular}& 18.1 & 7.7 & 4.2 & 47.6 & 1.4 & 0.1 & 0.9 & 0.5 & 0.7 & 0.2 & 15.6   \\
 \end{tabular}

\end{landscape}

\end{document}

相关内容