LaTeX forum ⇒ Graphics, Figures & TablesHow to fit a big table?

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

How to fit a big table?

Postby Mahmudul » Sun Jun 28, 2020 5:32 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[12pt]{article}
  2.  
  3. \usepackage{ltablex,booktabs}
  4. \usepackage{lipsum} %
  5.  
  6. \usepackage{geometry}
  7. \usepackage{pdflscape}
  8.  
  9. \begin{document}
  10. \section{Introduction}
  11. \lipsum[1]
  12.  
  13. \newgeometry{margin=1cm}
  14. \begin{landscape}
  15. \thispagestyle{empty} %% Remove header and footer.
  16. % Table generated by Excel2LaTeX from sheet 'SelectedBonds'
  17. \begin{table}[htbp]
  18. \begin{center}
  19. \footnotesize %% Smaller font size.
  20. \begin{tabular}{|c|c|c|c|c|c|l|c|c|c|}
  21. \toprule
  22. \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}} \\
  23. \midrule
  24. Industrial & 26-Jun-22 & 26-Jun-12 & 6.00E+08 & 6.00E+08 & 10 & FXPV & 2 & A1 & AA- \\
  25. \midrule
  26. Industrial & 7-Aug-20 & 7-Aug-15 & 5.00E+08 & 5.00E+08 & 5 & FXPV & 2 & A1 & AA- \\
  27. \midrule
  28. Industrial & 1-Mar-21 & 17-Feb-11 & 8.00E+08 & 8.00E+08 & 10 & FXPV & 4.25 & A2 & A \\
  29. \midrule
  30. Industrial & 30-Oct-19 & 31-Oct-16 & 7.50E+08 & 7.50E+08 & 3 & FXPV & 1.4 & A2 & A \\
  31. \midrule
  32. Industrial & 27-May-21 & 27-May-11 & 1.25E+09 & 1.25E+09 & 10 & FXPV & 3.9 & A3 & A \\
  33. \midrule
  34. Industrial & 1-Oct-22 & 27-Sep-12 & 1.00E+09 & 1.00E+09 & 10 & FXPV & 2.45 & A1 & A+ \\
  35. \midrule
  36. Industrial & 16-May-22 & 16-May-17 & 6.00E+08 & 6.00E+08 & 5 & FXPV & 2.35 & A1 & A+ \\
  37. \midrule
  38. Industrial & 1-Aug-23 & 31-May-13 & 1.05E+09 & 1.05E+09 & 10 & FXPV & 3.25 & Baa2 & BBB \\
  39. \midrule
  40. Industrial & 15-Oct-20 & 13-Oct-17 & 1.00E+09 & 1.00E+09 & 3 & FXPV & 2.08 & Baa2 & BBB \\
  41. \midrule
  42. Industrial & 23-Nov-20 & 23-Nov-15 & 1.25E+09 & 1.25E+09 & 5 & FXPV & 2.5 & Baa1 & A- \\
  43. \midrule
  44. Industrial & 15-Sep-21 & 9-Sep-11 & 9.00E+08 & 9.00E+08 & 10 & FXPV & 3.35 & Baa1 & A- \\
  45. \midrule
  46. Communication\&Service & 19-Sep-28 & 19-Sep-18 & 2.79E+08 & 2.79E+08 & 10 & FXPV & 4.6 & Baa2 & BBB \\
  47. \midrule
  48. Communication\&Service & 17-Aug-27 & 17-Aug-17 & 7.00E+08 & 7.00E+08 & 10 & FXPV & 4.5 & Baa1 & BBB+ \\
  49. \midrule
  50. Communication\&Service & 17-Feb-23 & 17-Aug-17 & 5.50E+08 & 5.50E+08 & 6 & FXPV & 3.5 & Baa1 & BBB+ \\
  51. \midrule
  52. ConsumerDiscretionary & 1-Jun-23 & 22-May-13 & 3.90E+08 & 3.90E+08 & 10 & FXPV & 2 & Baa1 & BBB+ \\
  53. \midrule
  54. ConsumerDiscretionary & 26-May-22 & 26-May-15 & 8.92E+08 & 8.92E+08 & 7 & FXPV & 1.125 & Baa1 & BBB+ \\
  55. \midrule
  56. ConsumerStaples & 2-Oct-28 & 2-Oct-15 & 5.79E+08 & 5.79E+08 & 13 & FXPV & 1 & A1 & A+ \\
  57. \midrule
  58. ConsumerStaples & 11-Jun-24 & 8-Jun-16 & 3.80E+08 & 3.80E+08 & 8 & FXPV & 3.25 & A1 & A+ \\
  59. \midrule
  60. ConsumerStaples & 16-Aug-22 & 16-Aug-12 & 1.11E+09 & 1.11E+09 & 10 & FXPV & 2 & Aa3 & AA- \\
  61. \midrule
  62. ConsumerStaples & 26-Mar-20 & 26-Mar-10 & 1.00E+09 & 1.00E+09 & 10 & FXPV & 4.5 & A2 & A \\
  63. \midrule
  64. ConsumerStaples & 16-Jul-27 & 18-Jul-17 & 5.52E+08 & 5.52E+08 & 10 & FXPV & 0.52 & Aa2 & AA \\
  65. \midrule
  66. ConsumerStaples & 15-Jul-22 & 18-Jul-17 & 6.44E+08 & 6.44E+08 & 5 & FXPV & 0.183 & Aa2 & AA \\
  67. \midrule
  68. IT & 10-Jun-20 & 10-Jun-16 & 4.53E+08 & 4.53E+08 & 4 & FXPV & 2.65 & Aa1 & AA+ \\
  69. \midrule
  70. IT & 10-Jun-20 & 10-Jun-15 & 2.31E+09 & 2.31E+09 & 5 & FXPV & 0.35 & Aa1 & AA+ \\
  71. \midrule
  72. IT & 10-Jun-26 & 10-Jun-16 & 2.27E+08 & 2.27E+08 & 10 & FXPV & 3.6 & Aa1 & AA+ \\
  73. \midrule
  74. IT & 19-May-21 & 27-Apr-2016 & 8.27E+08 & 8.27E+08 & 5 & FXPV & 3.625 & Aa2 & AA- \\
  75. \midrule
  76. IT & 25-Feb-24 & 27-Apr-2016 & 8.54E+08 & 8.54E+08 & 8 & FXPV & 3.375 & Aa3 & AA \\
  77. \midrule
  78. IT & 1-Nov-21 & 1-Nov-11 & 5.00E+08 & 5.00E+08 & 10 & FXPV & 2.9 & A1 & A \\
  79. \midrule
  80. IT & 27-Jan-20 & 27-Jan-17 & 7.50E+08 & 7.50E+08 & 3 & FXPV & 1.9 & A1 & A \\
  81. \midrule
  82. Health Care & 15-May-22 & 9-May-17 & 7.50E+08 & 7.50E+08 & 5 & FXPV & 2.35 & A2 & A+ \\
  83. \midrule
  84. Health Care & 15-Oct-20 & 25-Oct-17 & 9.00E+08 & 9.00E+08 & 3 & FXPV & 1.95 & A3 & A+ \\
  85. \midrule
  86. Health Care & 15-Mar-23 & 28-Feb-13 & 7.50E+08 & 7.50E+08 & 10 & FXPV & 2.875 & A3 & A+ \\
  87. \midrule
  88. Health Care & 12-Aug-2020 & 05-Oct-2015 & 3.30E+08 & 3.30E+08 & 5 & FXPV & 5.2 & Ba1 & AA \\
  89. \midrule
  90. Health Care & 15-Jun-2023 & 03-Jun-2013 & 1.00E+09 & 1.00E+09 & 10 & FXPV & 3 & A1 & AA \\
  91. \midrule
  92. Health Care & 1-Mar-19 & 1-Mar-16 & 7.00E+08 & 0.00E+00 & 3 & FXPV & 1.125 & Aaa & AAA \\
  93. \midrule
  94. Health Care & 5-Dec-21 & 21-Nov-2014 & 3.50E+08 & 3.50E+08 & 7 & FXPV & 2.45 & Aaa & AAA \\
  95. \midrule
  96. Health Care & 15-May-21 & 20-May-2011 & 4.50E+08 & 4.50E+08 & 10 & FXPV & 3.55 & Aaa & AAA \\
  97. \midrule
  98. Real State & 15-Jan-23 & 28-Feb-2013 & 1.65E+09 & 1.65E+09 & 10 & FXPV & 5.25 & B1 & B- \\
  99. \midrule
  100. Real State & 15-Apr-22 & 15-Apr-2014 & 8.50E+08 & 8.50E+08 & 8 & FXPV & 4.875 & B1 & BB- \\
  101. \midrule
  102. Utility & 15-Jun-2025 & 19-Apr-2013 & 1.74E+07 & 1.74E+07 & 12 & FXPV & 3 & baa1 & BBB \\
  103. \midrule
  104. Utility & 15-Dec-24 & 13-Dec-2012 & 1.46E+07 & 1.46E+07 & 12 & FXPV & 3.05 & baa2 & BBB \\
  105. \midrule
  106. Materials & 8-Nov-19 & 30-Nov-09 & 3.00E+08 & 0.00E+00 & 10 & FXPV & 5.2 & Baa1 & BBB+ \\
  107. \bottomrule
  108. \end{tabular}%
  109. \end{center}
  110. \label{Tab:Sample}%
  111. \end{table}%
  112. \end{landscape}
  113. \restoregeometry
  114. \section{BBBBB}
  115. \lipsum[1]
  116. \end{document}

Bartman
Posts: 75
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Sun Jun 28, 2020 6:53 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. {\small
  2. \begin{longtable}
  3. content
  4. \begin{longtable}}


As an alternative to ltablex I would like to mention xltabular.

Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm

Postby Mahmudul » Sun Jun 28, 2020 3:08 pm

Thanks @Bartman . I am going to try this approach...
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. {\small
  2. \begin{longtable}
  3. content
  4. \begin{longtable}}

Bartman
Posts: 75
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Sun Jun 28, 2020 4:32 pm

Sorry, of course it means

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. {\small
  2. \begin{longtable}{<column format>}
  3. content
  4. \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] [Expand/Collapse] [Download] ({untitled.tex})
  1. {\small
  2. \begin{longtable}{<column format>}
  3. \toprule
  4. head row
  5. \midrule
  6. first content row
  7. \addlinespace
  8. second content row
  9. \bottomrule
  10. \end{longtable}}

Mahmudul
Posts: 7
Joined: Mon May 25, 2020 3:27 pm

Postby Mahmudul » Tue Jun 30, 2020 1:15 am

Thanks a lot @ Bartman

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. {\small
  2. \begin{longtable}{<column format>}
  3. \toprule
  4. head row
  5. \midrule
  6. first content row
  7. \addlinespace
  8. second content row
  9. \bottomrule
  10. \end{longtable}}
[/quote]


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 4 guests