Graphics, Figures & TablesMulticolumn/multirow tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jimp
Posts: 9
Joined: Tue Aug 23, 2011 6:10 pm

Multicolumn/multirow tables

Post by jimp »

I am new to Latex and having some problems making tables. I would like my table to look like the attached figure but the I don't get the multicolumn working at the headline 'Reinforcement'. Do anyone have suggestions?

Thanks in advice, best regards jimp.
Attachments
Table
Table
help.png (6.7 KiB) Viewed 20689 times
Last edited by jimp on Thu Aug 25, 2011 2:59 pm, edited 1 time in total.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Multicolumn/multirow tables

Post by localghost »

The multirow package allows to typeset entries spanning multiple rows (who knew?). For further details consult the package manual. Open a command line for instant access.

Code: Select all

texdoc multirow
For entries spanning multiple columns use the \multicolumn command.


Best regards and welcome to the board
Thorsten
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Multicolumn/multirow tables

Post by Stefan Kottwitz »

Hi Jimp,

welcome to the board!

Have a look at Creating tables with LaTeX, there are examples for multicolumn and multirow tables together with an explanation of \multicolumn and \multirow.

Stefan
LaTeX.org admin
jimp
Posts: 9
Joined: Tue Aug 23, 2011 6:10 pm

Multicolumn/multirow tables

Post by jimp »

Thanks for the tip but I'm in a bit hurry due a deadline on Friday and my !"#! mentor required my work done in LateX this monday. So I am going to ask if Im on the right way with this code =)

Code: Select all

\begin{table*}[h!]
	\centering
	\begin{tabular}{| c | c | c | c | c | c | c |}
	\hline
	\multicolumn{7}{| c |}{Reinforced beams} \\
	\hline
	Support length	& Linear model 	& Non linear model 	& Loading plate 	& Support 	& \multicolumn{2}{| c |}{Reinforcement}	& Total \\
	\hline
	1			& 2			& 3			& 4			& 5		& 6	& 7						& 8 \\
	\hline
	\end{tabular}
	\caption{Number of elements in each part of the reinforced beams.}
	\label{table78}
\end{table*}
jimp
Posts: 9
Joined: Tue Aug 23, 2011 6:10 pm

Multicolumn/multirow tables

Post by jimp »

Never mind! I managed to do it!
jimp wrote:Thanks for the tip but I'm in a bit hurry due a deadline on Friday and my !"#! mentor required my work done in LateX this monday. So I am going to ask if Im on the right way with this code =)

Code: Select all

\begin{table*}[h!]
	\centering
	\begin{tabular}{| c | c | c | c | c | c | c |}
	\hline
	\multicolumn{7}{| c |}{Reinforced beams} \\
	\hline
	Support length	& Linear model 	& Non linear model 	& Loading plate 	& Support 	& \multicolumn{2}{| c |}{Reinforcement}	& Total \\
	\hline
	1			& 2			& 3			& 4			& 5		& 6	& 7						& 8 \\
	\hline
	\end{tabular}
	\caption{Number of elements in each part of the reinforced beams.}
	\label{table78}
\end{table*}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Multicolumn/multirow tables

Post by localghost »

I would do it slightly different and devide some cells in the table header.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[tableposition=top]{caption}
\usepackage{multirow}

\begin{document}
  \begin{table}[!ht]
    \caption{Beam model reinforcement (115x630)}\label{tab:bemore}
    \centering
    \footnotesize
    \begin{tabular}{|*8{c|}}\hline
      Support & Linear & Non-linear & Loading & \multirow{2}{*}{Support} & \multicolumn{2}{c|}{Reinforcement} & Total \\\cline{6-8}
      length (m) & Model & Model & plate & & Hex & Cohessive & \\\hline
      0,06 & 13192 & 13192 & 840 & 245 & 750 & 720 & 28894 \\\hline
      0,09 & & & & & & & \\\hline
      0,12 & & & & & & & \\\hline
    \end{tabular}
  \end{table}
\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Multicolumn/multirow tables

Post by Stefan Kottwitz »

That's a start! Note , you have got 8 columns. So in the column definition (and in the first multicolumn) you need one more c cell to make it work:

Code: Select all

\begin{table*}[h!]
   \centering
   \begin{tabular}{| c | c | c | c | c | c | c | c |}
   \hline
   \multicolumn{8}{| c |}{Reinforced beams} \\
   \hline
   Support length   & Linear model    & Non linear model    & Loading plate    & Support    & \multicolumn{2}{c |}{Reinforcement}   & Total \\
   \hline
   1         & 2         & 3         & 4         & 5      & 6   & 7                  & 8 \\
   \hline
   \end{tabular}
   \caption{Number of elements in each part of the reinforced beams.}
   \label{table78}
\end{table*}
Stefan
LaTeX.org admin
jimp
Posts: 9
Joined: Tue Aug 23, 2011 6:10 pm

Multicolumn/multirow tables

Post by jimp »

Thank you, Stefan_K. I noticed that just some time after my post.

localghost, thanks alot! Looks very good!
localghost wrote:I would do it slightly different and devide some cells in the table header.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[tableposition=top]{caption}
\usepackage{multirow}

\begin{document}
  \begin{table}[!ht]
    \caption{Beam model reinforcement (115x630)}\label{tab:bemore}
    \centering
    \footnotesize
    \begin{tabular}{|*8{c|}}\hline
      Support & Linear & Non-linear & Loading & \multirow{2}{*}{Support} & \multicolumn{2}{c|}{Reinforcement} & Total \\\cline{6-8}
      length (m) & Model & Model & plate & & Hex & Cohessive & \\\hline
      0,06 & 13192 & 13192 & 840 & 245 & 750 & 720 & 28894 \\\hline
      0,09 & & & & & & & \\\hline
      0,12 & & & & & & & \\\hline
    \end{tabular}
  \end{table}
\end{document}
Post Reply