TransWikia.com

How to fix the width of columns in tabularx table?

TeX - LaTeX Asked on September 2, 2021

I am working on Springer template, I want to create a tabularx table and I to fix the width of the columns. I work on landscape page and I want create a table like that table which contains 34 columns:

enter image description here

But the problem is that, I can’t fix the width of tables, the results of my table :

enter image description here

and that’s my code:

documentclass[twocolumn]{svjour3}          % twocolumn

begin{landscape}



start{document}
begin{table} [htp]

setcellgapes{3pt}
centering
scriptsize
makegapedcells
%0.0255
%0.0745
%0.0145

begin{tabularx} {linewidth}{| p{0.072textwidth}|
                                 *{32}{p{0.011textwidth}|}
                                p{0.069textwidth}|}  



hline  
A & multicolumn{18}  {m{0.198textwidth}|}   {A} 
  & multicolumn{9}  {m{0.099textwidth}|}   {A}
  & multicolumn{5}  {m{0.055textwidth}|}   {A}
  &Ref


hline
A & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26&27&28&29&30&31&32&Ref


hline

end{tabularx}
end{table}

end{landscape}


end{document}

2 Answers

You may use tabular*, set the tabcolsep to 0pt, and let tabular* calculate the width by using @{extracolsep{fill}}. If you need multi line cells, just change wc{0.025linewidth} to p{0.025linewidth}, and similar for other other length.

enter image description here

documentclass[twocolumn]{article}          % twocolumn

usepackage{array, pdflscape}


begin{document}
begin{landscape}
begin{table*} [!htp]

footnotesize
setlength{tabcolsep}{0pt}

begin{tabular*} {linewidth}{@{extracolsep{fill}}| wc{0.03textwidth}|
                                 *{32}{wc{0.025textwidth}|}
                                wc{0.069textwidth}|}  



hline  
A & multicolumn{18}  {c|}   {A} 
  & multicolumn{9}  {c|}   {A}
  & multicolumn{5}  {c|}   {A}
  &Ref


hline
A & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26&27&28&29&30&31&32&Ref


hline

end{tabular*}
end{table*}

end{landscape}


end{document}

Answered by Sveinung on September 2, 2021

You need at least one X column:

documentclass[twocolumn]{svjour3}          % twocolumn
usepackage{tabularx,pdflscape}
begin{document}
begin{landscape}
smallnoindent
begin{tabularx}{linewidth}{|X|*{32}{p{0.011textwidth}|}X|}  hline  
A & multicolumn{18}  {m{0.198textwidth}|}   {A} 
  & multicolumn{9}  {m{0.099textwidth}|}   {A}
  & multicolumn{5}  {m{0.055textwidth}|}   {A}
  &Refhline
A & 
1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26&27&28&29&30&31&32&Refhline
end{tabularx}
end{landscape}

end{document}

enter image description here

Answered by user187802 on September 2, 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