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.

I have a problem when including an image inside a table using the multirow option. My problem comes from the vertical space dedicated to this row. As you can see in the picture included, the image gets more vertical space than the dedicated to the row. As you can see the image is not fully included

Here, I put the latex code I have used for generating the above picture:

\begin{table}[!htb]
\centering
\begin{tabular}{m{1.5cm}c ccccc}
\toprule 
& & $1024 \times 1024$ & $512 \times 512$ &$256 \times 256$ & $128 \times 128$ & $64  \times 64$ \tabularnewline
\midrule
\multirow{3}{*}{\includegraphics[height=.15\textwidth{../images/BestViews/PVMTooth/3.PVMTooth.dir/1024x1024-0613}}& Time & 254.2 & 57.63 & 17.61 & 4.77& 2.07  \tabularnewline
& Best Entropy & 3.0 & 3.49 & 4.28 & 5.88 & 8.56 \tabularnewline
& Worst Entropy & 1.23 & 1.52 &1.9&2.6 & 4.67 \tabularnewline
\midrule
\bottomrule
\end{tabular}
\caption{The best and worst views according to our measure for different image size.}
\label{table:BB:BestAndWorstNumbers}
\end{table} 

Thanks in advance.

share|improve this question
    
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Christian Hupfer Apr 13 at 11:14

2 Answers 2

Give some vertical space substituting \tabularnewline with \\[1.25ex].

MWE:

\documentclass{article}
\usepackage{array,multirow,booktabs}
\usepackage[demo]{graphicx}

\begin{document}
\begin{table}[!htb]
\centering
\begin{tabular}{m{1.5cm}c ccccc}
\toprule
& & $1024 \times 1024$ & $512 \times 512$ &$256 \times 256$ & $128 \times 128$ & $64  \times 64$ \\
\midrule
\multirow{3}{*}{\includegraphics[height=.15\textwidth,width=1cm]{../images/BestViews/PVMTooth/3.PVMTooth.dir/1024x1024-0613}}
& Time & 254.2 & 57.63 & 17.61 & 4.77& 2.07  \\[1.25ex]
& Best Entropy & 3.0 & 3.49 & 4.28 & 5.88 & 8.56 \\[1.25ex]
& Worst Entropy & 1.23 & 1.52 &1.9&2.6 & 4.67 \\[1.25ex]
\midrule
\bottomrule
\end{tabular}
\caption{The best and worst views according to our measure for different image size.}
\label{table:BB:BestAndWorstNumbers}
\end{table} 
\end{document} 

enter image description here

Another option is to give all the spacing at the end:

\documentclass{article}
\usepackage{array,multirow,booktabs}
\usepackage[demo]{graphicx}

\begin{document}
\begin{table}[!htb]
\centering
\begin{tabular}{m{1.5cm}c ccccc}
\toprule
& & $1024 \times 1024$ & $512 \times 512$ &$256 \times 256$ & $128 \times 128$ & $64  \times 64$ \\
\midrule
\multirow{3}{*}{\includegraphics[height=.15\textwidth,width=1cm]{../images/BestViews/PVMTooth/3.PVMTooth.dir/1024x1024-0613}}
& Time & 254.2 & 57.63 & 17.61 & 4.77& 2.07  \\
& Best Entropy & 3.0 & 3.49 & 4.28 & 5.88 & 8.56 \\
& Worst Entropy & 1.23 & 1.52 &1.9&2.6 & 4.67 \\[3.75ex]
\midrule
\bottomrule
\end{tabular}
\caption{The best and worst views according to our measure for different image size.}
\label{table:BB:BestAndWorstNumbers}
\end{table} 
\end{document} 

enter image description here

share|improve this answer

You can use the cellspace package, that ensures a minimal vertical spacing between the top of a cell and the bottom of the above cell, and symmetrically between its bottom and the top of the below cell. It works with most column types but not with \multirow. To activate this feature it suffices to write an S before the type of one column ; I chose the text (second) column that I changed to l (I like it better that way) and adapted the minimal spacing via a command defined in preamble. Of course if you have may tables with different image heights, you'll have to determine its value each time, but it's only 1 line to write per table, so I hope you'll find it less time-consuming.

Anyway here is an example. I centred the numerical value with respect to the decimal dot with numprint when necessary:

\documentclass[a4paper, 11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{graphicx}%[draft]
\usepackage{array, booktabs, multirow}
\usepackage[autolanguage]{numprint}
\newcolumntype{D}{>{\hfill}N{3}{2}<{\hfill}}
\newcommand*\cellspacelimit[1]{\setlength{\cellspacetoplimit}{#1}\setlength{\cellspacebottomlimit}{#1}}

\usepackage{cellspace}
\begin{document}

\begin{table}[!htb]
\cellspacelimit{10pt}
\centering
\begin{tabular}{c Sl  DDDcc}%{m{1.5cm}}
\toprule
\addlinespace
& & {$1024 \times 1024$} & {$512 \times 512$} &{$256 \times 256$} & $128 \times 128$ & $64  \times 64$ \tabularnewline
\midrule
\multirow{3}{*}{\includegraphics[height=.2\textwidth]{AliceSteadman.png}} & Time & 254.2 & 57.63 & 17.61 & 4.77& 2.07  \tabularnewline
& Best Entropy & 3.0 & 3.49 & 4.28 & 5.88 & 8.56 \tabularnewline
& Worst Entropy & 1.23 & 1.52 &1.9&2.6 & 4.67 \tabularnewline
\midrule
\bottomrule
\end{tabular}
\caption{The best and worst views according to our measure for different image size.}
\label{table:BB:BestAndWorstNumbers}
\end{table}

\end{document} 

enter image description here

share|improve this answer
    
But, these kind of solutions are time-consuming depending on the number of tables that you have and also on the number of different images you have to include inside the tables. I would like to find some automatic solution to my problem, although the proposals you have done solutionate my problem. I will be waiting for a less time-consuming solution. But, in any case, thanks for yours proposals. –  EvaMonclús Apr 13 at 11:57
    
@EvaMonclús: I've entirely changed my answer, which is now less time-consuming, I think. –  Bernard Apr 13 at 13:11
    
Thanks a lot!!! –  EvaMonclús Apr 16 at 8:31
    
My main problem is that the dimensions of the images are different. So, in the end, I have to manually adjust the size of them or use your first answer. –  EvaMonclús Apr 16 at 8:40
    
??? The original dimension of my image also was different; it was scaled through height=.2\textwidth. Adjustment can be achieved with a suitable value of cellspacelimit. You also could play with \arraystretch, but the rows then are no more vertically centred. Another solution would be tu insert in a cell an invisible rule (0pt thickness) but itlonger to determine the exact values of its depth and height so that the cell remains vertically centred. –  Bernard Apr 16 at 8:53

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.