LaTeX forum ⇒ Graphics, Figures & TablesVertical spacing problem in a big table Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
Cham
Posts: 858
Joined: Sat Apr 02, 2011 4:06 pm

Vertical spacing problem in a big table  Topic is solved

Postby Cham » Fri May 11, 2018 4:08 pm

I'm having a problem with vertical spacings in a big tablularx which doesn't fit well on a single page. The code below reproduces exactly the problem. What would be the simplest solution?

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[french]{babel}
  5. \usepackage{microtype}
  6. \usepackage{enumitem}
  7. \setlist[enumerate]{label*=\arabic*.}
  8. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  9. \usepackage{hhline}
  10. \usepackage{tabularx}
  11.  
  12. \begin{document}
  13.  
  14. \section{Some title}
  15.  
  16. \medskip
  17.  
  18. \begin{center}
  19. \small
  20. \renewcommand{\arraystretch}{1.5}
  21. \begin{tabularx}{\textwidth}{|XX|}
  22. \hline
  23. \multicolumn{1}{|>{\centering}X|}{\textsf{WORD1}}
  24. & \multicolumn{1}{>{\centering}X|}{\textsf{WORD2}}
  25. \\ \hhline{==}
  26. \textbf{\textsf{Subtitle1}}
  27.  
  28. \medskip
  29.  
  30. \raggedright
  31. Blabla bla bla bla blablabla bla bla blabla bla blabla bla bla bla blablabla blabla blabla blabla.
  32. &
  33. \\ \hhline{==}
  34. \textbf{\textsf{Subtitle2}}
  35.  
  36. \medskip
  37.  
  38. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  39. \setcounter{enumi}{0}
  40. \raggedright
  41. \item Blabla bla bla bla blablabla bla.
  42. \end{enumerate}
  43. &
  44. \textbf{\textsf{Subtitle3}}
  45.  
  46. \medskip
  47.  
  48. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=1.\arabic*]
  49. \setcounter{enumi}{0}
  50. \raggedright
  51. \item Boring comment 1.
  52. \item Boring comment 2. Blablabla blabla blabla bla bla bla blabla blablabla blabla bla bla bla blabla blablabla bla.
  53. \item Boring comment 3. Blablabla blabla blabla bla bla blabla bla bla blablabla blabla.
  54. \item Boring comment 4.
  55. \end{enumerate}
  56. \\
  57. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  58. \setcounter{enumi}{1}
  59. \raggedright
  60. \item Blabla bla bla bla blablabla bla.
  61. \end{enumerate}
  62. &
  63. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=2.\arabic*]
  64. \setcounter{enumi}{0}
  65. \raggedright
  66. \item Boring comment 1. Blabla bla bla bla blabla blabla.
  67. \item Boring comment 2. Bla bla blabla blabla bla bla. Blabla bla
  68. \item Boring comment 3. Bla bla bla. Blabla blabla bla bla blabla, bla bla bla blabla blablabla.
  69. \item Boring comment 4. Bla blablabla blabla blabla bla bla bla.
  70. \end{enumerate}
  71. \\
  72. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  73. \setcounter{enumi}{2}
  74. \raggedright
  75. \item Blabla bla bla bla blablabla bla.
  76. \end{enumerate}
  77. &
  78. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=3.\arabic*]
  79. \setcounter{enumi}{0}
  80. \raggedright
  81. \item Boring comment 1.
  82. \item Boring comment 2. Blabla blablablablabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla.
  83. \item Boring comment 3. Blabla blablablablabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla.
  84. \item Boring comment 4. Blabla blablablablabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla.
  85. \end{enumerate}
  86. \\
  87. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  88. \setcounter{enumi}{3}
  89. \raggedright
  90. \item Blabla bla bla bla blablabla bla.
  91. \end{enumerate}
  92. &
  93. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=4.\arabic*]
  94. \setcounter{enumi}{0}
  95. \raggedright
  96. \item Boring comment 1. Blabla blablabla blabla blabla blabla bla bla, bla bla.
  97. \item Boring comment 3. Blabla blablabla blabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla. Bla bla bla blablabla bla bla.
  98. \end{enumerate}
  99. \\
  100. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  101. \setcounter{enumi}{4}
  102. \raggedright
  103. \item Blabla bla bla bla blablabla bla.
  104. \end{enumerate}
  105. &
  106. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=5.\arabic*]
  107. \setcounter{enumi}{0}
  108. \raggedright
  109. \item Boring comment 1.
  110. \item Boring comment 2.
  111. \item Boring comment 3.
  112. \item Boring comment 4.
  113. \end{enumerate}
  114. \\ \hline
  115. \end{tabularx}
  116. \end{center}
  117.  
  118. \end{document}


The vertical spacing between each numbered paragraph is clearly too large. How to reduce it? I could use the command \\[negative spacing], but I'm not sure this is the best solution.

I could also reduce the text size, but I believe there's a way to fit the whole text in a single page without reducing the font. What would you suggest?

