TransWikia.com

Fitting a table within the text

TeX - LaTeX Asked on March 11, 2021

I am trying to create a table for my first appendix but I am facing the two following problems:

  • I would like to align the text of the first column to the left.
  • The columns are not equally distributed along the width of the text.

I show you here the code I am using and the result of it:

usepackage{float}
usepackage{adjustbox}
usepackage{multicol}
usepackage{longtable}

renewcommand*descriptionlabel[1]{hspaceleftmargin$#1$}
usepackage{array,ragged2e}
newcolumntype{C}{>{Centeringhspace{0pt}}p{0.1textwidth}}
usepackage[output-decimal-marker={,}]{siunitx}
usepackage{booktabs, makecell, tabularx}
newcolumntype{L}{>{raggedrightarraybackslash}X}
newcolumntype{P}[1]{>{centeringarraybackslash}p{#1}}


appendix
section{Suppliers´ production capacities}
begin{table}[ht]
setcellgapes{3pt}
makegapedcells
begin{tabularx}{linewidth}{@{}ccL@{}}
toprule
Facility Name & Year & Overall Capacity 
midrule
Text    & 2020                              & 1.500                                                    
Text   & 2020                              & 1.600                                                    
Text          & 2020                              & 2.500                                                    
                               
 bottomrule
end{tabularx}
  caption{Supplier facilities´ production capacities}
end{table}

enter image description here
I would be extremely grateful if someone can help me with this

One Answer

I would like to align the text of the first column to the left.

Just change

begin{tabularx}{linewidth}{@{}ccL@{}}

to

begin{tabularx}{linewidth}{@{}lcL@{}}

The columns are not equally distributed along the width of the text.

How about

begin{tabularx}{linewidth}{@{}LLL@{}}

i.e., use the L column type for all three columns.

enter image description here

documentclass{article}
usepackage{tabularx,ragged2e,booktabs}
newcolumntype{L}{>{RaggedRight}X}

begin{document}
begin{table}[ht]
begin{tabularx}{linewidth}{@{} LLL @{}}
toprule
Facility Name & Year & Overall Capacity 
midrule
Text & 2020 & 1.500  
Text & 2020 & 1.600  
Text & 2020 & 2.500  
bottomrule
end{tabularx}
caption{Supplier facilities' production capacities}
end{table}
end{document}

Correct answer by Mico on March 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP