LaTeX forum ⇒ Graphics, Figures & TablesLeft Aligning Text in Longtable Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Left Aligning Text in Longtable

Postby parkerokabe » Fri Apr 26, 2019 3:22 am

Hi! It took me hours how to figure out how to build this table and make it fit in my margins, but now my only issue is that I can't move the headers to the left. It's mostly just the second heading that has a big gap between "Particle" and "Size". I cut out some of the numbers to make it shorter. Any help would be greatly appreciated!

\documentclass[review]{elsarticle}

\usepackage{lineno,hyperref,upgreek,graphicx,chemformula,subfig,longtable,multirow}
\modulolinenumbers[5]
\usepackage{geometry}
\geometry{%
letterpaper, % a4paper
left= 2.54 cm,
right= 2.54 cm,
top= 2.54 cm,
bottom= 2.54 cm,
}

\journal{Journal of Nuclear Materials}

\begin{center}
\begin{longtable}[c]{ p{1cm} p{2.5cm} p{1.5cm} p{1.5cm} p{2cm} p{2cm}}
\caption{Summary of Chlorination Test Results.}\\

& & & & \multicolumn{2}{l}{Conversion (\%)}\\\cline{5-6}
Time (min) & Particle Size Range ($\upmu$m) & Set Point Temp (K) & vol\%Cl\textsubscript{2} & Mass-Based & CIE-Based\\
\hline\hline
\endfirsthead

\hline
& & & & \multicolumn{2}{l}{Conversion (\%)}\\\cline{5-6}
Time (min) & Particle Size Range (~$\upmu$m) & Set Point Temp (K) & vol\%Cl\textsubscript{2} & Mass-Based & CIE-Based\\
\hline\hline
\endhead

\hline
\endfoot

\hline
\endlastfoot

10 & \textless4,000 & 573 & 100 & 62.4 & 58.4\\
20 & \textless4,000 & 573 & 100 & 46.8 & 68.8\\
26 & \textless4,000 & 573 & 100 & 59.6 & 69.0\\
33 & \textless4,000 & 573 & 100 & 72.9 & 66.7\\
10 & Microns-4,000 & 523 & 100 & 66.3 & 85.0\\
30 & Microns-4,000 & 523 & 100 & 66.8 & 78.1\\
60 & Microns-4,000 & 523 & 100 & 65.9 & 85.1\\
90 & Microns-4,000 & 523 & 100 & 71.3 & 84.4\\
60 & 1,000-2,000 & 523 & 100 & 15.2 & 17.1\\
60 & 355-425 & 523 & 100 & 86.3 & 89.2\\
60 & 250-355 & 523 & 100 & 92.6 & 93.1\\
60 & 150-250 & 523 & 100 & 92.3 & 92.0\\
\end{longtable}
\end{center}

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Fri Apr 26, 2019 1:00 pm

