0

I'm very new to Latex and I'm struggling with a table (and afraid I'll be needing more tables in the future). I've seen some similar questions but can't clear on what my problem is and how to fix it.

I created a table with nine columns 8 rows, that have several cell combinations to fit various texts. The table looks like this in Excel:

enter image description here

That fits to a landscape A4 page. When I exported to Latex using the Excel2Latex plugin it generates the following code:

    % Table generated by Excel2LaTeX from sheet 'TABLA_Resumen_casos'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{|p{6.285em}|l|l|l|p{8.785em}|l|l|l|p{8.785em}|}
    \hline
    \multicolumn{1}{|l|}{} & \multicolumn{4}{p{26.64em}|}{\textit{Baccharis halimifolia}} & \multicolumn{4}{p{26.355em}|}{\textit{Juncus maritimus}} \bigstrut\\
    \hline
    \multicolumn{1}{|l|}{} & \multicolumn{1}{c|}{\multirow{2}[4]{*}{Algorithms}} & \multicolumn{2}{p{12.5em}|}{\# Presences \& PA} & \multirow{2}[4]{*}{Variables} & \multicolumn{1}{c|}{\multirow{2}[4]{*}{Algorithms}} & \multicolumn{2}{p{12.215em}|}{\# Presences \& PA} & \multirow{2}[4]{*}{Variables} \bigstrut\\
\cline{1-1}\cline{3-4}\cline{7-8}    \multicolumn{1}{|l|}{} &     & \multicolumn{1}{p{6.285em}|}{2005 (Train)} & \multicolumn{1}{p{6.215em}|}{2016 (Eval.)} & \multicolumn{1}{c|}{} &     & \multicolumn{1}{p{5.785em}|}{2005 (Train)} & \multicolumn{1}{p{6.43em}|}{2016 (Eval.)} & \multicolumn{1}{c|}{} \bigstrut\\
    \hline
    Physiological & \multicolumn{1}{p{5.355em}|}{Cubic RBF} & \multicolumn{1}{p{6.285em}|}{ - } & \multicolumn{1}{p{6.215em}|}{ -} & Survival map (based on experimental data) & \multicolumn{1}{p{5.355em}|}{Cubic RBF} & \multicolumn{1}{p{5.785em}|}{ -} & \multicolumn{1}{p{6.43em}|}{ -} & Survival map (based on experimental data) \bigstrut\\
    \hline
    Basic SDM & \multicolumn{1}{l|}{\multirow{4}[8]{*}{GAM, ANN, FDA, RF, Maxent}} & \multicolumn{1}{l|}{\multirow{4}[8]{*}{340 Presences    340 PA (10 sets)             }} & \multicolumn{1}{l|}{\multirow{4}[8]{*}{106 presences 424 PA}} & \multirow{3}[6]{*}{\% of time immersed, mean dry hours, sd dry hours, soil type, riparian forest. } & \multicolumn{1}{l|}{\multirow{4}[8]{*}{GLM, CTA, FDA, RF, Maxent}} & \multicolumn{1}{l|}{\multirow{4}[8]{*}{90 Presences    90 PA (10 sets)           }} & \multicolumn{1}{l|}{\multirow{4}[8]{*}{265 Presences  1060 PA}} & \multirow{3}[6]{*}{\% of time immersed, mean dry hours, sd dry hours, soil type, maximum velocity. } \bigstrut\\
\cline{1-1}    Binary Conservative &     &     &     & \multicolumn{1}{l|}{} &     &     &     & \multicolumn{1}{l|}{} \bigstrut\\
\cline{1-1}    Binary Permissive &     &     &     & \multicolumn{1}{l|}{} &     &     &     & \multicolumn{1}{l|}{} \bigstrut\\
\cline{1-1}\cline{5-5}\cline{9-9}    Internal  &     &     &     & Survival map, maximum salinity,  mean dry hours, sd dry hours, soil type, riparian forest.  &     &     &     & Survival map, \% of time immersed, mean dry hours, sd dry hours, soil type, maximum velocity.   \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

And that code, when executed in Latex generates a table that does not reduce the column width to fit one page, and leaves it in really long rows that surpass the page. Like this:

enter image description here

So my question is, how to make it fit properly. I been reading and as far I can infer, it might be with the p{###em} indicators of column width and the fact that in the table, some are marked as {*} and some have a proper size indicated, so I'm thinking perhaps there's a way to fix the column width since the begining of the table.

The only way I managed to make it work was by changing manually all entries in the table that said p{###em}, and change them to a measure in cm. Though this seems to work, I would like to know if there is some way of changing it without surfing through the whole table, or by changing something in those em units.

Options like \adjustbox are not what I'm looking for as they reduce the whole table and to fit it in a page, the letters get unreadable.

My main question is regarding to see if there is some relatively minor change in the code, to take advantage of the file that Excel2latex created and adjust the table size, so in the future I won't be requiring changing too many things manually.

Thanks a lot, Felipe

Your Answer

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

Browse other questions tagged or ask your own question.