Graphics, Figures & TablesHow to fit a big table?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm

How to fit a big table?

Post by Mahmudul »

Hi, I have a table which is pretty big in terms of length and width. I have been using \resizebox option to fit the table. It does work well. However, the size of the fonts becomes so small can't read it properly. Hence, I have been trying another option to make it more readable. The code along with tables that I am trying to fit is given below. I am trying to have a bigger page in the middle of the chapter for the table. Problem is that It doesn't fit the full table (lower part of the table missing). How can I let the table continue to the next page so that the full table appears nicely? or Is there any other better option which will be suitable for this table?

Code: Select all

\documentclass[12pt]{article}

\usepackage{ltablex,booktabs}
\usepackage{lipsum} %

\usepackage{geometry}
\usepackage{pdflscape}

\begin{document}
\section{Introduction}
\lipsum[1]

\newgeometry{margin=1cm}
\begin{landscape}
\thispagestyle{empty} %% Remove header and footer.
% Table generated by Excel2LaTeX from sheet 'SelectedBonds'
\begin{table}[htbp]
\begin{center}
\footnotesize %% Smaller font size.	
\begin{tabular}{|c|c|c|c|c|c|l|c|c|c|}
	\toprule
	\multicolumn{1}{|p{11.145em}|}{\textbf{BBBBB}} & \multicolumn{1}{p{6.285em}|}{\textbf{AAAAA }} & \multicolumn{1}{p{6.5em}|}{\textbf{ccccc}} & \multicolumn{1}{p{4.57em}|}{\textbf{dddd ddddd}} & \multicolumn{1}{p{5.93em}|}{\textbf{fffff fffffff }} & \multicolumn{1}{p{5.93em}|}{\textbf{gggggg}} & \multicolumn{1}{p{3.715em}|}{\textbf{hhhhh iiiii}} & \multicolumn{1}{p{4.215em}|}{\textbf{jjjjjj jjjjjjj}} & \multicolumn{1}{p{4.355em}|}{\textbf{nnnnn oooooo}} & \multicolumn{1}{p{3.355em}|}{\textbf{pp qqqqqq}} \\
	\midrule
	Industrial & 26-Jun-22 & 26-Jun-12 & 6.00E+08 & 6.00E+08 & 10    & FXPV  & 2     & A1    & AA- \\
	\midrule
	 Industrial & 7-Aug-20 & 7-Aug-15 & 5.00E+08 & 5.00E+08 & 5     & FXPV  & 2     & A1    & AA- \\
	\midrule
	Industrial & 1-Mar-21 & 17-Feb-11 & 8.00E+08 & 8.00E+08 & 10    & FXPV  & 4.25  & A2    & A \\
	\midrule
	Industrial & 30-Oct-19 & 31-Oct-16 & 7.50E+08 & 7.50E+08 & 3     & FXPV  & 1.4   & A2    & A \\
	\midrule
	Industrial & 27-May-21 & 27-May-11 & 1.25E+09 & 1.25E+09 & 10    & FXPV  & 3.9   & A3    & A \\
	\midrule
	Industrial & 1-Oct-22 & 27-Sep-12 & 1.00E+09 & 1.00E+09 & 10    & FXPV  & 2.45  & A1    & A+ \\
	\midrule
	Industrial & 16-May-22 & 16-May-17 & 6.00E+08 & 6.00E+08 & 5     & FXPV  & 2.35  & A1    & A+ \\
	\midrule
	Industrial & 1-Aug-23 & 31-May-13 & 1.05E+09 & 1.05E+09 & 10    & FXPV  & 3.25  & Baa2  & BBB \\
	\midrule
	Industrial & 15-Oct-20 & 13-Oct-17 & 1.00E+09 & 1.00E+09 & 3     & FXPV  & 2.08  & Baa2  & BBB \\
	\midrule
    Industrial & 23-Nov-20 & 23-Nov-15 & 1.25E+09 & 1.25E+09 & 5     & FXPV  & 2.5   & Baa1  & A- \\
	\midrule
	Industrial & 15-Sep-21 & 9-Sep-11 & 9.00E+08 & 9.00E+08 & 10    & FXPV  & 3.35  & Baa1  & A- \\
	\midrule
	Communication\&Service & 19-Sep-28 & 19-Sep-18 & 2.79E+08 & 2.79E+08 & 10    & FXPV  & 4.6   & Baa2  & BBB \\
	\midrule
	Communication\&Service & 17-Aug-27 & 17-Aug-17 & 7.00E+08 & 7.00E+08 & 10    & FXPV  & 4.5   & Baa1  & BBB+ \\
	\midrule
	Communication\&Service & 17-Feb-23 & 17-Aug-17 & 5.50E+08 & 5.50E+08 & 6     & FXPV  & 3.5   & Baa1  & BBB+ \\
	\midrule
	ConsumerDiscretionary & 1-Jun-23 & 22-May-13 & 3.90E+08 & 3.90E+08 & 10    & FXPV  & 2     & Baa1  & BBB+ \\
	\midrule
	ConsumerDiscretionary & 26-May-22 & 26-May-15 & 8.92E+08 & 8.92E+08 & 7     & FXPV  & 1.125 & Baa1  & BBB+ \\
	\midrule
	ConsumerStaples & 2-Oct-28 & 2-Oct-15 & 5.79E+08 & 5.79E+08 & 13    & FXPV  & 1     & A1    & A+ \\
	\midrule
	ConsumerStaples & 11-Jun-24 & 8-Jun-16 & 3.80E+08 & 3.80E+08 & 8     & FXPV  & 3.25  & A1    & A+ \\
	\midrule
	ConsumerStaples & 16-Aug-22 & 16-Aug-12 & 1.11E+09 & 1.11E+09 & 10    & FXPV  & 2     & Aa3   & AA- \\
	\midrule
	ConsumerStaples & 26-Mar-20 & 26-Mar-10 & 1.00E+09 & 1.00E+09 & 10    & FXPV  & 4.5   & A2    & A \\
	\midrule
	ConsumerStaples & 16-Jul-27 & 18-Jul-17 & 5.52E+08 & 5.52E+08 & 10    & FXPV  & 0.52  & Aa2   & AA \\
	\midrule
	ConsumerStaples & 15-Jul-22 & 18-Jul-17 & 6.44E+08 & 6.44E+08 & 5     & FXPV  & 0.183 & Aa2   & AA \\
	\midrule
	IT    & 10-Jun-20 & 10-Jun-16 & 4.53E+08 & 4.53E+08 & 4     & FXPV  & 2.65  & Aa1   & AA+ \\
	\midrule
	IT    & 10-Jun-20 & 10-Jun-15 & 2.31E+09 & 2.31E+09 & 5     & FXPV  & 0.35  & Aa1   & AA+ \\
	\midrule
	IT    & 10-Jun-26 & 10-Jun-16 & 2.27E+08 & 2.27E+08 & 10    & FXPV  & 3.6   & Aa1   & AA+ \\
	\midrule
	IT    & 19-May-21 & 27-Apr-2016 & 8.27E+08 & 8.27E+08 & 5     & FXPV  & 3.625 & Aa2   & AA- \\
	\midrule
	IT    & 25-Feb-24 & 27-Apr-2016 & 8.54E+08 & 8.54E+08 & 8     & FXPV  & 3.375 & Aa3   & AA \\
	\midrule
	IT    & 1-Nov-21 & 1-Nov-11 & 5.00E+08 & 5.00E+08 & 10    & FXPV  & 2.9   & A1    & A \\
	\midrule
	IT    & 27-Jan-20 & 27-Jan-17 & 7.50E+08 & 7.50E+08 & 3     & FXPV  & 1.9   & A1    & A \\
	\midrule
	Health Care & 15-May-22 & 9-May-17 & 7.50E+08 & 7.50E+08 & 5     & FXPV  & 2.35  & A2    & A+ \\
	\midrule
	Health Care & 15-Oct-20 & 25-Oct-17 & 9.00E+08 & 9.00E+08 & 3     & FXPV  & 1.95  & A3    & A+ \\
	\midrule
	Health Care & 15-Mar-23 & 28-Feb-13 & 7.50E+08 & 7.50E+08 & 10    & FXPV  & 2.875 & A3    & A+ \\
	\midrule
	Health Care & 12-Aug-2020 & 05-Oct-2015 & 3.30E+08 & 3.30E+08 & 5     & FXPV  & 5.2   & Ba1   & AA \\
	\midrule
	Health Care & 15-Jun-2023 & 03-Jun-2013 & 1.00E+09 & 1.00E+09 & 10    & FXPV  & 3     & A1    & AA \\
	\midrule
	Health Care & 1-Mar-19 & 1-Mar-16 & 7.00E+08 & 0.00E+00 & 3     & FXPV  & 1.125 & Aaa   & AAA \\
	\midrule
	Health Care & 5-Dec-21 & 21-Nov-2014 & 3.50E+08 & 3.50E+08 & 7     & FXPV  & 2.45  & Aaa   & AAA \\
	\midrule
	Health Care & 15-May-21 & 20-May-2011 & 4.50E+08 & 4.50E+08 & 10    & FXPV  & 3.55  & Aaa   & AAA \\
	\midrule
	Real State & 15-Jan-23 & 28-Feb-2013 & 1.65E+09 & 1.65E+09 & 10    & FXPV  & 5.25  & B1    & B- \\
	\midrule
	Real State & 15-Apr-22 & 15-Apr-2014 & 8.50E+08 & 8.50E+08 & 8     & FXPV  & 4.875 & B1    & BB- \\
	\midrule
	Utility & 15-Jun-2025 & 19-Apr-2013 & 1.74E+07 & 1.74E+07 & 12    & FXPV  & 3     & baa1  & BBB \\
	\midrule
	Utility & 15-Dec-24 & 13-Dec-2012 & 1.46E+07 & 1.46E+07 & 12    & FXPV  & 3.05  & baa2  & BBB \\
	\midrule
	Materials & 8-Nov-19 & 30-Nov-09 & 3.00E+08 & 0.00E+00 & 10    & FXPV  & 5.2   & Baa1  & BBB+ \\
	\bottomrule
		\end{tabular}%
\end{center}
	\label{Tab:Sample}%
\end{table}%
\end{landscape}
\restoregeometry
\section{BBBBB}
\lipsum[1]
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Bartman
Posts: 367
Joined: Fri Jan 03, 2020 2:39 pm

How to fit a big table?

Post by Bartman »

Please read the documentation for the longtable package (which will be loaded by ltablex in your preamble) or a LaTeX introduction on how you can create multi-page tables. A longtable does not float, does not need the table environment and is not compatible with it. The already centered environment of the longtable package should also suffice for the \small font size command.

The font size can be limited by a group.

A possible approach:

Code: Select all

{\small
\begin{longtable}
content
\begin{longtable}}
As an alternative to ltablex I would like to mention xltabular.
Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm

How to fit a big table?

Post by Mahmudul »

Thanks @Bartman . I am going to try this approach...

Code: Select all

{\small
\begin{longtable}
content
\begin{longtable}}
Bartman
Posts: 367
Joined: Fri Jan 03, 2020 2:39 pm

How to fit a big table?

Post by Bartman »

Sorry, of course it means

Code: Select all

{\small
\begin{longtable}{<column format>}
content
\end{longtable}}% wrong command replaced
In addition, the vertical lines should be avoided when using the commands from booktabs. I recommend to use \addlinespace commands instead of the \midrule commands between the lines of the table content.

Code: Select all

{\small
\begin{longtable}{<column format>}
\toprule
head row
\midrule
first content row 
\addlinespace
second content row
\bottomrule
\end{longtable}}
Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm

How to fit a big table?

Post by Mahmudul »

Thanks a lot @ Bartman

Code: Select all

{\small
\begin{longtable}{<column format>}
\toprule
head row
\midrule
first content row 
\addlinespace
second content row
\bottomrule
\end{longtable}}
[/quote]
Post Reply