0

The following example mc.tex (found on the web) works (pdflatex on Linux/Debian/unstable, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian and LaTeX2e <2018-04-01> patch level 5) (preloaded format=pdflatex):

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
  \caption{Partial horizontal line}
  \begin{tabular}{ccc}
    \hline
    \multicolumn{2}{c}{\multirow{2}{*}{multi-col-row}}&\\
    \cline{1-2}
    X1&X2&X3\\
    Y1&Y2&Y3\\
    \hline
  \end{tabular}
  \label{tab:multicol}
\end{table}
\end{document}

but the similar example mc1.tex below does not work:

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
  \caption{Partial horizontal line}
  \begin{tabular}{ccc}
    \hline
    \multicolumn{2}{c}{\multirow{2}{*}{\begin{minipage}[t]{0.2\textwidth}
          \smallskip

          \textbf{\Large XX}

          here is yyyyy text
        \end{minipage}
    }}&\\
    \cline{1-2}
    X1&X2&X3\\
    Y1&Y2&Y3\\
    \hline
  \end{tabular}
  \label{tab:multicol}
\end{table}
\end{document}

I'm getting the following error:

 % pdflatex mc1.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./mc1.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo))
(/usr/share/texlive/texmf-dist/tex/latex/multirow/multirow.sty) (./mc1.aux)
Runaway argument?
{\begin {minipage}[t]{0.2\textwidth } \smallskip 
! Paragraph ended before \@xmultirow was complete.
<to be read again> 
                   \par 
l.15     }}
           &\\

How to have a minipage inside a multirow in tabular?

2

The problem is that while \multirow itself might be a long macro, it passes its arguments on to \@multirow which is not defined \long, so it can't take any \par or empty rows in its argument. The offending part is therefore not your minipage but the two \par tokens contained in it (the empty rows). One can trick this parsing rule by using \endgraf instead of \par (\endgraf then expands to \par). So the following works without issues:

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
  \caption{Partial horizontal line}
  \begin{tabular}{ccc}
    \hline
    \multicolumn{2}{c}{\multirow{2}{*}{\begin{minipage}[t]{0.2\textwidth}
          \smallskip
          \endgraf
          \textbf{\Large XX}
          \endgraf
          here is yyyyy text
        \end{minipage}
    }}&\\
    &\\
    &\\
    &\\
    \cline{1-2}
    X1&X2&X3\\
    Y1&Y2&Y3\\
    \hline
  \end{tabular}
  \label{tab:multicol}
\end{table}
\end{document}

If your only contents of those two columns is a minipage, it might be a better idea to use a p type cell in \multicolumn though (\multicolumn is defined \long so can take \par tokens directly):

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
  \caption{Partial horizontal line}
  \begin{tabular}{ccc}
    \hline
    \multicolumn{2}{p{.2\textwidth}}{
          \smallskip

          \textbf{\Large XX}

          here is yyyyy text
    }&\\
    \cline{1-2}
    X1&X2&X3\\
    Y1&Y2&Y3\\
    \hline
  \end{tabular}
  \label{tab:multicol}
\end{table}
\end{document}
  • Thank you so much you have saved my day! – trouselife Jun 6 at 15:40

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.