# More aesthetically wrap text in a table?

I have a table that I must fit in one page but have difficulty doing so in any aesthetically pleasing manner. A MWE is pasted below. Are there any suggestions to improve this? Regretfully I haven't a clue where to begin.

%----------------------------------------------------------------------------------------
%   DOCUMENT TYPE
%----------------------------------------------------------------------------------------
\documentclass[9pt]{article}

%----------------------------------------------------------------------------------------
%   PACKAGES
%----------------------------------------------------------------------------------------
\usepackage[T1]{fontenc} %Font
\usepackage{libertine}
%\usepackage{lmodern}
\usepackage{slantsc}

\usepackage{amsmath,amssymb,amsfonts,amsthm,textcomp,nicefrac} %Math

\usepackage{graphicx, subfigure} %graphics & nested graphics
\usepackage{float} %place graphics exactly where you desire with [H]
\usepackage[font=footnotesize]{caption}

\usepackage[usenames]{color}
\definecolor{Blue}{rgb}{0,0.08,0.8}

\usepackage{tikz} %graphs
\usetikzlibrary{arrows, shapes, calc, positioning}
\usepackage{array}

\usepackage{hyperref} %References

\usepackage{lscape} %for landscape orientation

\usepackage{titlesec}
\titleformat{\section}{\bfseries}{\thesection}{1em}{} %Section format
\titleformat{\subsection}{\bfseries}{\thesubsection}{1em}{} %Subsection format
\titleformat*{\subsubsection}{\bfseries\em} %Subsubsection format
\renewcommand*\footnoterule{} %Remove footnote separator line
\usepackage[bottom=0.1in]{geometry} %Margins
\usepackage{setspace}%Spacing
\pagestyle{fancy}
\cfoot{\thepage}
\renewcommand{\footrulewidth}{0pt}
\renewcommand*\footnoterule{} %Remove footnote separator line
\usepackage{booktabs}

%----------------------------------------------------------------------------------------
%   Document
%----------------------------------------------------------------------------------------

\begin{document}

\thispagestyle{empty}

\begin{landscape}

{\bf \scshape Personal Record Table}

\begin{table}[H]
\centering
\begin{tabular}{|c|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|} \hline

& {\bf Total Investment}
& {\bf Group 1 Invesment}
& {\bf Group2 Investment}
& {\bf Total payoffs from The Account}
& {\bf Your payoffs from The Account}
& {\bf Cost of deduction points assigned}
& {\bf Number of deduction points received}
& {\bf Cost of deduction points received}
& {\bf Losses from deductions}
& {\bf Final payoffs for this period}
& {\bf Total payoffs for all periods}\\

\hline\hline

{\bf 1} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 2} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 3} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 4} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 5} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 6} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 7} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 8} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 9} & & & & & & & & & & & & & &\\[2ex]\hline
{\bf 10} & & & & & & & & & & & & & &\\[2ex]\hline

\hline

\end{tabular}
\end{table}

\end{landscape}

%----------------------------------------------------------------------------------------
%   END
%----------------------------------------------------------------------------------------
\end{document}

-
welcome to tex.sx. You can format code sections using the {} button in the editor (see my edit) – David Carlisle Jan 26 '14 at 23:02

Perhaps something like this. the headings still look poor, you could use a smaller font so they do not take so many lines, or perhaps?? you could re-word some to be shorter.

%----------------------------------------------------------------------------------------
%   DOCUMENT TYPE
%----------------------------------------------------------------------------------------

% article doesn't have a 9pt opttion, deleted.
\documentclass{article}

%----------------------------------------------------------------------------------------
%   PACKAGES
%----------------------------------------------------------------------------------------
\usepackage[T1]{fontenc} %Font
\usepackage{libertine}
%\usepackage{lmodern}
\usepackage{slantsc}

\usepackage{amsmath,amssymb,amsfonts,amsthm,textcomp,nicefrac} %Math

\usepackage{graphicx, subfigure} %graphics & nested graphics
\usepackage{float} %place graphics exactly where you desire with [H]
\usepackage[font=footnotesize]{caption}

\usepackage[usenames]{color}
\definecolor{Blue}{rgb}{0,0.08,0.8}

% not for MWE, speeds thing sup:-)
%\usepackage{tikz} %graphs
%\usetikzlibrary{arrows, shapes, calc, positioning}
\usepackage{array}

\usepackage{hyperref} %References

\usepackage{lscape} %for landscape orientation

\usepackage{titlesec}
\titleformat{\section}{\bfseries}{\thesection}{1em}{} %Section format
\titleformat{\subsection}{\bfseries}{\thesubsection}{1em}{} %Subsection format
\titleformat*{\subsubsection}{\bfseries\em} %Subsubsection format
\renewcommand*\footnoterule{} %Remove footnote separator line
\usepackage[bottom=0.1in]{geometry} %Margins
\usepackage{setspace}%Spacing
\pagestyle{fancy}
\cfoot{\thepage}
\renewcommand{\footrulewidth}{0pt}
\renewcommand*\footnoterule{} %Remove footnote separator line
\usepackage{booktabs}

%----------------------------------------------------------------------------------------
%   Document
%----------------------------------------------------------------------------------------

\begin{document}

\thispagestyle{empty}

\begin{landscape}

%\bf obsolete in latex2e, and anyway looks like a heading to me.
\section*{Personal Record Table}

%\begin{table}[H] % table not needed here (and H not defined unless you load float package)
\centering
\setlength\extrarowheight{2pt}% keep letters off the lines.

% using r not c for numeric column,
% make p columns narrower, so they fit on page
\begin{tabular}{|>{\bfseries}r|*{14}{>{\bfseries\centering\arraybackslash}p{1.2cm}|}}
\hline

& Total Investment
& Group 1 Invesment
& Group2 Investment
& Total payoffs from The Account
& Your payoffs from The Account
& Cost of deduction points assigned
& Number of deduction points received
& Cost of deduction points received
& Losses from deductions
& Final payoffs for this period
& Total payoffs for all periods\\

\hline\hline

1 & & & & & & & & & & & & & &\\[2ex]\hline
2 & & & & & & & & & & & & & &\\[2ex]\hline
3 & & & & & & & & & & & & & &\\[2ex]\hline
4 & & & & & & & & & & & & & &\\[2ex]\hline
5 & & & & & & & & & & & & & &\\[2ex]\hline
6 & & & & & & & & & & & & & &\\[2ex]\hline
7 & & & & & & & & & & & & & &\\[2ex]\hline
8 & & & & & & & & & & & & & &\\[2ex]\hline
9 & & & & & & & & & & & & & &\\[2ex]\hline
10 & & & & & & & & & & & & & &\\[2ex]\hline
\end{tabular}

\end{landscape}

%----------------------------------------------------------------------------------------
%   END
%----------------------------------------------------------------------------------------
\end{document}

-

I have some suggestions:

• Use the rotating package and its sidewaystable environment to place a table in landscape mode.

• Use something like \usepackage[vmargin=0.5in]{geometry} to provide maximum space for the table.

• Use the tabularx package and its eponymous environment, with a width of \textwidth; let the package compute the widths of the 14 [!] data columns automatically. Since the tabularx environment is set to occupy \textwidth, there's no need (or point) in \centering the table.

• Use \raggedright instead of the default full justification for the data columns.

• It's not clear to me what the role of the string Personal Record Table is. I'm assuming it belongs in a \caption command; however, I may be wrong.

• Issue the instruction \small inside the sidewaystable environment to reduce the fontsize by 10%, and reduce the amount of intercolumn whitespace by setting \setlength\tabcolsep{2pt}. (The default value of this parameter is 6pt.) These two changes succeed in reducing the number of rows needed for the headers to 4.

Further remarks:

• The option 9pt isn't recognized and thus ignored by the article document class. I've therefore deleted it from the code below. The article document class recognizes only 10pt (default), 11pt, and 12pt as fontsize-related options.

• The macro {\bf ...} is PlainTeX; for LaTeX documents it's much better to use \textbf{...}.

• Your example code contains a lot of material that's not relevant for the table at hand; I've taken the liberty of stripping the code down to what's essential for typesetting the table.

\documentclass{article}
\usepackage{libertine}
\usepackage[vmargin=0.5in]{geometry}
\usepackage{rotating} % for sidewaystable environment
\usepackage{tabularx} % for tabularx environment
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}

\begin{document}
\thispagestyle{empty}

\begin{sidewaystable}
\small % 10% reduction of fontsize, i.e., from 10pt to 9pt
\setlength\tabcolsep{2pt} % default value: 6pt
\caption{Personal Record Table}

\medskip

\begin{tabularx}{\textwidth}{|c|*{14}{Y|}}
\hline
& \textbf{Total Investment}
& \textbf{Group1 Investment}
& \textbf{Group2 Investment}
& \textbf{Total payoffs from The Account}
& \textbf{Your payoffs from The Account}
& \textbf{Cost of deduction points assigned}
& \textbf{Number of deduction points received}
& \textbf{Cost of deduction points received}
& \textbf{Losses from deductions}
& \textbf{Final payoffs for this period}
& \textbf{Total payoffs for all periods}\\
\hline\hline
\textbf{1} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{2} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{3} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{4} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{5} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{6} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{7} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{8} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{9} & & & & & & & & & & & & & &\\[2ex]\hline
\textbf{10} & & & & & & & & & & & & & &\\[2ex]\hline
\end{tabularx}
\end{sidewaystable}
\end{document}

-
the baselines in the headers look larger than necessary. (take a look at the spacing between the lines "payoff" and "from".) also, a slightly smaller size wouldn't be detrimental, and might avoid a few hyphenated words. – barbara beeton Jan 27 '14 at 14:42
@barbarabeeton - Thanks. Will post a reworked example with (i) a \small directive in effect for the table (so that the font size will be 9pt rather than 10pt) and (ii) a lower value for \tabcolsep (so that more material will fit on each line). The baseline distances in the headers are, in fact, perfectly constant; it's just that one gap looks wider than the other because it happens to feature (virtually) no characters with descenders & ascenders whereas the next gap happens to have lots of them. – Mico Jan 27 '14 at 16:44