Graphics, Figures & TablesHow to handle wide tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

How to handle wide tables

Post by Singularity »

How do you Latex experts handle wide tables to get them to fit in the margins?

My MWE with problem table is attached. Note that I added the double \newline to get some blank space before the table, but keep it in the same paragraph so as to have it not indented.

Thanks.

Code: Select all

\documentclass[11pt,fleqn,reqno,oneside]{article}
%fleqn: left align equations		
%reqno: equation numbers on right
%oneside/twoside: for one or two sided printing with binding

%Math packages
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\everymath{\displaystyle}		% Default to displaystyle math.

\usepackage{array}					% Provides for a more flexible array and tabular environment
\usepackage{booktabs}				% For fancy stuff in arrays and tables, like the following column definitions
\usepackage{multirow}				% For multiple row cells in tables.
\usepackage{caption}
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%

\begin{document}
Two-dimensional systems are equivalent to the one dimensional systems except that they have more connections between them. Yet $2$-d systems with equivalent numbers of masses to $1$-d systems either show no energy sharing, as in figures (slash ref omitted for MWE) and (slash ref omitted for MWE), or they break down into a thermalized state, as in figures (slash ref omitted for MWE) and (slash ref omitted for MWE).
\newline\newline
\begin{minipage}{\linewidth}
\centering
\captionof{table}{Summary of Results} \label{tab:Summary}
\begin{tabular}{|l|l|l|l|}
	\toprule
	$N$ & $N \times 1$ & $N^2 \times 1$ & $N \times N$ \\
	\midrule
	\multirow{2}{*}{$8$} & No recurrence.                     & \multirow{2}{*}{Recurrence for $\beta = 3 \ldots 12$.} & No recurrence. \\
	                     & Thermalizes $\beta = 3 \ldots 32$. &                                                        & Thermalizes $\beta = 8, 9, 14 \ldots 32$. \\
	\midrule
	\multirow{2}{*}{$32$} & Recurrence in $\beta = 4 \ldots 9$. & \multirow{2}{*}{Flatline $\beta = 1 \ldots 32$} & No recurrence. \\
	                      & Thermalizes $\beta = 9 \ldots 32$.  &                                                 & Thermalizes $\beta = 16 \ldots 32$.\\
	\bottomrule
\end{tabular}
\end{minipage}
\end{document}
A (considerably) lesser issue is that in my implementation, this MWE gives a warning "The option 'hypcap=true' will be ignored for this". Why? And how do I get fix whatever the problem is?
Attachments
MWE.tex
(2 KiB) Downloaded 278 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to handle wide tables

Post by Johannes_B »

Too wide tables can have many reasons. Often it is bad design.
My first reaction seeing your table was: Why didn't he transpose the whole thing? There might be other rows. But still, i think it looks much better.

Code: Select all

\documentclass{article}
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\everymath{\displaystyle}%that's not a good idea, imho

\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{caption}
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%

\usepackage{showframe}
\begin{document}
Two-dimensional systems are equivalent to the one dimensional
systems except that they have more connections between them. Yet
$2$-d systems with equivalent numbers of masses to $1$-d systems
either show no energy sharing, as in figures (slash ref omitted
for MWE) and (slash ref omitted for MWE), or they break down into
a thermalized state, as in figures (slash ref omitted for MWE)
and (slash ref omitted for MWE).
%\newline\newline nah, finishing the paragraph with a blank line
%is just fine

\noindent\begin{minipage}{\linewidth}
\centering
\captionof{table}{Summary of Results} \label{tab:Summary}
\begin{tabular}{|l|l|l|l|}
        \toprule
        $N$                    & $N \times 1$                        & $N^2 \times 1$                                         & $N \times N$ \\
        \midrule
        \multirow{2}{*}{$8$}   & No recurrence.                      & \multirow{2}{*}{Recurrence for $\beta = 3 \ldots 12$.} & No recurrence. \\
                               & Thermalizes $\beta = 3 \ldots 32$.  &                                                        & Thermalizes $\beta = 8, 9, 14 \ldots 32$. \\
        \midrule
        \multirow{2}{*}{$32$}   & Recurrence in $\beta = 4 \ldots 9$. & \multirow{2}{*}{Flatline $\beta = 1 \ldots 32$} & No recurrence. \\
                                & Thermalizes $\beta = 9 \ldots 32$.  &                                                 & Thermalizes $\beta = 16 \ldots 32$.\\
        \bottomrule
\end{tabular}

\bigskip
\begin{tabular}{ccc}
	\toprule
	$N$          & 8             & 32 \\
	\midrule
$N \times 1$    & No recurrence                             & Recurrence in $\beta = 4 \ldots 9$. \\
                & Thermalizes $\beta = 3 \ldots 32$         & Thermalizes $\beta = 9 \ldots 32$.\\\addlinespace
$N^2 \times 1$  & Recurrence for $\beta = 3 \dots 12 $      & Flatline $\beta = 1 \ldots 32$\\\addlinespace
$N \times N$    & No recurrence.                            & No recurrence.\\
                & Thermalizes $\beta = 8, 9, 14 \ldots 32$. & Thermalizes $\beta = 16 \ldots 32$.\\


