I’m quite new to LaTeX and I’m having a real hard time writing a table that contains some large text in LaTeX.
My goal is to draw a 7 columns by 17 rows table. Each row is subdivided in a 2-row multirow spanning columns 2 to 4. Some cells in columns 5, 6 & 7 span across two rows to reduce repetitive text (see the image below).
Since the table is too large to fit into one page, I'm using the longtable package, and to tweak the look of the table I'm additionally also using the lscape (landscape), array and multirow packages to tweak the look of the table and for the arrangement of some multi-column cells.
The thing is that some cells containing large text is overflowing to the cells below instead of stretching the height of its row. This problem does not seem to happen when not using the multirow{}{}{}
command.
I've searched far and wide on this and other forums for the solution, and have also skimmed the aforementioned package manuals (plus tabular etc.), but after opening more tabs than I care to admit, I give up. A suggestion might be to change the overall design of the table, or even break it in smaller column chunks, but I don't have a choice. The table looks OK-ish in PDF after exporting it from Excel, so I could use \includepdf
from package pdfpages, but this would be a last resort route.
The image below is a sample of what the first few rows of my table would look like in excel:
The MWE below uses package lipsum intermittently to generate some dummy placeholder text (instead of the original):
\documentclass{article}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\usepackage{lscape}
\usepackage{lipsum} % For dummy text
\begin{document}
\newcommand\columnA{0.2\textwidth}
\newcommand\columnB{0.11\textwidth}
\newcommand\columnC{0.13\textwidth}
\newcommand\columnD{0.13\textwidth}
\newcommand\columnE{0.13\textwidth}
\newcommand\columnF{0.3\textwidth}
\newcommand\columnG{0.13\textwidth}
\begin{landscape}
\begin{small}
\begin{longtable}[c]{@{\extracolsep{\fill}}
>{\raggedright\arraybackslash}m{\columnA}
>{\centering\arraybackslash}m{\columnB}
>{\centering\arraybackslash}m{\columnC}
>{\centering\arraybackslash}m{\columnD}
>{\centering\arraybackslash}m{\columnE}
>{\centering\arraybackslash}m{\columnF}
>{\centering\arraybackslash}m{\columnG}
@{}}
\caption{A very big ugly table.\label{table1}}\\
\multirow{2}{\columnA}{\textbf{Study design}} & \multicolumn{3}{c}{\textbf{Participants}} & \multirow{2}{\columnE}{\textbf{Device name (Control options)}} & \multirow{2}{\columnF}{\textbf{User-environment interaction}} & \multirow{2}{\columnG}{\textbf{Type of outcomes assessed}} \\ \cline{2-4}
& \textbf{N} & \textbf{Description*} & \textbf{Diagnosis} & & & \\ \hline
\multicolumn{7}{c}{\textbf{Some category here}} \\ \hline
\endfirsthead
% additional pages' table head rows go here
\endhead
% additional pages' table foot rows go here...
\endfoot
\hline
\multicolumn{7}{l}{Table foot row 1}\\
\multicolumn{7}{l}{* Another foot row 2 \lipsum[10][2] }\\
\endlastfoot
\multirow{2}{\columnA}{Row 1 \lipsum[1][1]} & \textbf{Cases: 4} & \lipsum[1][2] & \lipsum[1][3] & \multirow{2}{\columnE}{\lipsum[1][4]} & \multirow{2}{\columnF}{\lipsum[1][5]} & \multirow{2}{\columnG}{\lipsum[1][6]} \\
& \textbf{Controls: 4} & Not reported & Just three words & & & \\
\multirow{2}{0.2\textwidth}{Row 2 \lipsum[2][1-2]} & \textbf{Cases: 10} & \lipsum[2][2] & \lipsum[2][3] & \multirow{4}{\columnE}{Quite long multirow tex:t \lipsum[2][4]} & \multirow{4}{\columnF}{Super long text \lipsum[2][1-15]} & \multirow{2}{\columnG}{\lipsum[2][6]} \\
& \textbf{Controls: -} & - & - & & & \\
\multirow{2}{\columnA}{Row 3 \lipsum[3][1]} & \textbf{Cases: 1} & two words & some more & & & \multirow{2}{\columnE}{Not that many words here either} \\
& \textbf{Controls: -} & - & - & & & \\
\multirow{2}{\columnA}{Row 4 \lipsum[4][1]} & \textbf{Cases: 9} & \lipsum[4][5] & Good & \multirow{2}{\columnE}{Couple of words} & \multirow{4}{\columnF}{Another short phrase with few words} & \multirow{2}{\columnG}{Yet another short text \& Only two words} \\
& \textbf{Controls: 20} & \lipsum[4][7] & Two words again & & & \\
\multirow{2}{\columnA}{Row 5 \lipsum[5][1-3]} & \textbf{Cases: 4} & something short & Bad & \multirow{2}{\columnE}{Something relatively short but not tiny} & & \multirow{2}{\columnG}{Again, something not that long} \\
& \textbf{Controls: -} & - & - & & & \\
\multirow{2}{\columnA}{Row 6 \lipsum[6][1]} & \textbf{Cases: 3} & \lipsum[6][2] & \lipsum[6][3] & \multirow{2}{\columnE}{\lipsum[6][4]} & \multirow{2}{\columnF}{\lipsum[6][5-10]} & \multirow{2}{\columnG}{Learning skills} \\
& \textbf{Controls: 3} & Short text & A few words & & & \\
\end{longtable}
\end{small}
\end{landscape}
\end{document}
I tried the solutions from these and many other similar questions but I could not reproduce any working solutions and or I reached a point were I found compiling errors and could not get any further down the rabbit hole:
multirow with word wrapped columns in longtable
how to implement a table that has some cells with long texts?
Center multirow text and place it on each page in longtabu when page breaks
I'm new here, so any criticism to the way I wrote the post or the question itself is welcome, and I'll gladly re-edit it if required. Thanks in advance!