[Tex/LaTex] Misplaced \omit when using \multicolumn within \multirow

multicolumnmultirowtablesxetex

I'm trying to put a \multicolumn within a \multirow environment in the following manner:

\documentclass{article}

\usepackage{multirow}
\usepackage{array}
\usepackage{mwe}

\begin{document}
    \begin{tabular}{|p{.03\textwidth}|p{.73\textwidth}|p{.03\textwidth}|p{.15\textwidth}|}
        Test1 & Test2 & Test3 &
        \multirow{1}{*}{\multicolumn{1}{m{\linewidth}}{\includegraphics[width=\linewidth]
        {example-image}}}
    \end{tabular}
\end{document}

For clarification, I have multiple rows in the table (6) and the multirow spans those 6 rows. The inner multicolumn is so that the image is centered within the multirow. However, I get the error:

Misplaced \Omit

Does anyone have any idea why this is happening? Thanks!

Update:

See Christian's answer for fixing the error. But latex was still having trouble centering the picture vertically when one of the rows was had multi line text. As a workaround, I increased the number of rows the multirow is spanning even though there are actually 6. This is admittedly an ugly hack and one I'm not particularly happy with, but it works for now. If anyone has any better solution, I'm open to suggestions.

Update 2:

Ok so update 2. See Christian's revised solution and comments for two possible ways to get around this problem. Thanks Christian for all the help!

Best Answer

I suppose, this is what you meant.

\documentclass{article}

\usepackage{multirow}
\usepackage{array}
\usepackage{mwe}

\begin{document}
  \begin{tabular}{|p{.03\textwidth}|p{.73\textwidth}|p{.03\textwidth}|p{.15\textwidth}|}
          Test1 & Test2 & Test3 & 
    \multicolumn{1}{m{\linewidth}}{\multirow{6}{*}{\includegraphics[scale=0.1]{example-image}}% End of multirow
          }% End of multicolumn
      \\ % End of the first row 
       Line2  & & &\\
       Line3  & & & \\
       Line4  & & & \\
       Line5  & & & \\
       Line6  & & & \\
        \end{tabular}
\end{document}

Another version with vertical centered content, which uses the makecell package and the \multirowcell command, which allows for a vertical shift of the content in the tabular cell (First optional parameter of \multirowcell), which is set to -2pt by me since I have the impression, this aligns correctly, however, it has to be revised if the size/scaling of the image changes. It is a 'hack' as well, but perhaps it is better than adding extra rows.

 \documentclass{article}

    \usepackage{multirow,makecell}
    \usepackage{array}
    \usepackage{mwe}

    \begin{document}
        \begin{tabular}{|p{.1\textwidth}|p{.2\textwidth}|p{.1\textwidth}|p{.15  \textwidth}|}
          \hline
          Test1 & Test2 & Test3 & 
           \multirowcell{6}[-2pt]{\includegraphics[scale=0.1]{example-image}%
           }% End of multirowcell
          \\
           Line2  & & & \\
           Line3  & & & \\
           Line4  & & & \\
           Line5  & & & \\
           Line6  & & & \\
        \hline
        \end{tabular}

    \end{document}

I added the \hline in order to check to the alignment and reduced the width of columns. Please roll back as you desire.

Screenshot multirow cell

By the way, the \multirow command allows also a vertical shifting, but I have not tried that so far.

Related Question