0

I am trying to create the following table with LaTeX:

enter image description here

I have tried using makecell, tabularx, and array packages. However, I can't create it. I can't make the table have a maximum width equal to \linewidth, while breaking long text correctly into multiple lines and creating bulleted lists in the table cells. What I have tried so far is:

\begin{table}[ht]
    \caption{Example Table}
    \label{example-table}
    \begin{center}
        \begin{tabularx}{\textwidth}{|p{0.2\linewidth}|p{0.2\linewidth}|p{0.2\linewidth}|p{0.2}\linewidth|X|}
            \hline
            \multicolumn{5}{|c|}{Example Table} \\
            \hline
            \multicolumn{2}{|c|}{very long text} & \multicolumn{3}{c|}{very long text} \\
            \hline
            \multirow{2}{*}{long text} & %
            \multirow{2}{*}{long text} & %
            \multirow{2}{*}{\makecell{very very \\ long text}} & %
            \multicolumn{2}{c|}{\makecell{very very \\ long text}} \\
            \cline{4-5}
             & & & \makecell{very very \\ long text} & \makecell{very very \\ long text} \\
             \hline
            \makecell{\begin{itemize \item very very long text \item second very very long text \end{itemize}} \\
            \hline
        \end{tabularx}
    \end{center}
\end{table}

Does anyone have ideas or know how to implement the table with LaTeX? Any help would be very much appreciated.

9
  • Welcome to TeX.SE.
    – Mico
    Jul 7, 2021 at 11:28
  • 1
    Just out of idle curiosity: Why did you choose to write \begin{tabularx}{\textwidth}{|p{0.2\linewidth}|p{0.2\linewidth}|p{0.2\linewidth}|p{0.2}\linewidth|X|} rather than, say, \begin{tabularx}{\textwidth}{|*{5}{X|}}? Should final column really be a lot narrower than the first four? Please advise.
    – Mico
    Jul 7, 2021 at 11:29
  • Hey @Mico, thanks. I tried p{0.2\linewidth}, because I thought I could restrain the table size and therefore keep the text from going over the vertical table lines and having automatic linebreaks in the cells. Other than that no particular reason. I am also new to latex, so there might be some stupid stuff happening in the code ...
    – Kaido
    Jul 7, 2021 at 12:10
  • I'm reluctant -- actually, unwilling -- too post an answer that fully implements the layout shown in your screenshot, as I think that parts of the layout you show are highly problematic. In particular, the partial overlaps of rows in column 1, columns 2-4, and columns 5-6 are bound to cause no end of uncertainty and confusion among your readers. Do you absolutely, positively have to come up with a exact LaTeX-based implementation of the layout shown in your screenshot?
    – Mico
    Jul 7, 2021 at 14:29
  • @Mico there is a table like this in a scientific book, which I want to cite and use in my work. I know it looks really problematic, but I am not sure what to do. I could split the table up or try to change the cell positions... do you suggest I exactly quote the source with the table, or rather change it and try to make it more clear and latex friendly?
    – Kaido
    Jul 8, 2021 at 7:32

1 Answer 1

0

Here is a solution. The last four cells I have left blank because they are basically the same as the previous one.

NOTE 1: You probably will have to adjust the \multirow 'nrows' parameter to reflect the actual number of lines covered rather than the number of rows.

NOTE 2: It is probably better to put the table in a landscape page because it is quite wide.

NOTE 3: I used paralist to get more compact item lists.

\documentclass{article}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{paralist}
\newcommand{\itemlist}[1]{%
  \setdefaultleftmargin{1em}{}{}{}{}{}
  \begin{compactitem}#1\end{compactitem}%
}

% Inspired by https://tex.stackexchange.com/a/510318/113546
\newcommand{\Xwdth}[1]{\dimexpr#1\hsize+#1\tabcolsep+#1\tabcolsep+#1\arrayrulewidth-2\tabcolsep-\arrayrulewidth\relax}
\newcommand{\multiX}[3]{\multicolumn{#1}{>{\hsize=\Xwdth{#1}}#2}{#3}}

\begin{document}
\begin{table}[ht]
    \caption{Example Table}
    \label{example-table}
    \begin{center}
        \begin{tabularx}{\textwidth}{|*{6}{X|}}
          \hline
          \multicolumn{6}{|c|}{Example Table} \\
          \hline
          Very very long text &  \multirow[t]{2}{=}{Very very long text} & \multirow[t]{2}{=}{Very very long text} & \multirow[t]{2}{=}{Very very very long text} & \multiX{2}{X|}{Very very long text} \\
          \cline{1-1}\cline{5-6}
          \multirow[t]{5}{=}{Very very long text} & & & & Very very long text & Very very long text \\
          \cline{2-6}
          & Very very long text & Very very long text & Very very long text & Very very long text & Very very long text \\
          \cline{2-6} 
             & {Very very Very very Very very long text
          \itemlist{%
          \item Item number one
          \item Item number two
          }} & & & & \\
            \hline
        \end{tabularx}
    \end{center}
\end{table}

\end{document}

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.