1

Trying to convert this table 1 to the table 2 format, Table 1

Table 2 (single table), merging the cells 1x1 & 1x2, merging the entire 3rd column and hiding the borders, and again merging the 1x4 & 1x5, with defined column width and row height. Table 2

Any ideas or suggestions apart from this method are also welcome

\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{|l|l|l|l|l|}
\hline & Column A & & & Column B \\
\hline i & Wind & & a & Monsoon \\
\hline ii & Anemometer & & b & Cyclone \\
\hline iii & Hurricane, Typhoon & & c & Measures speed of Wind \\
\hline iv & Mausam & & d & Moving air \\
\hline
\end{tabular}
\end{center}
\end{document}
3
  • If you are not adept at making tables in LaTeX, you can try Excel add-in Excel2LaTeX. Commented Mar 18, 2022 at 7:20
  • 1
    There is also tablesgenerator.
    – NBur
    Commented Mar 18, 2022 at 8:33
  • 1
    Noticed that you have edited your question with new requirements (defined column width and row height), I have edited my answer accordingly. Maybe it is better if you use EDIT to show what's the new part. Commented Mar 18, 2022 at 8:39

4 Answers 4

0

Slightly different from user187803's answer with the third column merged (though it makes no difference).

EDIT

  • Thanks to NBur, I removed unnecessary packages;
  • Now the column width and arraystretch can be set. The width of column is set by the value after p. The height of the table should be automatically set as you see the word wrap is on. But you can also set the arraystretch freely here.
\documentclass{article}
\usepackage{multirow,multirow}

\begin{document}
\begin{table}[htbp]
  \centering
  \caption{Add caption}
  \bgroup
    \renewcommand{\arraystretch}{1.2}% <-- array stretch for the table
    \begin{tabular}{|p{1cm}|p{3.5cm}|p{2cm}|p{1cm}|p{3.5cm}|}
      \cline{1-2}\cline{4-5} \multicolumn{2}{|c|}{\textbf{Column A}} & \multirow{5}[10]{*}{} &   \multicolumn{2}{c|}{\textbf{Column B}} \\
      \cline{1-2}\cline{4-5} i & Wind &   & a & Monsoon \\
      \cline{1-2}\cline{4-5} ii & Anemometer &   & b & Cyclone \\
      \cline{1-2}\cline{4-5} iii & Hurricane, Typhoon &   & c & Measures speed of Wind \\
      \cline{1-2}\cline{4-5} iv & Mausam, longer and longer and longer &   & d & Moving air \\
      \cline{1-2}\cline{4-5}
    \end{tabular}%
  \egroup
  \label{tab:addlabel}%
\end{table}%

\end{document}

Result

Actually I made this table using Excel2LaTeX which is rather convenient.

3
  • 1
    Maybe you can remove tabularx and booktabs, since you don't uses these packages.
    – NBur
    Commented Mar 18, 2022 at 8:29
  • @NBur Thanks for your advice and I am editing it. Commented Mar 18, 2022 at 8:31
  • Since I'm new to the community I'm not aware of how to use edit and thanks for the input @Teddy van jerry it was really helpful
    – Karthi_06
    Commented Mar 19, 2022 at 5:27
2

You can use \cline and \multicolumn.
EDIT
For defined column widths, you can use p{width} in the column definition.
For defined row heights, you can redefine \arraystretch.

\documentclass{article}
\begin{document}
\begin{center}
    \sffamily
    \def\arraystretch{1.5}
    \begin{tabular}{|l|p{3.5cm}|p{2cm}|l|l|}
        \cline{1-2}\cline{4-5} \multicolumn{2}{|c|}{\textbf{Column A}} & & \multicolumn{2}{|c|}{\textbf{Column B}} \\
        \cline{1-2}\cline{4-5} i & Wind & & a & Monsoon \\
        \cline{1-2}\cline{4-5} ii & Anemometer & & b & Cyclone \\
        \cline{1-2}\cline{4-5} iii & Hurricane, Typhoon & & c & Measures speed of Wind \\
        \cline{1-2}\cline{4-5} iv & Mausam & & d & Moving air \\
        \cline{1-2}\cline{4-5}
    \end{tabular}
\end{center}
\end{document}

enter image description here

1
  • Thanks @user187803
    – Karthi_06
    Commented Mar 19, 2022 at 4:40
1

With relatively new and versatile tabularray package the table code is short and simple:

\documentclass{article}
\usepackage{tabularray}

\begin{document}
    \begin{center}
\begin{tblr}{hline{1-Z}={1-2, 4-5}{solid}, vlines,
             colspec = {Q[l,6mm] X[l] Q[l,12mm] Q[l,6mm] X[l]},
             row{1} = {font=\bfseries, c}
             }
\SetCell[c=2]{c}    Column A 
    &               &   &   \SetCell[c=2]{c}    Column B 
                            &                           \\
i   & Wind          &   & a & Monsoon                   \\
ii  & Anemometer    &   & b & Cyclone                   \\
iii & Hurricane, Typhoon 
                    &   & c & Measures speed of Wind    \\
iv  & Mausam        &   & d & Moving air                \\
\end{tblr}
    \end{center}
\end{document}

enter image description here

1
  • Thanks for the input @zarko
    – Karthi_06
    Commented Mar 19, 2022 at 5:25
1

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
\begin{center}
\begin{NiceTabular}{ccccc}
\RowStyle[bold]{}
\Block[hvlines]{*-2}{}
\Block{1-2}{Column A}
    &               &   & \Block[hvlines]{*-2}{}  
                          \Block{1-2}{Column B}       \\
i   & Wind          &   & a & Monsoon                 \\
ii  & Anemometer    &   & b & Cyclone                 \\
iii & Hurricane, Typhoon 
                    &   & c & Measures speed of Wind  \\
iv  & Mausam        &   & d & Moving air              \\
\end{NiceTabular}
\end{center}
\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .