0

I am puzzled how to create in LaTeX the following table

enter image description here

I have spent much searching internet and books about latex but I cannot find something relevant. My problem is how to include the first row which is centered and has two columns as you see and also the last row.

Thank you very much.

Dimitris
  • 1,405

4 Answers4

0

Include the package multirow:

\usepackage{multirow}

And use it in your table like so:

\multicolumn{2}{c}{ Field variables }

The field will now span across 2 cells, the text will be centered, the content will be 'Field variables'.

0

You can start with:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lmodern}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{p{3.5cm}cp{1.75cm}p{3cm}p{1.75cm}}
\toprule
\multicolumn{3}{c}{Field variables} & \multicolumn{2}{c}{Field equations}\\
\midrule
Name & Symbol & Number of Unknowns & Name & Number of equations \\
\midrule
Displacement (vector) & \textbf{u} & 3 & Conservation of Linear Momentum & 3 (3.2.9) \\
Strain (second-order symmetric tensor) & $\varepsilon$ & 6 & Kinematics & 6 (3.2.4) \\
\bottomrule
\end{tabular}
\end{document}

enter image description here

Update: Following Johanne_B and Barbara Beeton suggestions, better aligning and cmidrules are introduced.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{array} % for \newcolumntype

\newcolumntype{v}[1]{%
    >{\raggedright\hspace{0pt}\arraybackslash}p{#1}%
}

\begin{document}
\begin{tabular}{v{3.5cm}cv{1.75cm}v{3cm}v{1.75cm}}
\toprule
\multicolumn{3}{c}{Field variables} & \multicolumn{2}{c}{Field equations}\\
\cmidrule(r){1-3}\cmidrule(l){4-5}
Name & Symbol & Number of Unknowns & Name & Number of equations \\
\cmidrule(r){1-1}\cmidrule(rl){2-2}\cmidrule(rl){3-3}\cmidrule(rl){4-4}\cmidrule(l){5-5}
Displacement (vector) & \textbf{u} & 3 & Conservation of Linear Momentum & 3 (3.2.9) \\
Strain (second-order symmetric tensor) & $\varepsilon$ & 6 & Kinematics & 6 (3.2.4) \\
\bottomrule
\end{tabular}
\end{document}

enter image description here

Ignasi
  • 136,588
0

So, based on the replies I got here is the table:

\begin{table}
\centering
\begin{tabular}{p{3.5cm}cp{1.75cm}p{3cm}p{1.75cm}}
\toprule
\multicolumn{3}{c}{Field variables} & \multicolumn{2}{c}{Field equations}\\
\midrule
Name & Symbol & Number of Unknowns & Name & Number of equations \\
\midrule
Displacement (vector) & $\textbf{u}$ & 3 & Conservation of Linear Momentum & 3 (3.2.9) \\
Strain (second-order symmetric tensor) & $\boldsymbol{\varepsilon}$ & 6 & Kinematics & 6 (3.2.4) \\
Stress (second-order symmetric tensor) & $\boldsymbol{\sigma}$ & 6 &  &  \\
Density (scalar) & $\rho$ & 1 & Conservation of Mass & 6 (3.2.4) \\
Internal Energy (scalar) & $u$ & 1 &  & 1 (3.2.4) \\
Temperature (scalar) & $T$ & 1 & Conservation of Mass & 6 (3.2.4) \\
Heat Fluc (scalar) &$\bf{q}$ & 3& &\\
\bottomrule
Number of Unknowns:& & 21 & Number of Equations& 11
\end{tabular}
\caption{Unknown field variables and available field equations in continuum mechanics.}
\end{table}

However, I want the contents of all the columns to be left-aligned (APART FROM the first row). How can I achieve this?

Dimitris
  • 1,405
  • Note that this site doesn't work like a normal forum, so new questions/follow up questions should not be posted as answers to existing questions. I would recommend that you create a new question with the above text. – Torbjørn T. Jul 07 '15 at 10:10
  • That said, you sort of have the answer in that code already: \multicolumn. You can have a \multicolumn spanning just one column, i.e. \multicolumn{1}{c}{Name}. – Torbjørn T. Jul 07 '15 at 10:16
0

As a start point you can try this site http://www.tablesgenerator.com it will help you to create table online like in excel