0

I am trying to design this table, But this contains multi-columns

enter image description here

How to go after this:

\usepackage{multirow}

\begin{table}[]
\begin{tabular}{llllll}
\hline
\multicolumn{1}{|l|}{Type} & \multicolumn{1}{l|}{Dataset} & \multicolumn{1}{l|}{\#Features} & \multicolumn{1}{l|}{\#Avg. sparsity} & \multicolumn{1}{l|}{\#Nodes} & \multicolumn{1}{l|}{\# Clusters} \\ \hline
                           & Facebook                     & 1284                            & 80\%                                 & 300                          & 20                               \\
Social Network             & Gplus                        & 1284                            & 80\%                                 & 300                          & 20                               \\
                           & Twitter                      & 1284                            & 80\%                                 & 300                          & 20                               \\
                           & Cora                         & 321                             & 19\%                                 & 100                          & 4                                \\
Citation Dataset           & Citeseer                     & 321                             & 20\%                                 & 100                          & 3                                \\
                           & Pubmed                       & 321                             & 20\%                                 & 100                          & 6                               
\end{tabular}
\end{table}

But it's not showing as I want:

enter image description here

How to design like that image? Should I use any extra package?

7
  • The multicolumn command can be used for the entries in the first row. Apart from that, I'd recommend to avoid vertical lines and to use the horizontal lines from the booktabs package. For an improved alignment of the numbers, you could use the siunitx package.
    – leandriis
    Oct 24, 2019 at 18:40
  • Define the table with all data columns you need, then combine header cells with \multicolumn{<#cols>}{<l/r/c>}{<text>} (see e.g. texblog.org/2012/12/21/… or en.wikibooks.org/wiki/LaTeX/…) Related: Using multicolumn in latex Oct 24, 2019 at 18:42
  • 1
    I don't think you need to specify the column widths here, nor to use multirow.
    – Bernard
    Oct 24, 2019 at 18:43
  • 1
    The code in your question seems to be only loosely related to the image. Could you please clarify?
    – leandriis
    Oct 24, 2019 at 20:38
  • @leandriis I corrected, Please check. Oct 25, 2019 at 4:22

3 Answers 3

2

Does that help ?

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}

\begin{table}
\centering
\begin{tabular}{c|ccc|ccc}
\toprule
\multirow{2}{*}{two rows} & \multicolumn{3}{|c|}{three columns} & \multicolumn{3}{|c|}{three other columns} \\
\cline{2-7}
                          & column 1 & column 2 & column 3    & column 4 & column 5 & column 6          \\    
\midrule
\midrule
line 1                    & \multicolumn{2}{c}{columns 1 and 2} & then 3 & then 4 & \multicolumn{2}{|c}{then 5 and 6 with vert bar} \\
\midrule
line 2                    & \multirow{2}{*}{2 rows' cell} & lorem & ipsum & & & \\
line 3                    &                               & lorem & ipsum & & & \\
\bottomrule
\end{tabular}
\caption{Example of what you can do...}
\end{table}

\end{document}

enter image description here

As @leandriis says,

The code in your question seems to be only loosely related to the image.

Might be helpful to be more precise in what you want to achieve.

1
  • It was very helpful. Oct 26, 2019 at 8:11
4

Some elementary description how to design tales you can find in WikiBooks/Tables. For further design of your tables is also worth to see "Wie Tabellen eigentlich aussehen sollten". Learned from both links, you can design the following table, which has multi column and multi row cells:

\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs, multirow}

\begin{document}
    \begin{table}
\centering
\begin{tabular}{c ccc ccc}
    \toprule
\multirow{2}{*}{two rows} 
        & \multicolumn{3}{c}{3-columns cell} & \multicolumn{3}{c}{3-columns cell}   \\
    \cmidrule(lr){2-4} \cmidrule(lr){5-7}
        & column 1  & column 2  & column 3  & column 4  & column 5  & column 6          \\
    \midrule
\multirow{4}{*}{Social Network}  
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
    \addlinespace
\multirow{4}{*}{Citation Dataset}
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
        & item 1    & item 2    & then 3    & item 4    & item 5    & item 6            \\
    \bottomrule
\end{tabular}
\caption{Example of professional table design}
    \end{table}
\end{document}

enter image description here

2
  • Can you check the updated image, please? I accidentally used the wrong image earlier. Oct 25, 2019 at 12:01
  • @AadityaUra, in both received answer you got a way how to design multi column and multi row cells. Now you change question completely. It would be fer that you ask new question and from received select one, which the best way solve your problem as it is stated in the first version of question.
    – Zarko
    Oct 25, 2019 at 13:41
0

Here is what I tried and it's same as i wanted :

\begin{table*}
\centering
\begin{tabular}{c|c|c|cccccc}


\toprule
column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6  & column 6  \\ 
\toprule
\multirow{4}{*}{two rows} &  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  

\cline{2-8}
&  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  
\cline{2-8}
&  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  
\cline{2-8}
&  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  

\cline{1-8}
\multirow{2}{*}{two rows} &  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  

\cline{2-8}
&  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  
\cline{2-8}
&  column 1 & column 2 & column 3    & column 4 & column 5 & column 6       & column 6   \\  

\bottomrule
\end{tabular}
\caption{Example}
\end{table*}

enter image description here

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.