3

I made this table that after compiling works properly but I got the message above: can anyone please help me in order to understand what is wrong?

\begin{tabular}{cp{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
    \bigskip
    \multicolumn{1}{c}{\large\textbf{\underline{Model}}}&\multicolumn{4}{c}{\large\textbf{\underline{Parameters}}}\\
    \medskip
    & $\mu$ & $\alpha$ & $\beta$ & $\lambda_p$ & $\lambda_b$ \\ \hline
    \medskip
    \textbf{Poisson} & - & - & - & $2,66\times10^{-2}$ & - \\ \hline 
    \medskip
   \textbf{ Hawkes} & close to 0 & 3.53 & 3.97 & - & - \\ \hline
    \medskip
    \textbf{Branching} & - & - & - & - & $0,13\times10^{-2}$ \\ \hline 
\end{tabular}
  • You can't use \bigskip before a \multicolumn. – Ulrike Fischer Mar 11 at 10:54
  • 1
    Off-topic(ish), but if each parameter only corresponds to one row, it might be better to not have the table at all. I feel like one of the main points of the table would be to allow you to compare different entries in the same column, and that isn't applicable if each column only has a single row. – Teepeemm Mar 11 at 14:42
2

Two problems:

  • your first row only has 1+4=5 columns, while your table has 6 columns

  • instead of trying to add skips, I suggest to use \addlinespace from the booktabs package

Not strictly speaking a problem, but with 0,13 the spacing around the , will most likely be wrong. I suggest to have a look at the siunitx package

\documentclass{beamer}


\begin{document}

\begin{frame}
\begin{tabular}{cp{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
%    \bigskip
    \multicolumn{2}{c}{\large\textbf{\underline{Model}}}&\multicolumn{4}{c}{\large\textbf{\underline{Parameters}}}\\
%    \medskip
    & $\mu$ & $\alpha$ & $\beta$ & $\lambda_p$ & $\lambda_b$ \\ \hline
    \medskip
    \textbf{Poisson} & - & - & - & $2,66\times10^{-2}$ & - \\ \hline 
    \medskip
   \textbf{ Hawkes} & close to 0 & 3.53 & 3.97 & - & - \\ \hline
    \medskip
    \textbf{Branching} & - & - & - & - & $0,13\times10^{-2}$ \\ \hline 
\end{tabular}
\end{frame}

\end{document}
  • Thanks for the info, now it works properly. Last things: if I want to preserve this setting but putting the data centering with respect to the column, what should I do? I try to change something in cp{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm} but it doesn't work... – Andrea Mazzoran Mar 11 at 17:18
  • @AndreaMazzoran Not sure if I understand your comment correctly, but if you are looking for centred p columns, this answer will help: tex.stackexchange.com/a/157400/36296 – user36296 Mar 11 at 17:27
  • That was EXACTLY what I was looking for, thanks again, you are a master! – Andrea Mazzoran Mar 12 at 18:21
  • @AndreaMazzoran You're welcome! – user36296 Mar 12 at 18:23
5

Sorry, but \medskip does not do what you expect to.

Consider the simple example

\documentclass{article}

\begin{document}

\begin{tabular}{cc}
\hline
a & b \\
\hline
\medskip
c & d \\
\hline
\end{tabular}\qquad
\begin{tabular}{cc}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}

\end{document}

and its output

enter image description here

As you see, the vertical space is added below the second row, not between the first and second row.

You want, instead, to use siunitx and booktabs:

\documentclass{article}
\usepackage{siunitx,booktabs,array}

\begin{document}

\begin{tabular}{
 >{\bfseries}l
 S[table-format=1.2]
 S[table-format=1.2]
 S[table-format=1.2]
 S[table-format=1.2e-1]
 S[table-format=1.2e-1]
}
\toprule
\multicolumn{1}{c}{\textbf{Model}} & \multicolumn{5}{c}{\textbf{Parameters}}\\
\cmidrule(r){1-1} \cmidrule(l){2-6}
  & $\mu$ & $\alpha$ & $\beta$ & $\lambda_p$ & $\lambda_b$ \\
\midrule
Poisson & {--} & {--} & {--} & 2,66e-2 & {--} \\
\midrule
Hawkes & {close to 0} & 3.53 & 3.97 & {--} & {--} \\
\midrule
Branching & {--} & {--} & {--} & {--} & 0,13e-2 \\
\bottomrule
\end{tabular}

\bigskip

\begin{tabular}{
 >{\bfseries}l
 S[table-format=1.2]
 S[table-format=1.2]
 S[table-format=1.2]
 S[table-format=1.2e-1]
 S[table-format=1.2e-1]
}
\toprule
\multicolumn{1}{c}{\textbf{Model}} & \multicolumn{5}{c}{\textbf{Parameters}}\\
\cmidrule(r){1-1} \cmidrule(l){2-6}
  & $\mu$ & $\alpha$ & $\beta$ & $\lambda_p$ & $\lambda_b$ \\
\midrule
Poisson & {--} & {--} & {--} & 2,66e-2 & {--} \\
Hawkes & {close to 0} & 3.53 & 3.97 & {--} & {--} \\
Branching & {--} & {--} & {--} & {--} & 0,13e-2 \\
\bottomrule
\end{tabular}

\end{document}

I'd prefer to avoid as many horizontal rules as I can, so I showed also the table without the unnecessary ones.

enter image description here

The second table, with some added vertical space and no boldface:

\begin{tabular}{
 l
 S[table-format=1.2]
 S[table-format=1.2]
 S[table-format=1.2]
 S[table-format=1.2e-1]
 S[table-format=1.2e-1]
}
\toprule
\multicolumn{1}{c}{Model} & \multicolumn{5}{c}{Parameters}\\
\cmidrule(r){1-1} \cmidrule(l){2-6}
  & $\mu$ & $\alpha$ & $\beta$ & $\lambda_p$ & $\lambda_b$ \\
\midrule
Poisson & {--} & {--} & {--} & 2,66e-2 & {--} \\
\addlinespace
Hawkes & {close to 0} & 3.53 & 3.97 & {--} & {--} \\
\addlinespace
Branching & {--} & {--} & {--} & {--} & 0,13e-2 \\
\bottomrule
\end{tabular}   

enter image description here

Removing boldface is good, the additional vertical space is not really important.

  • Thanks, this is far better looking than mine. Last thing: if I want my table to be a little be wider (i.e. more space between \mu \alpha \beta ecc.) without messing up all the centering what do I have to change in the second code? – Andrea Mazzoran Mar 11 at 17:20
  • @AndreaMazzoran Are you sure this doesn't hinder readability? – egreg Mar 11 at 18:07

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.