3

I have stuck at formatting the following table. As you can see, third and fourth columns are not properly formatted. Based on the manual of \multirow, using {=} should wrap the text, but I don't know why it doesn't work here.

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{multirow}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
 
Table \ref{wrk-desc} briefly 

\begin{table*}[]
\caption{}
\centering
\label{wrk-desc}
\begin{tabular}{|P{4.0cm}|P{1.8cm}|P{2.6cm}|P{2.6cm}|P{1.2cm}|P{1.2cm}|}
\hline
\multirow{2}{*}{Description}   & \multirow{2}{*}{Dataset}        & \multirow{2}{=}{Total number of items} & \multirow{2}{c}{Weighted average of number of items per case} & \multicolumn{2}{c|}{Types}          \\ 
\cline{5-6} 
     &        &         &      & 100\% of samples & 30\%-70\% of samples \\ 
\hline


\end{tabular}
\end{table*}

enter image description here

0
7
  • Use {=} option in all `multirow cells.
  • If the content of multirow cells should be horizontally centered, than redefine its set up as \renewcommand\multirowsetup{\centering}.
  • Employ the siunitx package for settings quantities.
  • Slightly increase widths of columns (for this is some space in text widths), as is done in the following MWE (since the content of table body is unknown selected widths can be silly)
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{array, makecell, multirow}
\setcellgapes{3pt}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{siunitx}

\begin{document}

Table \ref{wrk-desc} briefly

    \begin{table*}
\centering
\caption{my wide table}
\label{wrk-desc}
    \sisetup{range-phrase={\,--\,}}
    \renewcommand\multirowsetup{\centering} 
    \makegapedcells
\begin{tabular}{|P{4.0cm}|P{2cm}|P{2.6cm}|P{3cm}|P{2cm}|P{2cm}|}
    \hline
\multirow{3.4}{=}{Description}   
    & \multirow{3.4}{=}{Dataset}        
        & \multirow{3.4}{=}{Total number of items} 
            & \multirow{3.4}{=}{Weighted average of number of items per case}
                & \multicolumn{2}{c|}{Types}          \\
\cline{5-6}
    &   &   &   & \qty{100}{\%} of samples 
                    & \qtyrange{30}{70}{\%} of samples \\
    \hline
\end{tabular}
    \end{table*}
\end{document}

enter image description here

(red lines indicate text area borders)

5
  • Excuse me, but your code doesn't work for me. Indeed I paste the whole content but the result is still messy. I have shared the test project at bit.ly/3cFVy5D I think that the document class I am using is different. But I am not able to figure it out. It seems that \multirow{3.4} is not correct in my case. – mahmood Jun 13 at 19:34
  • @mahmood, apparently Overleaf hasn't last version of packages or it is somehow broken (temporary I cant access my account on it). Please, contact their support for help. I tested my solution with recent MiKTeX in it works fine. Or make own local installation of LaTeX. – Zarko Jun 13 at 20:19
  • @mahmood, now I succeed to access my Oveleaf account and test my solution. It works fine and gives the same result as I obtain from MiKTeX and show in answer. So, Overleaf is not to blame for your problem, but your test document. I suggest you to make new test document with my solution and see, if your problem still persist. If not, on its base built your real document. – Zarko Jun 13 at 20:25
  • Well I see that the IEEEtran version is 1.8b on 2015. The link I shared is on our local sharelatex server, but I have included the IEEEtran.cls file in the project. That is bizarre that it doesn't work... – mahmood Jun 13 at 20:46
  • 2
    @mahmood, it is not bizarre, problem is that you probably have outdated sharelatex server. You need to update all packages, not only IEEEtran class. For example. recent multirow is 2021/03/15, version v2.8 ... – Zarko Jun 13 at 23:53
4

For me it works fine with this code (just some modifications to improve the table layout):

    \documentclass[conference]{IEEEtran}
    {}\IEEEoverridecommandlockouts
    \usepackage{multirow}
    \usepackage{makecell} 
    \usepackage{array}
    \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

    \begin{document}

    Table \ref{wrk-desc} briefly

    \begin{table*}
    \setcellgapes{2pt}\makegapedcells
    \caption{}
    \centering
    \label{wrk-desc}
    \begin{tabular}{|P{4.0cm}|P{1.8cm}|P{2.6cm}|P{2.6cm}|P{1.25cm}|P{1.25cm}|}
    \hline
    \multirow{2}{*}{Description} & \multirow{2}{*}{Dataset} & \multirow{2}{=}{Total number of items} & \multirow{2}{=}[-1.25ex]{Weighted average of number of items per case}& \multicolumn{2}{c|}{Types} \\
    \cline{5-6}
         & & & & 100\% of samples & 30\,\%-70\,\% of samples \\
    \hline
    \end{tabular}
    \end{table*}

    \end{document} 

enter image description here

6
  • It seems that my document class or the tex engine is different because your code is messy for me. I have shared the document at bit.ly/3cFVy5D – mahmood Jun 13 at 19:38
  • The document class is the one you posted. Maybe the installation of the size is not up-to-date? – Bernard Jun 13 at 19:57
  • @mahmood: I've just added a small modification to the code, to have a better layout. Please see whether it works for you. – Bernard Jun 13 at 20:08
  • 1
    Thank you for the edit, @Sebastiano. – Bernard Jun 13 at 22:38
  • @Bernard aahahahah :-) I'm glady to help you and the other excellent users. – Sebastiano Jun 13 at 22:39

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.