使用多行选项在表格内添加图像时,我遇到了问题。我的问题来自此行专用的垂直空间。如您在所附图片中看到的,图像获得的垂直空间比行专用的垂直空间更大。
在这里,我放上了用于生成上图的 latex 代码:
\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}
提前致谢。
答案1
给出一些垂直空间,\tabularnewline
用替换\\[1.25ex]
。
梅威瑟:
\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}
另一个选择是在末尾给出所有间距:
\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}
答案2
您可以使用 cellspace
包,确保单元格顶部与上方单元格底部之间有最小垂直间距,并且其底部与下方单元格顶部之间对称。它适用于大多数列类型,但不适用于 \multirow。要激活此功能,只需在某一列的类型前写一个 S 即可;我选择了要更改为的文本(第二)列l
(我更喜欢这种方式),并通过序言中定义的命令调整最小间距。当然,如果您有许多具有不同图像高度的表格,则每次都必须确定其值,但每个表格只需写一行,所以我希望您会发现它耗时更少。
无论如何,这是一个例子。必要时,我会将数值相对于小数点居中numprint
:
\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}