\bottomrule
\end{tabular}
\end{minipage}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

How to handle wide tables

Post by Singularity »

Johannes_B wrote:Too wide tables can have many reasons. Often it is bad design.
My first reaction seeing your table was: Why didn't he transpose the whole thing? There might be other rows. But still, i think it looks much better.
...
I considered that. But it took me almost 2 hours to figure out what I had (finding the right packages, reading about them, finding an explanation of what you just read because most Latex documentation is written as if the user is already a Latex expert and doesn't give examples, etc), and I was just too tired to redo it as a transpose. Also, I feel like the horizontal layout presented what I wanted to say a little clearer, since even tables are usually read left-to-right. So I was kind of hoping there was some "shrink" or "magnify" type option.

That said, I'm not married to the horizontal layout, so I may yet end up using your code (albeit with a few more midrules thrown in). It avoids the margin issues and will still get my point across.

Edit: There are no other rows to the original table (columns in the transposed one).
Last edited by Singularity on Sun Apr 06, 2014 10:05 pm, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: How to handle wide tables

Post by Johannes_B »

For me, your content are just letters. I don't know the topic, and i don't know the message. You are right, reading direction is important to transfer knowledge.

One other possibility would be to decrease the font size, but it would be somehow odd for the reader to find only one single table with a smaller font size. Having said that, you could make all tables smaller, if your up to it.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

How to handle wide tables

Post by Singularity »

Johannes_B wrote:...
One other possibility would be to decrease the font size, but it would be somehow odd for the reader to find only one single table with a smaller font size. Having said that, you could make all tables smaller, if your up to it.
How, please? (Note, there's only the one table, at least so far).
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to handle wide tables

Post by Johannes_B »

You could use a font switch loke \small or \footnotesize above the tabular environment.

Making all of them smaller would mean either, work by hand, or defining all tables alike.

Code: Select all

\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{blindtext}

\usepackage{showframe}
\newenvironment{mytable}{
\begin{center}%A bit of vertical space
	\begin{minipage}{\linewidth}%can't be broken over pages
%		\scriptsize
		\huge%a switch defined globally
	}{\end{minipage}
\end{center}
}
		
\begin{document}
\blindtext

\begin{mytable}
\centering
\captionof{table}{Summary of Results} \label{tab:Summary}
\begin{tabular}{ccc}
	\toprule
	$N$          & 8             & 32 \\
	\midrule
$N \times 1$    & No recurrence                             & Recurrence in $\beta = 4 \ldots 9$. \\
                & Thermalizes $\beta = 3 \ldots 32$         & Thermalizes $\beta = 9 \ldots 32$.\\\addlinespace
$N^2 \times 1$  & Recurrence for $\beta = 3 \dots 12 $      & Flatline $\beta = 1 \ldots 32$\\\addlinespace
$N \times N$    & No recurrence.                            & No recurrence.\\
                & Thermalizes $\beta = 8, 9, 14 \ldots 32$. & Thermalizes $\beta = 16 \ldots 32$.\\
\bottomrule
\end{tabular}
\end{mytable}

\blindtext

\begin{mytable}
	\begin{tabular}{rl}
		\toprule
		some & text\\
		\bottomrule
	\end{tabular}
\end{mytable}
\end{document}
Please note that LaTeX provides you with floating environments for figures and tables, that way they can be put on a place, where they fit best. If you want to define a font size or the centering globally, there are other roads to take.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

How to handle wide tables

Post by Singularity »

Not sure where this example came from, but it's in one of my browser tabs and is how I would print the table vertically (if I go that route). Posting it here solely for my future reference:

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to writeLaTeX --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you give
% someone the link to this page, they can edit at the same
% time. See the help menu above for more info. Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\everymath{\displaystyle}%that's not a good idea, imho

\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{caption}
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%

\begin{document}
Two-dimensional systems are equivalent to the one dimensional
systems except that they have more connections between them. Yet
$2$-d systems with equivalent numbers of masses to $1$-d systems
either show no energy sharing, as in figures (slash ref omitted
for MWE) and (slash ref omitted for MWE), or they break down into
a thermalized state, as in figures (slash ref omitted for MWE)
and (slash ref omitted for MWE).
%\newline\newline nah, finishing the paragraph with a blank line
%is just fine

\noindent\begin{minipage}{\linewidth}
%\centering
\bigskip
\captionof{table}{Summary of Results} \label{tab:Summary}
\begin{tabular}{lll}
        \toprule
        $N$          & 8             & 32 \\
        \toprule
$N \times 1$    & No recurrence.                             & Recurrence in $\beta = 4 \ldots 9$. \\
                & Thermalizes $\beta = 3 \ldots 32$.         & Thermalizes $\beta = 9 \ldots 32$.\\\midrule
$N^2 \times 1$  & Recurrence for $\beta = 3 \dots 12$.      & Flatline $\beta = 1 \ldots 32$.\\\midrule
$N \times N$    & No recurrence.                            & No recurrence.\\
                & Thermalizes $\beta = 8, 9, 14 \ldots 32$. & Thermalizes $\beta = 16 \ldots 32$.\\
\bottomrule
\end{tabular}
\end{minipage}
\end{document}
Post Reply