Reputation: 592
I am new to latex, and I am trying to create a table, but the content in the table cell is quite long, so I decided to create a new line for the cells.
But I am not sure how to do that, could someone help me on that? Here is my code:
\begin{table}[h!]
\caption{Multirow table}
\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
Observation(Species name) & Likelihood (Limnodynastes peronii Distribution Model) &Likelihood (Rhinella marina Distribution Model)\\
\hline
Observation 1 (Limnodynastes peronii) &0.0712 &0.2699\\
\hline
Observation 2 (Rhinella marina) &0.30 &0.013 \\
\hline
\end{tabular}
\end{center}
\end{table}
Upvotes: 1
Views: 5050
Reputation: 56
Here is a fix I made up. The command wraps information in a parbox with a little extra spacing above and below the text to make it look nice. This allows you to limit the width of a cell as well as enter manual line breaks.
\begin{table}[h!]
\caption{Multirow table}
\newcommand{\wrap}[1]{\parbox{.33\linewidth}{\vspace{1.5mm}#1\vspace{1mm}}}
\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
\wrap{Observation\\ (Species name)} &\wrap{Likelihood\\ (Limnodynastes peronii Distribution Model)} &\wrap{Likelihood\\ (Rhinella marina\\ Distribution Model)}\\
\hline
\wrap{Observation 1\\ (Limnodynastes peronii)} &0.0712 &0.2699\\
\hline
\wrap{Observation 2\\ (Rhinella marina)}&0.30 &0.013 \\
\hline
\end{tabular}
\end{center}
\end{table}
Hope this helps- this is my first answer on stackoverflow!
Upvotes: 4