Tables – How to Merge Two Cells in LaTeX

combinetables

I can't figure out how to merge two rows as in figure below.

This is my code:

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}                
\usepackage[utf8]{inputenc}             
\usepackage[english,italian]{babel}
\usepackage{booktabs}
\usepackage{caption}
\usepackage[bindingoffset=1.5cm, left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}

\begin{document}
\title{Title}
\author{Me}
%\date{10 dicembre 2015}

\maketitle

 \begin{center}
  \begin{tabular}{|c|c|}
\hline
Text & \\
\hline 
Diametro fori (mm) & 4\\
\hline 
Passo x (mm) & 24\\
\hline
Passo y (mm) & 24\\
\hline
Altezza canale (mm) & 10\\
\hline
Lunghezza canale (mm) & 146\\
\hline
Numero fori & 39\\
\hline
  \end{tabular}
   \captionof{table}{Caratteristiche della piastra e del canale}
    \label{tab:dati_canale-piastra}
 \end{center}

\end{document}

enter image description here

Best Answer

Try \multicolumn{2}{|l|}{Text} \tabularnewline in the relevant row. \multicolumn{n}{q}{foo} merges n cells with type q and places foo as content.

Side note: Using booktabs and vertical lines in a table is not the best design. I would also use left alignment for the first column.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}                
\usepackage[utf8]{inputenc}             
\usepackage[english,italian]{babel}
\usepackage{booktabs}
\usepackage{caption}
\usepackage[bindingoffset=1.5cm, left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}

\begin{document}
  \title{Title}
  \author{Me}
  %\date{10 dicembre 2015}

  \maketitle

  \begin{center}
    \begin{tabular}{|c|c|}
      \hline
      \multicolumn{2}{|l|}{Text} \tabularnewline
      \hline 
      Diametro fori (mm) & 4 \tabularnewline
      \hline 
      Passo x (mm) & 24\tabularnewline
      \hline
      Passo y (mm) & 24\tabularnewline
      \hline
      Altezza canale (mm) & 10\tabularnewline
      \hline
      Lunghezza canale (mm) & 146\tabularnewline
      \hline
      Numero fori & 39\tabularnewline
      \hline
    \end{tabular}
    \captionof{table}{Caratteristiche della piastra e del canale}
    \label{tab:dati_canale-piastra}
  \end{center}
\end{document}

enter image description here

Related Question