Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Here I come again,

Following the indications on this url I managed to get almost exactly what I want. However the problem is that the first multirow cell (with text "5 and 6") is not vertically centered.

Any help is very much appreciated.

Setup is Miktex 2.9, updated packages from CTAN as of today, Texniccenter 2a3 on win7x32. Profile is Latex->PDF.

Best regards and thanks in advance

\documentclass{article}
\usepackage{multirow,array,tabularx,booktabs}

\begin{document}
\newcolumntype{Z}{>{\centering\arraybackslash}X}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}
\begin{table}[htbp]
\begin{tabularx}{\textwidth}{|Z|Z|Z|}
\hline\hline Number&Image 1&Image 2\\\hline\hline
1&\includegraphics[width=0.2\columnwidth]{images/1.png}&\includegraphics[width=0.2\columnwidth]{images/1a.png}\\\hline
2&\includegraphics[width=0.2\columnwidth]{images/2.png}&\includegraphics[width=0.2\columnwidth]{images/2a.png}\\\hline
3&\includegraphics[width=0.2\columnwidth]{images/3.png}&\includegraphics[width=0.2\columnwidth]{images/3a.png}\\\hline
\multirow{2}{*}{5 and 6}&\multirow{2}{*}{\includegraphics[width=0.2\columnwidth]{images/56.png}}&\includegraphics[width=0.2\columnwidth]{images/5.png}\\\cline{3-3}
& & \includegraphics[width=0.2\columnwidth]{images/6.png}\\\hline
\end{tabularx}
\caption{Images}
\label{tab:figuretable}
\end{table}

\end{document}
share|improve this question
    
Examples which we can't compile (because of the missing images) are already not very useful. But if even you can't compile your example (because of the missing graphicx package) ... Try to make examples that every one can compile (e.g. replace graphics by \rule{width}{height}), and test them before copy&paste. –  Ulrike Fischer Feb 8 '12 at 13:17
    
@UlrikeFischer Thank you for the tips. I didn't get the missing graphicx package part, I've been including graphics in my documents without the needing to explicitly declare it and the images load just fine. –  Jose R Feb 8 '12 at 14:32
    
If you compile exactly the example you gave above you should get errors. If not your system has been manipulated. But it is quite possible that you don't have to load graphicx explicitly in a larger document. E.g. another package could do it internally. Nevertheless: Never assume that an example does what you think it does, always test it. –  Ulrike Fischer Feb 8 '12 at 14:39
    
@UlrikeFischer Thank you very much for the tips, from now on I will include graphicx package. I did test the example before posting the question and it yielded a page without errors and produced a pdf page output. –  Jose R Feb 8 '12 at 15:05
    
If this example really compiles without errors then one of the standard packages (or the class) you load have been changed - something you should never, never do. This is very bad practice. –  Ulrike Fischer Feb 8 '12 at 15:12

2 Answers 2

up vote 4 down vote accepted

You don't need multirow, for this application: just put the double image in an inner tabular environment. The width of an X column is available as \hsize.

\documentclass{article}
\usepackage{array,tabularx,booktabs}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\newcolumntype{Z}{>{\centering\arraybackslash}X}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}
\begin{table}[htbp]
\begin{tabularx}{\textwidth}{ZZZ}
\toprule
Number&Image 1&Image 2\\
\midrule
1
  &\includegraphics[width=0.2\columnwidth]{images/1.png}
  &\includegraphics[width=0.2\columnwidth]{images/1a.png}\\
\midrule
2
  &\includegraphics[width=0.2\columnwidth]{images/2.png}
  &\includegraphics[width=0.2\columnwidth]{images/2a.png}\\
\midrule
3
  &\includegraphics[width=0.2\columnwidth]{images/3.png}
  &\includegraphics[width=0.2\columnwidth]{images/3a.png}\\
\midrule
5 and 6
  &\includegraphics[width=0.2\columnwidth]{images/56.png}
  &\begin{tabular}{@{}>{\centering\arraybackslash}p{\hsize}@{}}
   \includegraphics[width=0.2\columnwidth]{images/5.png}\\
   \midrule
   \includegraphics[width=0.2\columnwidth]{images/6.png}
   \end{tabular}\\
\bottomrule
\end{tabularx}
\caption{Images}
\label{tab:figuretable}
\end{table}

\end{document}

I've used the rules as in booktabs; if you really prefer boxed tables, change them back to \hline.

share|improve this answer
    
Thank you, I'm marking this as the accepted answer –  Jose R Feb 8 '12 at 15:03

multirow has a final (after the width, before the contents) optional "fixup" argument that allows you to raise or lower the contents, so you can visually achieve the centering you want, even if not fully automatic.

share|improve this answer
    
Thank you very much for your answer, it works however this is not as automatic as you stated. That's why I'm marking @egreg's answer as accepted. –  Jose R Feb 8 '12 at 15:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.