User avatar
Johannes_B
Site Moderator
Posts: 3725
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Fri May 11, 2018 6:15 pm

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[french]{babel}
  5. \usepackage{microtype}
  6. \usepackage{enumitem}
  7. \setlist[enumerate]{label*=\arabic*.}
  8. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  9. \usepackage{hhline}
  10. \usepackage{tabularx}
  11. \usepackage{showframe}
  12.  
  13. \begin{document}
  14.  
  15. \section{Some title}
  16.  
  17. \smallskip
  18.  
  19. \bgroup\noindent%
  20. \setlist[enumerate]{nosep,topsep=0pt,partopsep=0pt}%
  21. \small%
  22. %\renewcommand{\arraystretch}{1.5}%<===== ?
  23. \enlargethispage{\baselineskip}%
  24. \begin{tabularx}{\textwidth}{|XX|}
  25. \hline
  26. \multicolumn{1}{|>{\centering}X|}{\textsf{WORD1}}
  27. & \multicolumn{1}{>{\centering}X|}{\textsf{WORD2}}
  28. \\ \hhline{==}
  29. \textbf{\textsf{Subtitle1}}
  30.  
  31. \smallskip
  32.  
  33. \raggedright
  34. Blabla bla bla bla blablabla bla bla blabla bla blabla bla bla bla blablabla blabla blabla blabla.
  35. &
  36. \\ \hhline{==}
  37. \textbf{\textsf{Subtitle2}}
  38.  
  39. \smallskip
  40.  
  41. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  42. \setcounter{enumi}{0}
  43. \raggedright
  44. \item Blabla bla bla bla blablabla bla.
  45. \end{enumerate}
  46. &
  47. \textbf{\textsf{Subtitle3}}
  48.  
  49. \smallskip
  50.  
  51. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=1.\arabic*]
  52. \setcounter{enumi}{0}
  53. \raggedright
  54. \item Boring comment 1.
  55. \item Boring comment 2. Blablabla blabla blabla bla bla bla blabla blablabla blabla bla bla bla blabla blablabla bla.
  56. \item Boring comment 3. Blablabla blabla blabla bla bla blabla bla bla blablabla blabla.
  57. \item Boring comment 4.
  58. \end{enumerate}
  59. \\
  60. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,nosep]
  61. \setcounter{enumi}{1}
  62. \raggedright
  63. \item Blabla bla bla bla blablabla bla. WOMBAT
  64. \end{enumerate}
  65. &
  66. \begin{enumerate}
  67. \setcounter{enumi}{0}
  68. \raggedright
  69. \item Boring comment 1. Blabla bla bla bla blabla blabla.
  70. \item Boring comment 2. Bla bla blabla blabla bla bla. Blabla bla
  71. \item Boring comment 3. Bla bla bla. Blabla blabla bla bla blabla, bla bla bla blabla blablabla.
  72. \item Boring comment 4. Bla blablabla blabla blabla bla bla bla.
  73. \end{enumerate}
  74. \\
  75. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  76. \setcounter{enumi}{2}
  77. \raggedright
  78. \item Blabla bla bla bla blablabla bla.
  79. \end{enumerate}
  80. &
  81. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=3.\arabic*]
  82. \setcounter{enumi}{0}
  83. \raggedright
  84. \item Boring comment 1.
  85. \item Boring comment 2. Blabla blablablablabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla.
  86. \item Boring comment 3. Blabla blablablablabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla.
  87. \item Boring comment 4. Blabla blablablablabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla.
  88. \end{enumerate}
  89. \\
  90. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  91. \setcounter{enumi}{3}
  92. \raggedright
  93. \item Blabla bla bla bla blablabla bla.
  94. \end{enumerate}
  95. &
  96. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=4.\arabic*]
  97. \setcounter{enumi}{0}
  98. \raggedright
  99. \item Boring comment 1. Blabla blablabla blabla blabla blabla bla bla, bla bla.
  100. \item Boring comment 3. Blabla blablabla blabla blabla blabla bla bla, bla bla blabla. Blabla blabla blablabla bla bla. Bla bla bla blablabla bla bla.
  101. \end{enumerate}
  102. \\
  103. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm]
  104. \setcounter{enumi}{4}
  105. \raggedright
  106. \item Blabla bla bla bla blablabla bla.
  107. \end{enumerate}
  108. &
  109. \begin{enumerate}[itemsep=1ex,leftmargin=0.5cm,label*=5.\arabic*]
  110. \setcounter{enumi}{0}
  111. \raggedright
  112. \item Boring comment 1.
  113. \item Boring comment 2.
  114. \item Boring comment 3.
  115. \item Boring comment 4.
  116. \end{enumerate}
  117. \\ \hline
  118. \end{tabularx}
  119. \egroup
  120.  
  121. \end{document}


But maybe getting over to longtable might be a better solution.
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
Cham
Posts: 858
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Fri May 11, 2018 11:40 pm

Thanks a lot for the reply.

Why the \bgroup\noindent%, instead of \begin{center}...\end{center} ?

Why the % after \small ?

I'm using the command \renewcommand{\arraystretch}{1.5} because the vertical spacements are better looking around the titles. The frame gets too tight without that command.

I mostly solved my issue by using the font size \footnotesize, and \\[-18pt] to reduce the vertical spacings of the enumerates. Is that a proper solution ?

User avatar
Johannes_B
Site Moderator
Posts: 3725
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat May 12, 2018 6:35 am

A center environment adds vertical space at the beginning and ending. Your table has textwidth, there is nothong to center anyway.

The percent signs comment out the line breaks, which are treated. As spaces. That you should know.

As long as you are fully aware of why you are doing something, it cannot be a wrong solution.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests