Graphics, Figures & TablesComplex Table with merged Cells over Columns and Rows

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Rimme
Posts: 6
Joined: Wed Nov 28, 2012 2:18 pm

Complex Table with merged Cells over Columns and Rows

Post by Rimme »

Hi,

I'm trying to make the following table, but I cant seem to get it right.

Code: Select all

___________________________
|__|_________________|    |
|__|___________|     |    |
|__|_____|_____|_____|____|
|__|_____|_____|_____|____|
Hope that someone can help me make the table. I've tried using multirow and \multicolumn but I only get errors.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Complex Table with merged Cells over Columns and Rows

Post by svend_tveskaeg »

Hi and welcome to the board.

Please show your try/tries as a minimal working example.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Complex Table with merged Cells over Columns and Rows

Post by Stefan Kottwitz »

Hi Rimme,

welcome to the board!
Rimme wrote:I've tried using multirow and multicolumn but I only get errors.
In such cases two things are good to know:
  • what did you try (as Svend already asked), so we can tell you what has been wrong
  • what were the error messages
Generelly "I get errors" without telling the error messages messages and even without what's been done doesn't show us much. It's hard to help then. A "type a complex table for me" surely wasn't meant by you, but to learn what's wrong and what's correct.

Stefan
LaTeX.org admin
Rimme
Posts: 6
Joined: Wed Nov 28, 2012 2:18 pm

Complex Table with merged Cells over Columns and Rows

Post by Rimme »

I hope this is what you asked for.

Code: Select all

\documentclass[11pt]{article}

\begin{document}
\begin{table}
  \centering
    \begin{tabular}{|c|c|c|c|c|} \hline
      \multirow{3}{|c|}{...}  & \multicolumn{3}{|c|}{...}                     &     \multirow{3}{|c|}{...} \\\hline                      
                              & \multicolumn{2}{|c|}{...} & \multirow{2}{|c|}{...} &  \\\hline                    
                              & a & b	                  & 	              &   \\\hline
	a		      & b & c	                  & e	              & f \\\hline
     \end{tabular}
\end{table}

\end{document}
The error I get when I only use the above is:

Code: Select all

!Undefined control sequence.<to be read again> \multirow \multirow
When I put the same table in the document that I am working on these errors occurs:

Code: Select all

!Missing number, treated as zero. <to be read again>|\multirow{3}{|c|}{...}
!Illegal unit of messure (pt inserted). <to be read again>|\multirow{3}{|c|}{...}
Last edited by cgnieder on Wed Nov 28, 2012 11:25 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Complex Table with merged Cells over Columns and Rows

Post by cgnieder »

Well, now the issue is clear: there is no \multirow command! LaTeX only provides the \multicolumn command but no equivalent for rows. There is a package, though, that provides something similar: the multirow package. Have a look at its documentation (multirow) to see how it works.

Regards
site moderator & package author
Rimme
Posts: 6
Joined: Wed Nov 28, 2012 2:18 pm

Re: Complex Table with merged Cells over Columns and Rows

Post by Rimme »

I have looked in the package manager and it seems that the package is already installed and I have \usepackage{multirow} in my preamble. So it looks like the package is not working.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Complex Table with merged Cells over Columns and Rows

Post by Stefan Kottwitz »

So you just forgot to put \usepackage{multirow} into your minimal example above, Clemens noticed that already. That's the reason for the Undefined control sequence error.

The error Missing number, treated as zero comes because you did not set a width. Have a look at the link to the multirow documentation, provided by Clemens above. The syntax for \multirow is

Code: Select all

\multirow{number of rows}{width}{text}
it also supports two optional arguments, which you did not use.

So, in your example, this would work:

Code: Select all

\multirow{3}{1cm}{|c|}{...}
and also this:

Code: Select all

\multirow{3}{*}{|c|}{...}
with * as indication for using the natural width of the text argument.

Stefan
LaTeX.org admin
Rimme
Posts: 6
Joined: Wed Nov 28, 2012 2:18 pm

Re: Complex Table with merged Cells over Columns and Rows

Post by Rimme »

Thank you very much, everything is now working.
Post Reply