2

I've created a horizontal table using the tabular package. The rotating package isn't playing nicely with one of my other packages, so I can't use \sidewaystable. However, my table still runs off the page. Is there any quick fix where I can get my columns to have a fixed width and fit on the page. Thanks

\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}
7
  • 1
    Welcome to TeX SE. It is great that you include code but it is not as useful as it could be. First, it is far from minimal. Try creating a Minimal Working Example - that is, the smallest complete document you can which produces the problem. Second, can you reproduce the issue with a standard class? Since I don't have psuthesis I can't reproduce the issue from your current code. By the way, you load graphicx at least 3 times though I don't think you need it for the MWE even once.
    – cfr
    Apr 14, 2014 at 21:37
  • @cfr Hi, thanks for taking a look. I just tried to run it in a few other classes, but no dice. I'm using a template from the school for my dissertation, so I try not to mess around much with the front matter. I cut down some of the extra text I had in the packages area, do you have any other suggestions? Apr 14, 2014 at 21:41
  • You mean you can't reproduce it with a standard class? One thing you do need, though, is \begin{document}... \end{document}. You also load caption multiple times.
    – cfr
    Apr 14, 2014 at 21:42
  • 1
    Your document was not close to being a "minimal working example" it used a non standard class, included dozens of packages not required to show the problem and did not include the full markup of a document, I've edited it so people can reproduce the problem. Apr 14, 2014 at 22:25
  • 1
    @DavidCarlisle Thanks David. I'm really a novice when it comes to LaTeX, I'm mostly pasting text into my TexShop window. I appreciate your corrections. Apr 14, 2014 at 23:00

2 Answers 2

2

You could use something like this but note that it does make the text of your table quite small. Note that I did this before David Carlisle edited your question and so my example is somewhat less minimal. I kept the font packages and page layout in case that affected the spacing but I could certainly have pared it down further.

I've used rules and a couple of other tweaks to improve readability:

\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}

Smaller tabular

3
  • Omg, you are my hero. Seriously, I'm only using LaTeX for my dissertation because it's a requirement and this saved my life. Thank you, thank you, thank you!!!! Apr 14, 2014 at 22:59
  • @CharlieTango You're welcome. Don't forget to consider accepting an answer when you've decided which solution works best for you. [Though I feel a bit of an ingrate after being thanked that effusively - it's only a table! Anyway, somebody saved my dissertation at the eleventh hour when the damn thing wouldn't compile and I blindly panicked...]
    – cfr
    Apr 14, 2014 at 23:10
  • How do I accept an answer? It might be only a table, but I have to make 3 of these and I've got a minimum of time finish these changes so I can graduate on time. Duh, nevermind. I found the green check. Thanks again. I'm going to VERY CAREFULLY paste my other numbers into this code and then change the titles. Thank you again. Apr 14, 2014 at 23:12
1

One possible layout (which still generates warnings but fits on a page with article class) is

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .