GeneralTable Size and Figure Spacing in LaTex

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
BMAcox
Posts: 40
Joined: Sun Dec 23, 2007 12:07 am

Table Size and Figure Spacing in LaTex

Post by BMAcox »

Hello All:

I am having trouble w. my table and figure. Hope you can help:
1.
I created a table in Latex, but currently it is too big. I would like to make the fonts of my table values smaller compared to the rest of my document. How can I do that?
2.
I uploaded .pdf graphics files into my MikTex project for various figures. But for each figure, there is alot of spacing that is put between the graph and my caption. The spacing is at least 1/3 of my 8x11 page. Does anyone know why that occurs and how to fix that?

Thank you in advance!

Recommended reading 2024:

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

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

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Table Size and Figure Spacing in LaTex

Post by Juanjo »

Question 1.

There are several tips to reduce the width of a table:
  • Reduce the fontsize in the whole table. For this, put before the table a suitable declaration command as \small or \scriptsize. To limit the effect of this declaration to a specific table, add after it the \normalsize command, put the table in an environment (center, for example), or enclose the table with \begingroup and \endgroup.
  • Reduce the space between columns, varying the \tabcolsep length.
  • Scale down the table with \scale or resize it with \resizebox. Both commands are defined in the graphicx package
  • Reduce the fontsize of some columns with the help of the array package. A command like >{\small} before a column descriptor writes all elements in that column in small size.
Of course, you can combine one or more of these ideas. See the following example:

Code: Select all

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{array}

\begin{document}

\noindent Left margin here \hfill right margin here.

\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
   \hline \multicolumn{8}{|c|}{A wide table} \\ \hline
   One.One & One.Two & One.Three & One.Four & One.Five 
           & One.Six & One.Seven & One.Eight \\
   Two.One & Two.Two & Two.Three & Two.Four & Two.Five
           & Two.Six & Two.Seven & Two.Eight \\ \hline
\end{tabular}
\end{center}

\begin{center}
\small\addtolength{\tabcolsep}{-5pt}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
   \hline \multicolumn{8}{|c|}{A (not so) wide table} \\ \hline
   One.One & One.Two & One.Three & One.Four & One.Five 
           & One.Six & One.Seven & One.Eight \\
   Two.One & Two.Two & Two.Three & Two.Four & Two.Five
           & Two.Six & Two.Seven & Two.Eight \\ \hline
\end{tabular}
\end{center}

\begin{center}
\scalebox{0.7}{%
\begin{tabular}{|c|c|c|c|c|c|c|c|}
   \hline \multicolumn{8}{|c|}{A (not so) wide table} \\ \hline
   One.One & One.Two & One.Three & One.Four & One.Five 
           & One.Six & One.Seven & One.Eight \\
   Two.One & Two.Two & Two.Three & Two.Four & Two.Five
           & Two.Six & Two.Seven & Two.Eight \\ \hline
\end{tabular}}
\end{center}

\begin{center}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|c|c|}
   \hline \multicolumn{8}{|c|}{A (not so) wide table} \\ \hline
   One.One & One.Two & One.Three & One.Four & One.Five 
           & One.Six & One.Seven & One.Eight \\
   Two.One & Two.Two & Two.Three & Two.Four & Two.Five
           & Two.Six & Two.Seven & Two.Eight \\ \hline
\end{tabular}}
\end{center}

\begin{center}
\addtolength{\tabcolsep}{-3pt}
\begin{tabular}{|>{\tiny}c|c|>{\tiny}c|c|>{\tiny}c|c|>{\tiny}c|c|}
   \hline \multicolumn{8}{|c|}{A (not so) wide table} \\ \hline
   One.One & One.Two & One.Three & One.Four & One.Five 
           & One.Six & One.Seven & One.Eight \\
   Two.One & Two.Two & Two.Three & Two.Four & Two.Five
           & Two.Six & Two.Seven & Two.Eight \\ \hline
\end{tabular}
\end{center}

\end{document}
Question 2

You can eliminate superfluous space by means of the trim option of \includegraphics. Please, take a look at this topic and this document.

Merry Christmas!
BMAcox
Posts: 40
Joined: Sun Dec 23, 2007 12:07 am

Re: Table Size and Figure Spacing in LaTex

Post by BMAcox »

Thank you! :D I will try out the solns. So far for 2., I have only been able to add graphics that are .pdf which is also what my LaTex file is output to. I will look for addtl extensions in the Document too. Happy New Year!
BMAcox
Posts: 40
Joined: Sun Dec 23, 2007 12:07 am

Re: Table Size and Figure Spacing in LaTex

Post by BMAcox »

Hello. I tried out the code on its own and worked exactly. Thank you. But when I added a caption to the Table, I got the table back in the same size as before (not the smaller version :oops: ) and the caption went missing. The code that I had modified the original posted earlier was:
\begin{table}
\begin{center}
\small\addtolength{\tabcolsep}{-5pt}
\begin{tabular}{c||c|c|c||c|c||c}
X& x1 & $x2$ & x3 & x4 & x5&x6\\\hline
I & 1& 2& 3 & 4 & 5& 6\\
& (.46) & & & (.16)&&\\
II&1&2&3 & 4&5&6\\
& (.82) & & & (.28)&&\\
III &1&2 &3& 4&5&6\\
& (.63) & & & (.24)&&\\
IV & 1& 2& 3& 4&5& 6\\
& (.39) & & & (.14)&&\\
V & 1& 2& 3& 4&5& 6\\
& (.82) & & & (.39)&&\\
VI & 1& 2& 3& 4&5& 6\\
& (1.15) & & & (2.65)&&\\
\end{tabular}
\end{center}
}
\caption{My caption} \label{tab:mytab}
\end{table}
BMAcox
Posts: 40
Joined: Sun Dec 23, 2007 12:07 am

