1

I want to have a long table that looks like as follows:

enter image description here

I have tried the following:

% Please add the following required packages to your document preamble:
% \usepackage{multirow}
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{|l|l|l|l|}
\hline
\multicolumn{2}{|l|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} \textbf{Issue}}}                                                                                                         & \multicolumn{2}{l|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} \textbf{Findings}}}                                              \\ \hline
\multicolumn{2}{|l|}{\cellcolor[HTML]{C0C0C0}{\color[HTML]{000000} \textbf{Theme 1}}}                                                                                                       & \multicolumn{2}{l|}{\cellcolor[HTML]{C0C0C0}{\color[HTML]{000000} \textbf{Name of Theme 1}}}                                       \\ \hline
Project 1                   & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam,nonumy eirmod.                                                                              & MS 1: & Vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan,et iusto odio dignissim qui blandit praesent luptatum \\ \hline
                            &                                                                                                                                                               & MS 2: & Ut wisi enim ad minim veniam, quis nostrud exerci tation                                                                   \\ \cline{3-4} 
                            &                                                                                                                                                               & MS 3: & Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse,molestie consequat                                    \\ \cline{3-4} 
\multirow{-3}{*}{Project 2} & \multirow{-3}{*}{At vero eos et accusam et justo duo dolores et ea rebum. Stet clita,kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.} & MS 4: & Stet clita kasd gubergren, no sea takimata sanctus est.                                                                    \\ \hline
\multicolumn{2}{|l|}{\cellcolor[HTML]{C0C0C0}\textbf{Theme 2}}                                                                                                                              & \multicolumn{2}{l|}{\cellcolor[HTML]{C0C0C0}\textbf{Name of Theme 2}}                                                              \\ \hline
Project 3                   & Ullamcorper suscipit lobortis nisl ut aliquip ex ea,commodo consequat.                                                                                        & MS 5: & Sed diam nonumy eirmod tempor invidunt ut labore et dolore magna,aliquyam erat.                                            \\ \hline
Project 4                   & Justo duo dolores et ea rebum. Stet clita kasd gubergren                                                                                                      & MS 6: & Dignissim qui blandit praesent luptatum zzril delenit augue duis,dolore te feugait nulla facilisi.                         \\ \hline
\multicolumn{2}{|l|}{\cellcolor[HTML]{C0C0C0}\textbf{Theme 3}}                                                                                                                              & \multicolumn{2}{l|}{\cellcolor[HTML]{C0C0C0}\textbf{Name of Theme 3}}                                                              \\ \hline
Project 5                   & Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt,ut labore et dolore magna aliquyam erat.                                                  & MS 7: & Nam liber tempor cum soluta nobis eleifend option congue nihil,imperdiet doming id quod mazim placerat facer possim assum. \\ \hline
\end{tabular}
\end{table}

However, this does not look like the table I want to have. Can anybody help me?

1
  • 1
    you say longtable and tagged the question that way but your example does not use longtable do you need this table to take more than one page? for the columns you have llll but beed lp{3cm}lp{3cm} (or some other width) so columns 2 and 4 take paragraphs of text – David Carlisle Sep 11 '17 at 20:00
3

enter image description here

  • since you not provided mwe -- a small complete document beginning with \documentclass{...} and ending with \end{document} i guess what is in your document preamble and how is defined page layout
  • for cells with multi lines content you need to define column type p{...} or X from package tabularx
  • for multi row cells with multi lines content you need to define its width. recent version of multirow package offer option {=} which overtake column format.
  • i assume, that in multi row cells you like to have text in cells on their top. for this positioning is used option [t] also defined in the recent version of multirow package.

\documentclass{article}
\usepackage{ragged2e}
\usepackage[table]{xcolor}
\usepackage{booktabs, multirow, tabularx}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{hhline}
\usepackage[skip=1ex]{caption}

    \begin{document}
\begin{table}[htb]
\centering
\setlength\tabcolsep{4pt}
    \caption{My caption}
\label{my-label}
\begin{tabularx}{\linewidth}{|l|L|l|L|}
    \hhline{|--|--|}
    \rowcolor{black}
\multicolumn{2}{|l|}{\color{white} \textbf{Issue}}
        &   \multicolumn{2}{l|}{\color{white} \textbf{Findings}}    \\
    \hhline{|--|--|}
    \rowcolor{gray!50}
\multicolumn{2}{|l|}{\textbf{Theme 1}}
        &   \multicolumn{2}{l|}{\textbf{Name of Theme 1}}           \\
    \hhline{|--|--|}
Project 1
    &   Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
        sed diam,nonumy eirmod.                                                                              & MS 1: &   Vel illum dolore eu feugiat nulla facilisis at vero
                    eros et accumsan, et iusto odio dignissim qui
                    blandit praesent luptatum                       \\ \hline
\multirow[t]{10}{*}{Project 2}
    & \multirow[t]{10}{=}{At vero eos et accusam et justo duo dolores
                        et ea rebum. Stet clita,kasd gubergren,
                        no sea takimata sanctus est Lorem ipsum
                        dolor sit amet.}
        & MS 2: &   Ut wisi enim ad minim veniam,
                    quis nostrud exerci tation                      \\ \cline{3-4}
    &   & MS 3: &   Duis autem vel eum iriure dolor in hendrerit
                    in vulputate velit esse,molestie consequat      \\ \cline{3-4}
    &   & MS 4: &   Stet clita kasd gubergren, no sea takimata
                    sanctus est.                                    \\
    \hhline{|--|--|}
    \rowcolor{gray!50}
\multicolumn{2}{|l|}{\textbf{Theme 2}}
    &   \multicolumn{2}{l|}{\textbf{Name of Theme 2}}               \\
    \hhline{|--|--|}
Project 3
    &   Ullamcorper suscipit lobortis nisl ut aliquip ex ea,
        commodo consequat.                                                                                        & MS 5: &   Sed diam nonumy eirmod tempor invidunt ut labore
                    et dolore magna, aliquyam erat.                 \\ \hline
Project 4
    &   Justo duo dolores et ea rebum. Stet clita kasd gubergren
        & MS 6: &   Dignissim qui blandit praesent luptatum
                    zzril delenit augue duis,dolore te feugait
                    nulla facilisi.                                 \\ \hline
    \rowcolor{gray!50}
\multicolumn{2}{|l|}{\textbf{Theme 3}}
    &   \multicolumn{2}{l|}{\textbf{Name of Theme 3}}               \\ \hline
Project 5
    &   Consetetur sadipscing elitr,
        sed diam nonumy eirmod tempor invidunt,
        ut labore et dolore magna aliquyam erat.                                                  & MS 7: &   Nam liber tempor cum soluta nobis eleifend option
                    congue nihil, imperdiet doming id quod mazim placerat
                    facer possim assum.                             \\
    \hline
\end{tabularx}
\end{table}
    \end{document}

note: i above mwe i consider your mwe and not "longtable" tag of your question. recent version of multirow package is release 2016/11/25, version v2.2.

6
  • Thank you for your answer Zarko! However, if I comply your solution in a fresh document, I get a "Missing number, treated as zero. \end{tabularx}" as well as "Illegal unit of measure (pt inserted). \end{tabularx}" error. How can I solve this? Thanks. – Ferit Sep 12 '17 at 8:14
  • @Ferit, without seeing this document i can't say anything what is going wrong. i test my mwe again and it works (no errors, no warnings, no bad boxes). to help you please ask new question or edit this and show how you test/use my mwe and see, if we reproduce mentioned error. – Zarko Sep 12 '17 at 10:25
  • It's weird because I opened a new document in Texstudio and copied your mwe but unfortunately it won't compile as I get the beforementioned errors. :-/ – Ferit Sep 12 '17 at 10:41
  • I was wrong that it did not compile. It compiled with errors but it looks a bit different than your image - see: imgur.com/a/M85kL I mentioned in the title that I need a longtable landscaped. Is it possible to build the table with longtable and landscape? If yes, how can I do that? – Ferit Sep 12 '17 at 10:51
  • did you have installed recent version of multirow package (2016/11/25, version v2.2)? it seems that its syntax is not recognized. (option [t] and option {=}) . – Zarko Sep 12 '17 at 11:00

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.