2

I want to create a table that looks like the following: enter image description here

Under the 'Country List', I would like to have a row with 2 column. How do I do I include that? I have to following :

\begin{table}
\begin{tabular}{ |p{3cm}|p{3cm}|p{3cm}||p{3cm}|p{3cm}|p{3cm}|  }
\hline
\multicolumn{6}{|c|}{1D Basin} \\
\hline
\multicolumn{6}{|c||c|}{Longitudinal & Transversal}
\hline
Mode & Calculated [Hz] & Measured [Hz] & Mode  & Calculated [Hz] & Measured [Hz]\\
\hline
m = 0 & 0.1 & measurement & n = 0 & - & measurement\\
m = 1 & 0.1   & measurement & n = 1 & 0.1 & measurement\\
m = 2 & 0.1   & measurement & n = 2 & 0.1 & measurement\\
m = 3 & 0.1   & measurement & n = 3 & 0.1 & measurement\\
m = 4 & 0.1   & measurement & n = 4 & 0.1 & measurement\\
\hline
\end{tabular}
\end{table}

However, I am getting infinite number of errors starting with:

! missing }

How to proceed further?

4

You forgot to add \\ for a new line, and you ned to split that second multicolumn. You could improve the look of the table, I have added a few suggestions.

Fixed original code

\documentclass[11pt]{article}

\begin{document}
\begin{table}
\begin{tabular}{ |p{3cm}|p{3cm}|p{3cm}||p{3cm}|p{3cm}|p{3cm}|  }
\hline
\multicolumn{6}{|c|}{1D Basin} \\
\hline
\multicolumn{3}{|c|}{Longitudinal} & \multicolumn{3}{|c|}{Transversal}\\
\hline
Mode & Calculated [Hz] & Measured [Hz] & Mode  & Calculated [Hz] & Measured [Hz]\\
\hline
m = 0 & 0.1 & measurement & n = 0 & - & measurement\\
m = 1 & 0.1   & measurement & n = 1 & 0.1 & measurement\\
m = 2 & 0.1   & measurement & n = 2 & 0.1 & measurement\\
m = 3 & 0.1   & measurement & n = 3 & 0.1 & measurement\\
m = 4 & 0.1   & measurement & n = 4 & 0.1 & measurement\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

Suggestions

Vertical lines does not really look that good, especially double vertical lines. Stick to lines that go in the reading direction. Also, horisontal rules loook better if given different weights, therefore use the booktabs -package, which introduce toprule, midrule, and bottomrule. These look a lot better.

I have also removed to tip-line and put that in a caption, as it is better suited there, and also it is better if you are going to reference your table in your text, which you probably will.

You have essentially two tables here, which for some reason is combined here, with the only difference being the columns "Longitudal Measurement" and the "Transversal Measurement". I would possible split these into two separate tables, easing both reading and referencing. As it is now, it is quite wide, so you either need to have really long textlines, or shrink the textsize in the table. I think it would be better to split the table into two seperate tables.

You asked in a comment to make the table fit into the text. Here is an example of how this could be done.

\documentclass[11pt]{article}
\usepackage[left=3cm,right=3cm]{geometry} % just a wider pageformat, (much too long lines are used here, should be around 60-80 characters per line, 66 being ideal for the most part)
\usepackage{
booktabs, % Nicer 
tabularx, % Enables the X-column-type, which takes all the horisontal space available, to make the table fit into the space given, like the \textwidth
lipsum, % Just some sample text.
}
\newcolumntype{Y}{>{\centering\arraybackslash}X} % Introduces an X-column which also is centered.
\begin{document}
\lipsum[1]
\begin{table}[hbt]
\begin{tabularx}{\textwidth}{cccXccc}
\toprule
\multicolumn{3}{c}{Longitudinal} && \multicolumn{3}{c}{Transversal}\\
\midrule
Mode & Calculated [Hz] & Measured [Hz] && Mode  & Calculated [Hz] & Measured [Hz]\\
m = 0 & 0.1 & measurement && n = 0 & - & measurement\\
m = 1 & 0.1   & measurement && n = 1 & 0.1 & measurement\\
m = 2 & 0.1   & measurement && n = 2 & 0.1 & measurement\\
m = 3 & 0.1   & measurement && n = 3 & 0.1 & measurement\\
m = 4 & 0.1   & measurement && n = 4 & 0.1 & measurement\\
\bottomrule
\end{tabularx}
\caption{ID Basin}
\end{table}
\lipsum[2]
\end{document}

enter image description here

2
  • I followed your suggestion to skip the vertical lines and reduce the horizontal lines. Now, I want the table to have the same width as textwidth. I did the following: \begin{tabularx}{\textwidth}{@{}c| c c c c@{}} The table is now having the same width as the text, but the text inside the table is orientated to the left, instead of nicely spread over the table. What to do? – André Jun 17 '16 at 14:21
  • @André I've edited my answer. I am unsure of what it is you really want here. For tabularx to know which column to expand to fit into the text, you need to specify an X-column. An X-column would set the text left-aligned, and if you want center-aligned, see the line in my example, which introduces a Y-column – Runar Jun 17 '16 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.