1

In the following sample latex codes of a table, how can I avoid large gaps in between symbols in the first column:

\documentclass{article}
\usepackage{rotating}

\begin{document}
    \begin{sidewaystable}[h]
    \caption{Comparsion of Methods }\label{tab:LPer}
    \centering % centering table
    \resizebox{\textwidth}{!}{
    \begin{tabular}{|p{4cm}| c |c| ccc |ccc |ccc  |ccc| ccc| ccc|} % creating 10 columns
    \hline\hline % inserting double-line
    &\multicolumn{2}{c}{}&\multicolumn{3}{|c}{M 5} &\multicolumn{3}{|c}{M 1} &\multicolumn{3}{|c}{M2} &\multicolumn{3}{|c}{M3}&\multicolumn{3}{|c}{M3}&\multicolumn{3}{|c|}{M4}\\ [0.5ex]
    \hline
    Model \& Parameters &$Input 1$ & $Input 2$ & N & $error$& Time & N & $error$ & Time &N & $error$& Time &N & $error$ & Time & N & $error$ & Time & N & $error$& Time \\[0.5ex]
    A1--a1=0.05; a2=0; a3=0.3 &$\theta$&1--100&  && & && & && & && & && & && \\[0.5ex]
    \hline
    A2--$\sigma=0.12,\,  \theta=-0.14,\,\nu=0.2$&$\epsilon$&90--120&  && & && & && & && & && & && \\[0.5ex]
    \hline % inserts single-line
    \hline % inserts single-line
    \end{tabular}}
    \end{sidewaystable}
\end{document}
2
  • 1
    Welcome to TeX.SE. Please provide compilable documents, not just fragments of code
    – user31729
    Aug 24, 2017 at 15:47
  • 1
    Your table contains not 10, but 21 [!], columns! What are you trying to convey to your readers?
    – Mico
    Aug 24, 2017 at 16:34

2 Answers 2

2

enter image description here

You can use \raggedright in the cell, but also don't use h with sidewaystable, avoid scaling tables, and don't use $ to get text italic, and finally (not shown in the image) always put the | at the right hand side of a cell unless in the first column. Never put it on the left.

\documentclass{article}
\usepackage{array,rotating}

\begin{document}
    \begin{sidewaystable}
    \caption{Comparsion of Methods }\label{tab:LPer}
    \centering % centering table
     \footnotesize
     \setlength\tabcolsep{3pt}

    \hspace*{-10pt}%
    \begin{tabular}{@{}|>{\raggedright}p{4cm}| c |c|ccc|ccc|ccc|ccc|ccc|ccc|@{}} % creating 10 columns
    \hline\hline % inserting double-line
    &\multicolumn{2}{c|}{}&\multicolumn{3}{c|}{M 5} &
\multicolumn{3}{c|}{M 1} &\multicolumn{3}{c|}{M2} &
\multicolumn{3}{c|}{M3}&
\multicolumn{3}{|}c{M3}&\multicolumn{3}{c|}{M4}\\ [0.5ex]
    \hline
    Model \& Parameters &\textit{Input} 1 & \textit{Input} 2 & N &
\textit{error}& Time &
 N & \textit{error} & Time &N & \textit{error}& Time &N &
\textit{error} & Time & N & \textit{error} & Time &
 N & \textit{error}& Time \\[0.5ex]
    A1--a1=0.05; a2=0; a3=0.3 &$\theta$&1--100&  && & && & && & && & && & && \\[0.5ex]
    \hline
    A2--$\sigma=0.12,\,  \theta=-0.14,\,\nu=0.2$&$\epsilon$&90--120&  && & && & && & && & && & && \\[0.5ex]
    \hline % inserts single-line
    \hline % inserts single-line
    \end{tabular}%
    \hspace*{-20pt}%
    \end{sidewaystable}
\end{document}
0

In addition to using a \raggedright prefix for the p{4cm} column specification, you should also try to give your table a more open look. The following code provides an example. Note, in particular, the absence of any vertical rules; they're simply not needed in a reasonably well designed table.

enter image description here

\documentclass{article}
\usepackage{rotating,array,booktabs}
\usepackage[skip=0.333\baselineskip]{caption}

\begin{document}
    \begin{sidewaystable}[h]
    \captionsetup{font=footnotesize}
    \caption{Comparsion of Methods}\label{tab:LPer}

    \footnotesize
    \setlength\tabcolsep{0pt} % let LaTeX determine intercol. whitespace 
    \setlength\extrarowheight{1pt}
    \begin{tabular*}{\textwidth}{>{\raggedright}p{3cm} 
        @{\extracolsep{\fill}} cc*{6}{ccc}} % 21 [!] columns in all
    \toprule

    Model \& Parameters & Input 1 & Input 2 
    &\multicolumn{3}{c}{M0} &\multicolumn{3}{c}{M1} 
    &\multicolumn{3}{c}{M2} &\multicolumn{3}{c}{M3}
    &\multicolumn{3}{c}{M4} &\multicolumn{3}{c}{M5}\\ 
    \cmidrule{4-6}   \cmidrule{7-9} 
    \cmidrule{10-12} \cmidrule{13-15} 
    \cmidrule{16-18} \cmidrule{19-21} 
    &&
    & $N$ & error& Time & $N$ & error & Time & $N$ & error& Time 
    & $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
    \midrule
    A1: $a_1=0.05$; $a_2=0$; $a_3=0.3$           & $\theta$   &  1--100& \\
    \addlinespace
    A2: $\sigma=0.12$; $\theta=-0.14$; $\nu=0.2$ & $\epsilon$ & 90--120& \\
    \bottomrule
    \end{tabular*}
    \end{sidewaystable}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .