1

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.072\textwidth}|
                                 *{32}{p{0.011\textwidth}|}
                                p{0.069\textwidth}|}  



\hline  
A & \multicolumn{18}  {m{0.198\textwidth}|}   {A} 
  & \multicolumn{9}  {m{0.099\textwidth}|}   {A}
  & \multicolumn{5}  {m{0.055\textwidth}|}   {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}
5
  • Why are you specifying a specific width when you're working with multicolumn anyways? – Steradiant Jun 24 '20 at 6:47
  • 1
    tabularx needs al teasl one X type column to work properly. If you just use p type columns, there is no reason to use tabularx. – leandriis Jun 24 '20 at 7:03
  • Please add some more information on the desired output. Do you need linebreaks inside of table cells? If so, p type columns can be a good choice. If not, you could also ge for w type columns (from the array package). Are the numbers in your table the actual entries or will you replace them later? With what kind of contents will they be replaced with? Will you add more rows? What will their contents look like? Do you need linebreaks inside of the \multicolumn cells or just a single line? How will the contents of the "Ref" column look like? Author year citations or numeric ones?... – leandriis Jun 24 '20 at 7:06
  • Please make your code compilable. Several packages such as makecell and tabularxare clearly missing. \start{document} should be replaced with \begin{document}. Also, you can't use \begin{landscape} before \begin{document}. Please fix that. – leandriis Jun 24 '20 at 7:08
  • why are you using tabularx??? as the only point of that is to vary the column width automatically, just use a normal tabular. – David Carlisle Jun 24 '20 at 9:31
0

You need at least one X column:

\documentclass[twocolumn]{svjour3}          % twocolumn
\usepackage{tabularx,pdflscape}
\begin{document}
\begin{landscape}
\small\noindent
\begin{tabularx}{\linewidth}{|X|*{32}{p{0.011\textwidth}|}X|}  \hline  
A & \multicolumn{18}  {m{0.198\textwidth}|}   {A} 
  & \multicolumn{9}  {m{0.099\textwidth}|}   {A}
  & \multicolumn{5}  {m{0.055\textwidth}|}   {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{landscape}

\end{document}

enter image description here

2
  • The code did not run please check it again – stevGates Jun 24 '20 at 13:29
  • ?? My image is the output of the pdflatexrun ... – user187802 Jun 24 '20 at 14:28
0

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.025\linewidth} to p{0.025\linewidth}, 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.03\textwidth}|
                                 *{32}{wc{0.025\textwidth}|}
                                wc{0.069\textwidth}|}  



\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}
1
  • 1
    I will appreciate if the downvoter could justify the down vote. Difficult to see what is wrong with the answer. – Sveinung Jun 24 '20 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.