1

I am creating a table that will use \multirow (and \multicolumn) command(s). Before compilation, I can imagine what I expect and it is this:

enter image description here

So, my code look like this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}

\begin{table}
  \centering
  \caption{My caption here}\label{tab:4}
\begin{tabular}{p{3cm} p{3cm}p{3cm}p{3cm}}\toprule
  \multirow{2}{3cm}{\textbf{Something ForSure ThreeLined }}& \multicolumn{3}{c}{\bfseries Just a phrase}\\
  & \textbf{Word1} & \textbf{Word2} & \textbf{Word3}\\
Third row & Upper1 & Upper2 & Upper3\\
 & & Lower2 (With a text of description) & Lower3 (With a text of description)\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

(Initially the p columns was m and the "third row")

And I feel ok, until I give the compilation command.

Then the output is this:

enter image description here

And for the first minutes I am looking for my mistake on searching a "3" instead of "2" inside my multirow command... But no luck... Then looking for missing "&" or several possible typos etc.

Then I decided to create a MWE with changes from m to p column types... Now I am here and my question is:

Does \multirow supposed to behave like this? Or is this something that can (and have to) be fixed like a bug?

I know that I can fix the code by adding an empty row after the \miltirow command. But is it supposed to be compiled like this?

PS: The working code for them who are interested is here:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}

\begin{table}
  \centering
  \caption{My caption here}\label{tab:4}
\begin{tabular}{p{3cm} p{3cm}p{3cm}p{3cm}}\toprule
  \multirow{2}{3cm}{\textbf{Something ForSure ThreeLined }}& \multicolumn{3}{c}{\bfseries Just a phrase}\\
  & \textbf{Word1} & \textbf{Word2} & \textbf{Word3}\\&&&\\
Third raw & Upper1 & Upper2 & Upper3\\
 & & Lower2 (With some text of description) & Lower3 (With some text of description)\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
  • 1
    You know it will take three lines (at least this is how I interpret "Something ForSure ThreeLined") but nevertheless tell mutlirow that these will be 2 rows (by choosing the argument 2) and then you are surprised by the outcome? Are you secretly looking for makecell (so that you can squeeze 3 lines of text in 2 rows) or what do you want to achieve? – user121799 Sep 26 '18 at 22:53
  • @marmot: If I split is inside a tabular (tabular in tabular) but still inside the multiline command, then it is supposed to be just two lines tall the "multirowed" cell. Not 3... But it still gives the same error. If I am loosing something simple, please correct me. – koleygr Sep 26 '18 at 23:02
  • 1
    in multirow cell had not to be more text lines than spanned lines by it. in your case, multirow spanned two lines (rows) of text. in this you cant write three lines. consequently third line spill out of cell. high of multirow cell is not determined by it content but by number of spanned rows. – Zarko Sep 26 '18 at 23:02
  • So, @Zarko, If I give a specific width in the multirow column... Then I supposed to know how many lines will be used? If so, just make it an answer to not leave ananswered the question... Or I will search for a duplicate ... (most possible someone else had the same problem) – koleygr Sep 26 '18 at 23:05
  • 1
    @marmot, I was ready to write a sorry that didn't understood your first comment... With "error" I meant the unexpected for me (and some other people [see Zarco's answer or compare with the behavior of multicolumn]). I thought that the multirow command will create a cell as tall as its first argument (not in real lines... but in comparsion with the rest of the cells). At least if I had wrote such a command, this would be its expected behavior. The similarity in the names "multicolumn" and "multirow" is what made some people to think like this. But.. different creators of these two commands.. – koleygr Sep 26 '18 at 23:27
1

the multirow cells does not work as many people expect: that its size, i.e. height is determined by its content. contrary, it is determined by sum of heights of text lines in spanned rows in other columns.

for example: in your case its height is determined by two rows height in other columns of table. consequently the third line of text spill-out of the cell (in your case at bottom).

what can be done? in advance not much. you should first know, how many lines of text are in spanned rows and how many lines would content of multirow cell will has. so after that you can make fine tuning. for example in your mwe you can increase height of rows with change of arraystretch:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, makecell}
\usepackage{multirow}
\begin{document}

\begin{table}
  \centering
  \renewcommand\arraystretch{1.6}
  \caption{My caption here}\label{tab:4}
\begin{tabular}{p{3cm} p{3cm} p{3cm} p{3cm}}
    \toprule
\multirow[t]{3}{=}{\textbf{Something ForSure ThreeLined }}
    & \multicolumn{3}{c}{\bfseries Just a phrase}           \\
    & \textbf{Word1} & \textbf{Word2} & \textbf{Word3}      \\
Third row   & Upper1 & Upper2 & Upper3                      \\
    &       & Lower2 (With a text of description)
                     & Lower3 (With a text of description)  \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

which gives:

enter image description here

note: i select \multirow[t]{3}{=}{...} since spanned rows has height of three lines of regular text (third line "belong" to additional vertical space in cells forced by setings \renewcommand\arraystretch{1.6}).

  • Thanks for the information @Zarco. I think that the problem is that someone want to keep multirow package alive. The easiest think is to write one more useful multirow command inside the core of TeXlive and let multirow die. Hahaha. – koleygr Sep 26 '18 at 23:30
  • @koleygr, well package is very useful. recent version (i use some features from it) has fine documentation and new features. however, regarding vertical size its behave as i described. – Zarko Sep 26 '18 at 23:35
  • Thanks @Zarco... I will take a look ... (and add a feature request too, if I see it can be combined with the rest of its behavior...) – koleygr Sep 26 '18 at 23:37
  • @koleygr, realizing this feature request is not trivial. it means, that the other rows had to be automatically redesigned (changed their heights). so, we can't expect that this will happen in near future or that this will happen at all. – Zarko Sep 26 '18 at 23:43
  • May be you are right... So, my feature request is for LaTeX2e and LaTeX3... :P – koleygr Sep 26 '18 at 23:48

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.