Graphics, Figures & TablesHow to reduce space?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
rain
Posts: 12
Joined: Thu Jan 28, 2016 9:00 pm

How to reduce space?

Post by rain »

I have issues with displaying tables. They consume too much space. It happens often that some figure or table could fit in the end of previous page but it goes to next page. See screenshot.

Code: Select all

\noindent Tables below will illustrate record linkage attack.
\FloatBarrier
\begin{table}
\begin{center}
\caption {Work (adapted from ~\cite{ppdp})}
\begin{tabular}{|c|c|c|c|c|c|}
\hline \textbf{First name} & \textbf{Last name} & \textbf{Age} & \textbf{Gender} & \textbf{City} & \textbf{Work} \\ 
\hline Juhan & Olev & 39 & Male & Elva & Programmer \\
\hline John & Doe & 35 & Male & Elva & Analyst \\ 
\hline Gebede & Ahmed & 37 & Male & Tartu & Developer \\ 
\hline Beth & Smith & 41 & Female & Tartu & Designer \\ 
\hline Laura & Saar & 44 & Female & Elva & Painter \\ 
\hline 
\end{tabular}
\label{work}
\end{center}
\end{table}

\begin{table}
\begin{center}
\caption {Disability (adapted from ~\cite{ppdp})}
\begin{tabular}{|c|c|c|c|}
\hline \textbf{Age} & \textbf{Gender} & \textbf{City} & \textbf{Disability}  \\ 
\hline 39 & Male & Elva & No \\
\hline 35 & Male & Elva & Yes \\ 
\hline 37 & Male & Tartu & No \\ 
\hline 41 & Female & Tartu & Yes \\ 
\hline 44 & Female & Elva & No  \\
\hline
\end{tabular}
\label{flu}
\end{center}
\end{table}
\FloatBarrier

Attached screenshot shows what I get.
rendering.png
rendering.png (55.29 KiB) Viewed 2990 times
If you look at screeshot, bot tables could be fitted on page 11. What could I do to stop that space waste? If I remove \FloatBarrier they go somewhere far away. What would you recommend to do?

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 reduce space?

Post by Johannes_B »

If they would fit in that space, LaTeX would put them there. They aren't.
LaTeX standard puts only one float at the bottom of the page, and it can take up a maximum of thirty percent of the text block height.

You have two different float, with extra space inside. I gave an alternative version of the tables below.

Side node, if you don't want your pictures to float around, why are you putting them in a floating environment?

Code: Select all

\documentclass{article}
\usepackage{placeins}
\usepackage{caption}
\usepackage{booktabs}
\newcommand{\tabhead}{\textbf}
\renewcommand{\bottomfraction}{.5}
\begin{document}
\noindent Tables below will illustrate record linkage attack.
\FloatBarrier
\begin{table}
	\centering
	\caption {Work (adapted from~\cite{ppdp})}
	\begin{tabular}{cccccc}
		\toprule
		\tabhead{First name} & \tabhead{Last name} & \tabhead{Age} & \tabhead{Gender} & \tabhead{City} & \tabhead{Work} \\
		\midrule
		Juhan                & Olev                & 39            & Male             & Elva           & Programmer \\
		John                 & Doe                 & 35            & Male             & Elva           & Analyst \\
		Gebede               & Ahmed               & 37            & Male             & Tartu          & Developer \\
		Beth                 & Smith               & 41            & Female           & Tartu          & Designer \\
		Laura                & Saar                & 44            & Female           & Elva           & Painter \\
		\bottomrule
	\end{tabular}
	\label{work}

	\bigbreak
	\caption {Disability (adapted from~\cite{ppdp})}
	\begin{tabular}{cccc}
		\toprule
		\tabhead{Age} & \tabhead{Gender} & \tabhead{City} & \tabhead{Disability}  \\
		\midrule
		39            & Male             & Elva           & No \\
		35            & Male             & Elva           & Yes \\
		37            & Male             & Tartu          & No \\
		41            & Female           & Tartu          & Yes \\
		44            & Female           & Elva           & No  \\
		\bottomrule
	\end{tabular}
	\label{flu}
\end{table}
\FloatBarrier
\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.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How to reduce space?

Post by Stefan Kottwitz »

Don't use \begin{center} ... \end{center} in a table environment. The reason is, that the center environment is for centered displayed text within normal text, so it adds space before and after it. This would add to the space, that the table environment already adds.

So, for centered tables, write:

Code: Select all

\begin{table}
  \centering
  ...
\end{table}
\centering does centering without adding extra space before and above. And this setting is limited within an environment, so centering stops at \end{table}.

That's what Johannes did above. He just did not explicitly mention it, so I added it.

Stefan
LaTeX.org admin
Post Reply