The `ragged2e` package has the great `\RaggedRight` macro for such cases:

  1. \documentclass[review]{elsarticle}
  2.  
  3. \usepackage{lineno,hyperref,upgreek,graphicx,chemformula,subfig,longtable,multirow}
  4. \modulolinenumbers[5]
  5. \usepackage{geometry}
  6. \geometry{%
  7. letterpaper, % a4paper
  8. left= 2.54 cm,
  9. right= 2.54 cm,
  10. top= 2.54 cm,
  11. bottom= 2.54 cm,
  12. showframe
  13. }
  14.  
  15. \usepackage{ragged2e}
  16. \usepackage{array}
  17.  
  18. \newcolumntype{R}[1]{>{\RaggedRight}p{#1}}
  19.  
  20. \journal{Journal of Nuclear Materials}
  21.  
  22.  
  23.  
  24. \begin{document}
  25. \begin{longtable}[c]{ R{1cm} R{2.5cm} R{1.5cm} R{1.5cm} R{2cm} R{2cm}}
  26. \caption{Summary of Chlorination Test Results.}\\
  27.  
  28. & & & & \multicolumn{2}{l}{Conversion (\%)}\\\cline{5-6}
  29. Time (min) & Particle Size Range ($\upmu$m) & Set Point Temp~(K) & vol\%Cl\textsubscript{2} & Mass-Based & CIE-Based\\
  30. \hline\hline
  31. \endfirsthead
  32.  
  33. \hline
  34. & & & & \multicolumn{2}{l}{Conversion (\%)}\\\cline{5-6}
  35. Time (min) & Particle Size Range (~$\upmu$m) & Set Point Temp (K) & vol\%Cl\textsubscript{2} & Mass-Based & CIE-Based\\
  36. \hline\hline
  37. \endhead
  38.  
  39. \hline
  40. \endfoot
  41.  
  42. \hline
  43. \endlastfoot
  44.  
  45. 10 & \textless4,000 & 573 & 100 & 62.4 & 58.4\\
  46. 20 & \textless4,000 & 573 & 100 & 46.8 & 68.8\\
  47. 26 & \textless4,000 & 573 & 100 & 59.6 & 69.0\\
  48. 33 & \textless4,000 & 573 & 100 & 72.9 & 66.7\\
  49. 10 & Microns-4,000 & 523 & 100 & 66.3 & 85.0\\
  50. 30 & Microns-4,000 & 523 & 100 & 66.8 & 78.1\\
  51. 60 & Microns-4,000 & 523 & 100 & 65.9 & 85.1\\
  52. 90 & Microns-4,000 & 523 & 100 & 71.3 & 84.4\\
  53. 60 & 1,000-2,000 & 523 & 100 & 15.2 & 17.1\\
  54. 60 & 355-425 & 523 & 100 & 86.3 & 89.2\\
  55. 60 & 250-355 & 523 & 100 & 92.6 & 93.1\\
  56. 60 & 150-250 & 523 & 100 & 92.3 & 92.0\\
  57. \end{longtable}
  58. \end{document}


Screen Shot 2019-04-26 at 21.08.24.png
Screen Shot 2019-04-26 at 21.08.24.png (64.99 KiB) Viewed 111 times
Last edited by user22741 on Fri Apr 26, 2019 9:10 pm, edited 1 time in total.

parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Postby parkerokabe » Fri Apr 26, 2019 9:03 pm

user22741 wrote:The `ragged2e` package has the great `\RaggedRight` macro for such cases:

  1. \documentclass[review]{elsarticle}
  2.  
  3. \usepackage{lineno,hyperref,upgreek,graphicx,chemformula,subfig,longtable,multirow}
  4. \modulolinenumbers[5]
  5. \usepackage{geometry}
  6. \geometry{%
  7. letterpaper, % a4paper
  8. left= 2.54 cm,
  9. right= 2.54 cm,
  10. top= 2.54 cm,
  11. bottom= 2.54 cm,
  12. showframe
  13. }
  14.  
  15. \usepackage{ragged2e}
  16. \usepackage{array}
  17.  
  18. \newcolumntype{R}[1]{>{\RaggedRight}p{#1}}
  19.  
  20. \journal{Journal of Nuclear Materials}
  21.  
  22.  
  23.  
  24. \begin{document}
  25. \begin{longtable}[c]{ R{1cm} R{2.5cm} R{1.5cm} R{1.5cm} R{2cm} R{2cm}}
  26. \caption{Summary of Chlorination Test Results.}\\
  27.  
  28. & & & & \multicolumn{2}{l}{Conversion (\%)}\\\cline{5-6}
  29. Time (min) & Particle Size Range ($\upmu$m) & Set Point Temp~(K) & vol\%Cl\textsubscript{2} & Mass-Based & CIE-Based\\
  30. \hline\hline
  31. \endfirsthead
  32.  
  33. \hline
  34. & & & & \multicolumn{2}{l}{Conversion (\%)}\\\cline{5-6}
  35. Time (min) & Particle Size Range (~$\upmu$m) & Set Point Temp (K) & vol\%Cl\textsubscript{2} & Mass-Based & CIE-Based\\
  36. \hline\hline
  37. \endhead
  38.  
  39. \hline
  40. \endfoot
  41.  
  42. \hline
  43. \endlastfoot
  44.  
  45. 10 & \textless4,000 & 573 & 100 & 62.4 & 58.4\\
  46. 20 & \textless4,000 & 573 & 100 & 46.8 & 68.8\\
  47. 26 & \textless4,000 & 573 & 100 & 59.6 & 69.0\\
  48. 33 & \textless4,000 & 573 & 100 & 72.9 & 66.7\\
  49. 10 & Microns-4,000 & 523 & 100 & 66.3 & 85.0\\
  50. 30 & Microns-4,000 & 523 & 100 & 66.8 & 78.1\\
  51. 60 & Microns-4,000 & 523 & 100 & 65.9 & 85.1\\
  52. 90 & Microns-4,000 & 523 & 100 & 71.3 & 84.4\\
  53. 60 & 1,000-2,000 & 523 & 100 & 15.2 & 17.1\\
  54. 60 & 355-425 & 523 & 100 & 86.3 & 89.2\\
  55. 60 & 250-355 & 523 & 100 & 92.6 & 93.1\\
  56. 60 & 150-250 & 523 & 100 & 92.3 & 92.0\\
  57. \end{longtable}
  58. \end{document}



I added the lines
\usepackage{ragged2e}
\usepackage{array}

\newcolumntype{R}[1]{>{\RaggedRight}p{#1}}

but nothing changed. Am I missing something?

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Fri Apr 26, 2019 9:07 pm

The table has also to use the new column type.

parkerokabe
Posts: 7
Joined: Thu Apr 25, 2019 5:45 pm

Postby parkerokabe » Fri Apr 26, 2019 10:47 pm

user22741 wrote:The table has also to use the new column type.


It worked! Thank you so much!


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 4 guests