Re: Table Size and Figure Spacing in LaTex

Post by BMAcox »

For the graphics figure, how does one modify the resizing code above so that I the graphs and captions fit nicely without caption drooping at the bottom border... And how does one fit more than one external graphic file onto a page? The lines below only inserted the two graphs onto separate pages w. captions hugging the bottom borders.
\begin{figure}[t]
\centering
\includegraphics[width=1.00\textwidth]{Fiigure3.pdf}
\caption{Y(STUDENT'S T) minus Y(GSHD) matched by kurtosis}
\label{fig:Fiigure3}
\end{figure}\begin{figure}[t]
\centering
\includegraphics[width=1\textwidth]{secondgraph.pdf}
\caption{N(0,1) in black, Standardized t(5) in green and GHSD(lambda(5) in blue)}
\label{fig:secondgraph}
\end{figure}

Many thanks
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Table Size and Figure Spacing in LaTex

Post by Juanjo »

Concerning the table, in this part of your code

Code: Select all

\end{tabular}
\end{center}
}
\caption{My caption}\label{tab:mytab}
there is a superfluous brace, the isolated one. Just remove it. By the way, since the whole thing is inside a table environment, you can replace the center environment by \centering. In other words, the following code works:

Code: Select all

\begin{table}
    \centering
    \small\addtolength{\tabcolsep}{-5pt}
	\begin{tabular}{c||c|c|c||c|c||c}
		X& x1 & $x2$ & x3 & x4 & x5&x6\\\hline
		I & 1& 2& 3 & 4 & 5& 6\\
		& (.46) & & & (.16)&&\\
		II&1&2&3 & 4&5&6\\
		& (.82) & & & (.28)&&\\
		III &1&2 &3& 4&5&6\\
		& (.63) & & & (.24)&&\\
		IV & 1& 2& 3& 4&5& 6\\
		& (.39) & & & (.14)&&\\
		V & 1& 2& 3& 4&5& 6\\
		& (.82) & & & (.39)&&\\
		VI & 1& 2& 3& 4&5& 6\\
		& (1.15) & & & (2.65)&&\\ 
	\end{tabular}
	\caption{My caption}	\label{tab:mytab}
\end{table}
Concerning graphics, you can improve your code in two senses:
* It seems you want both graphics in the same page. However, in both figure environments you use the t descriptor, which forces LaTeX to put the graphic at the top of a page. It is better to use the default option (tbp descriptors), so LaTeX have more chances to place both graphics in the same page. You can even include both graphics with a unique figure environment:

Code: Select all

\begin{figure}
  \centering
  \includegraphics{firstgraphicfile}
  \caption{A suitable graphic} \label{fig:one}
  \bigskip
   \includegraphics{secondgraphicfile}
  \caption{Another interesting graphic} \label{fig:two}
\end{figure}
Of couse, you can replace \bigskip with a different command in order to get a proper vertical separation between graphics.

* You can also improve control over the dimensions of the area covered by the graphics. To this end, use the optional argument of \includegraphics. For example, the command

Code: Select all

\includegraphics[width=4cm,height=5cm,keepaspectratio]{graphicsfile}
includes a graphic which occupies, at most, a rectangle of 4 cm x 5 cm. The keepaspectratio key avoids distortion of the image. You can also set relative lengths:

Code: Select all

\includegraphics[width=0.4\textwidth,height=0.3\textheight,keepaspectratio]{graphicsfile}
Here, the width of the graphic is, at most, 40% of \textwidth and its height is not greater than the 30 % of \textheight.

Please, read the epslatex document. You will find there many more tips and hints about managing graphics in LaTeX.
BMAcox
Posts: 40
Joined: Sun Dec 23, 2007 12:07 am

Re: Table Size and Figure Spacing in LaTex

Post by BMAcox »

All the above worked very well. The trim option fixed the problem. Thank you! :P
lamlam80401295
Posts: 3
Joined: Wed Oct 26, 2016 11:42 am

Table Size and Figure Spacing in LaTex

Post by lamlam80401295 »

My problem is solved, that's all I need :D
Thanks a lot
bbrout
Posts: 1
Joined: Mon Nov 25, 2019 8:05 pm

Table Size and Figure Spacing in LaTex

Post by bbrout »

This worked like a charm. Using

\usepackage{longtable}

for long tables had problems with some of your suggestions, but reducing the space between columns worked great. You have to compile the .tex file a couple of times to get the headings and data to all line up. This saves me a lot of headache.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

Table Size and Figure Spacing in LaTex

Post by Stefan Kottwitz »

Hi bbrout,

welcome to the forum! And thanks for sharing your experience!

Stefan
LaTeX.org admin
Post Reply