Wrapped text getting merged with column values

I am using the following code for a table which doesn't look pleasing at all. I was able to wrap text but it is getting merged in the values given in the column. Any help would be appreciated.

\begin{document}
\begin{table}[]
\begin{tabular}{ccccc}
\hline
\multirow{2}{*}{\textbf{Years}} & \multicolumn{3}{c}{\textbf{Days}}
& \multirow{2}{*}{\parbox{4cm} {\centering \textbf{Sediment volume excavated
in the year represented by the boundary of the corresponding range of
years}}} \\ \cline{2-4}
& \textbf{\parbox{1.5cm}
{\centeringQ\textgreater{}10 (m\textsuperscript{3}/s)}} &
\textbf{\parbox{1.5cm} {\centering10\textgreater{}Q\textgreater{}20
(m\textsuperscript{3}/s)}} & \textbf{\parbox{1.5cm} {\centering
Q\textgreater{}20 (m\textsuperscript{3}/s)}} &                         \\
\hline
2002-2003                                & 18
& 15                                                & 3
& 486                                               \\
2003-2006                                & 25
& 18                                                & 7
& 666                                               \\
2006-2010                                & 24
& 22                                                & 2
& 217                                                \\
2010-2013                                & 29
& 19                                                & 10
& 126                                                \\ \hline
\end{tabular}
\end{table}

\end{document}


• Welcome to TeX SX! Please post a full compilable code, not a screenshot of a snippet. – Bernard Nov 6 '18 at 13:13

Use the caption for that big chunk of text.

\documentclass{article}
\usepackage{booktabs,siunitx,caption}

\sisetup{per-mode=symbol}

\begin{document}

\begin{table}[htp]
\centering

\caption{Sediment volume excavated in the year represented by
the boundary of the corresponding range of years}

\begin{tabular}{ccccc}
\toprule
Years & \multicolumn{3}{c}{Days (\si{\meter\cubed\per\second})} & Sediment \\
\cmidrule(lr){2-4}
& $Q<10$ & $10<Q<20$ & $Q>20$ \\
\midrule
2002-2003 & 18 & 15 &  3 & 486 \\
2003-2006 & 25 & 18 &  7 & 666 \\
2006-2010 & 24 & 22 &  2 & 217 \\
2010-2013 & 29 & 19 & 10 & 126 \\
\bottomrule
\end{tabular}

\end{table}


\multirow deliberately overlaps the next row (or several rows). What you need is a strut to push the THIRD row down, which means it has to go on the second row.

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[]
\sbox0{\parbox[t]{4cm}{\centering \textbf{Sediment volume excavated
in the year represented by the boundary of the corresponding range of
years}}}% measuer height
\begin{tabular}{ccccc}
\hline
\multirow{2}{*}{\textbf{Years}} & \multicolumn{3}{c}{\textbf{Days}}
& \multirow{2}{*}{\usebox0} \\
\cline{2-4}
& \textbf{\parbox[t]{1.5cm}
{\centering Q\textgreater{}10 (m\textsuperscript{3}/s)}} &
\textbf{\parbox[t]{1.5cm} {\centering 10\textgreater{}Q\textgreater{}20
(m\textsuperscript{3}/s)}} & \textbf{\parbox[t]{1.5cm} {\centering
Q\textgreater{}20 (m\textsuperscript{3}/s)}} &
\rule[\dimexpr \arraystretch\normalbaselineskip-\dp0]{0pt}{0pt} \\
\hline
2002-2003                                & 18
& 15                                                & 3
& 486                                               \\
2003-2006                                & 25
& 18                                                & 7
& 666                                               \\
2006-2010                                & 24
& 22                                                & 2
& 217                                                \\
2010-2013                                & 29
& 19                                                & 10
& 126                                                \\ \hline
\end{tabular}
\end{table}

\end{document}


This version moves the first row down. Note that I used \raisebox this time. \multirow always tries to center the entry, which we definitely do NOT want here. To overlay the second row, I need to set the depth to 0pt, which can be done using the optional arguments.

It is important to remember where the baseline is for these adjustments, especially when using \parbox.

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[]
\sbox0{\parbox[b]{4cm}{\centering \strut\textbf{Sediment volume excavated
in the year represented by the boundary of the corresponding range of
years}}}% measure height
\sbox1{\textbf{\parbox[t]{1.5cm}
{\centering Q\textgreater{}10 (m\textsuperscript{3}/s)}}}%
\begin{tabular}{ccccc}
\hline
\multirow{2}{*}{\textbf{Years}} & \multicolumn{3}{c}{\textbf{Days}}
& \raisebox{\dimexpr -\dp0-\ht1-\dp1}%
[\dimexpr \ht0-\dp0-\ht1-\dp1][0pt]{\usebox0} \\
\cline{2-4}
& \usebox1 &
\textbf{\parbox[t]{1.5cm} {\centering 10\textgreater{}Q\textgreater{}20
(m\textsuperscript{3}/s)}} & \textbf{\parbox[t]{1.5cm} {\centering
Q\textgreater{}20 (m\textsuperscript{3}/s)}} & \\
\hline
2002-2003                                & 18
& 15                                                & 3
& 486                                               \\
2003-2006                                & 25
& 18                                                & 7
& 666                                               \\
2006-2010                                & 24
& 22                                                & 2
& 217                                                \\
2010-2013                                & 29
& 19                                                & 10
& 126                                                \\ \hline
\end{tabular}
\end{table}

\end{document}


This time I put another tabular inside the tabular and used \makebox in one row to match the column widths.

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[]
\sbox0{\begin{tabular}{@{}p{1.5cm}p{1.5cm}p{1.5cm}@{}}
\multicolumn{3}{c}{\textbf{Days}} \\
\hline
\centering\textbf{Q\textgreater{}10 (m\textsuperscript{3}/s)} &
\centering\textbf{10\textgreater{}Q\textgreater{}20 (m\textsuperscript{3}/s)} &
\centering\textbf{Q\textgreater{}20 (m\textsuperscript{3}/s)}
\end{tabular}}% savebox not really needed here
\begin{tabular}{ccccc}
\hline
\textbf{Years} & \multicolumn{3}{c}{\usebox0} &
\parbox{4cm}{\centering \strut\textbf{Sediment volume excavated
in the year represented by the boundary of the corresponding range of
years}\strut} \\
\hline
2002-2003 & \makebox[1.5cm]{18} & \makebox[1.5cm]{15} & \makebox[1.5cm]{3} & 486 \\
2003-2006                                & 25
& 18                                                & 7
& 666                                               \\
2006-2010                                & 24
& 22                                                & 2
& 217                                                \\
2010-2013                                & 29
& 19                                                & 10
& 126                                                \\ \hline
\end{tabular}
\end{table}

\end{document}


• Perfect! Could the headings 'years' and 'days' also be aligned w.r.t the thirst heading, so that it looks cleaner? Thanks a lot for the help! – Bobolo Nov 6 '18 at 22:22
• You want them at the bottom instead of the top? – John Kormylo Nov 6 '18 at 22:31
• In the middle, actually, like in excel. – Bobolo Nov 8 '18 at 8:59