1

I have been trying for a few days now to fix this table in my Overleaf file. The multirows are extending past the page, and some of the cells are overlapping. There also seems to be a break in a \cline.

\documentclass[acmsmall, anonymous=true]{acmart}

\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tabularx}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcolumntype{d}{>{\centering}b{.03\textwidth}}

\begin{table}[hbt!]
\centering
\def\tabularxcolumn#1{m{#1}}
\begin{tabularx}{\textwidth}{cdYX}
\textit{Phase} &  & \multicolumn{1}{c}{\textit{Step}} & \multicolumn{1}{c}{\textit{Difficulties a Potential Data Subject Faces with Each Step}} \\
\multicolumn{1}{c|}{\multirow{8}{*}{\textbf{Collection}}} &  & \multirow{2}{=}{Data Source} & \multirow{2}{*}{looooooong looooooong looooooong looooooong cell looooooong looooooong looooooong looooooong cell}
\\ \cline{2-2}
\multicolumn{1}{c|}{} &  &  &  \\
\multicolumn{1}{c|}{} &  & \multirow{2}{*}{Subject Type} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{c|}{} &  &  &  \\
\multicolumn{1}{c|}{} &  & \multirow{2}{*}{Awareness and Consent} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{c|}{} &  &  &  \\
\multicolumn{1}{c|}{} &  & \multirow{2}{*}{Original Data Licensing} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{c|}{} &  &  &  \\ \hline
\multicolumn{1}{l|}{\textbf{Packaging}} &  & \multirow{2}{*}{Dataset Availability} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{l|}{} &  &  &  \\
\multicolumn{1}{l|}{} &  & \multirow{2}{*}{Dataset Licensing} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{l|}{} &  &  &  \\
\multicolumn{1}{l|}{} &  & \multirow{2}{*}{Prohibited Uses} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{l|}{} &  &  &  \\ \cline{1-1} \cline{3-4} 
\multicolumn{1}{l|}{\textbf{Use}} &  & \multirow{2}{*}{Model Use} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{l|}{} &  &  &  \\
\multicolumn{1}{l|}{} &  & \multirow{2}{*}{Dataset Derivatives} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{l|}{} &  &  &  \\
\multicolumn{1}{l|}{} &  & \multirow{2}{*}{Derivative Domain Shift} & \multirow{2}{*}{x} \\ \cline{2-2}
\multicolumn{1}{l|}{} &  &  &  \\ \cline{1-3}
\multicolumn{1}{l|}{\textbf{Retraction}} &  &  & \multirow{2}{*}{x} \\ \cline{2-3}
\multicolumn{1}{l|}{} &  &  & 
\end{tabularx}
 \caption[x]{\small x}
    \label{table:source}    
    \vspace{-5mm}
\end{table}
\FloatBarrier

enter image description here

When I have tried some solutions I've found on other posts, like specifying the cell width, I instead get this:

enter image description here

A sketch of the desired output (apologize it is crappy, I just moved things around in paint):

enter image description here

Any help would be much appreciated.

4
  • Welcome to TeX.SE!
    – Mensch
    Nov 10, 2021 at 18:27
  • Please make your code compilable by adding the documentclass and the relevant packages, as well as the definition of the Y column type.
    – leandriis
    Nov 10, 2021 at 18:35
  • Please also add a sketch of the expected output to your question.
    – leandriis
    Nov 10, 2021 at 18:36
  • Note that the only thing \multirow does is essentially overprinting over other rows. It doesn't reserve any space for its contents.
    – Skillmon
    Nov 10, 2021 at 19:44

2 Answers 2

0

I also made a solution with the tabularray package, which makes it much easier. This is a rather new package, so it may be a bit scary to use it. But it makes it much easier, as it automatically takes the actual size of cells into account. So it works also correctly with much larger texts, without you having to adjust numbers in \multirow.

I defined a rule (\RR) for the second column which I use instead of the \cline{2-2}. This is more robust. I also vertically centered the labels in the first column.

\documentclass[acmsmall, anonymous=true]{acmart}

\usepackage{tabularray}

\newcommand{\RR}{\rule[0.5ex]{6mm}{0.4pt}} % rule for second column

\begin{document}
\begin{table}[hbt!]
  \centering
  \begin{tblr}{ l | Q[l,m,colsep=0pt] X[1,l,m] X[3,l,m] }
    \textit{Phase} & & \SetCell[c=1]{c}{\textit{Step}} &
    \SetCell[c=1]{c}{\textit{Difficulties a Potential Data Subject
        Faces with Each Step}} \\ \hline
    \SetCell[r=4]{m}\textbf{Collection}
      & \RR & Data Source & 
          looooooong looooooong looooooong looooooong cell looooooong looooooong looooooong looooooong cell \\ 
      & \RR & Subject Type & x \\
      & \RR & Awareness and Consent & x \\
      & \RR & Original Data Licensing & x \\ \hline
      \SetCell[r=3]{m}\textbf{Packaging} & \RR &Dataset Availability & x \\ 
      & \RR & Dataset Licensing & x \\
      & \RR & Prohibited Uses & x \\
      \cline{1-1} \cline{3-4}
      \SetCell[r=3]{m}\textbf{Use} & \RR & Model Use & x \\
      & \RR & Dataset Derivatives & x \\
      & \RR & Derivative Domain Shift & x \\
      \cline{1-3}
      \textbf{Retraction} & & & x  \\ \cline{2-3} 
   \end{tblr}
  \caption[x]{\small x}
  \label{table:source}
  \vspace{-5mm}
\end{table}
%\FloatBarrier
\end{document}

enter image description here

1
  • Wow, thank you so much for doing this! This is perfect.
    – smorgan
    Nov 11, 2021 at 20:02
0

I made a couple of changes to your code:

  1. I changed the column widths. You have two X columns; I made the first one narrower.
  2. I eliminated the \multicolumn{1}{c|} (or l|) in the first column by putting the | in the tabular specification. (I choose l rather than c because that seemed the best to me.)
  3. I put an \extrarowheight to get more space between the rows.
  4. I changed a lot of \multirow{2}{*} to \multirow{2}{=}. For columns where text wrapping is wanted this is the proper choice. Actually I think all of them could be changed.
  5. I put a \hline under the header to separate it from the rest of the table.

This gives the following solution. I think this example stresses the use of \multirow to its limits. You probably will have to adjust some of the \multirow{2} to a larger number instead of 2, if the long text in the last column will grow bigger. I would advise to see if the tabularray package might be a better choice for this kind of table.

\documentclass[acmsmall, anonymous=true]{acmart}

\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tabularx}

\newcolumntype{Y}{>{\centering\arraybackslash\hsize=0.3\hsize}X}
\newcolumntype{d}{>{\centering}b{.02\textwidth}}
\setlength{\extrarowheight}{2pt}

\begin{document}
\begin{table}[hbt!]
  \centering \def\tabularxcolumn#1{m{#1}}
  \begin{tabularx}{\textwidth}{ l | d Y X }
    \textit{Phase} & & \multicolumn{1}{c}{\textit{Step}} &
    \multicolumn{1}{c}{\textit{Difficulties a Potential Data Subject
        Faces with Each Step}} \\ \hline
    {\multirow{8}{*}{\textbf{Collection}}} & & \multirow{2}{=}{Data Source} & 
    \multirow{2}{=}{looooooong looooooong looooooong looooooong cell looooooong looooooong looooooong looooooong cell}
    \\ \cline{2-2} \\
    & & \multirow{2}{=}{Subject Type} & \multirow{2}{*}{x} \\
    \cline{2-2}
    &  &  &  \\
    & & \multirow{2}{=}{Awareness and Consent} & \multirow{2}{*}{x} \\
    \cline{2-2}
    &  &  &  \\
    & & \multirow{2}{=}{Original Data Licensing} &
    \multirow{2}{*}{x} \\ \cline{2-2}
    & & & \\ \hline
    {\textbf{Packaging}} & & \multirow{2}{=}{Dataset Availability} & \multirow{2}{*}{x} \\ \cline{2-2}
    &  &  &  \\
    & & \multirow{2}{=}{Dataset Licensing} & \multirow{2}{*}{x} \\
    \cline{2-2}
    &  &  &  \\
    & & \multirow{2}{=}{Prohibited Uses} &
    \multirow{2}{*}{x} \\ \cline{2-2} 
    & & & \\
    \cline{1-1} \cline{3-4}
    {\textbf{Use}} & &
    \multirow{2}{=}{Model Use} & \multirow{2}{*}{x} \\ \cline{2-2}
    &  &  &  \\
    & & \multirow{2}{=}{Dataset Derivatives} & \multirow{2}{*}{x} \\
    \cline{2-2}
    &  &  &  \\
    & & \multirow{2}{=}{Derivative Domain Shift} &
    \multirow{2}{*}{x} \\ \cline{2-2} 
    & & & \\
    \cline{1-3}
    {\textbf{Retraction}} & & & \multirow{2}{*}{x} \\
    \cline{2-3} 
    & & &
  \end{tabularx}
  \caption[x]{\small x}
  \label{table:source}
  \vspace{-5mm}
\end{table}
%\FloatBarrier
\end{document}

enter image description here

1
  • Thank you so so much for this. This is really helpful. I am not great with tables at all, so I am sure this is probably not the best option, but thank you for the tip!
    – smorgan
    Nov 11, 2021 at 20:01

You must log in to answer this question.

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