# How to make a table with centered images?

On page 6 in this PDF is there a table with centred pictures in the right column.

Does anyone know how to make such a table?

I am using pdflatex.

-
– Joseph Wright Nov 9 '11 at 14:28
– morbusg Nov 9 '11 at 16:46

You need to change the baseline of the images. Usually you center it to the height of the lower case characters (1ex). This can be done using the \raisebox macro or using the valign=m key of the adjustbox package.

See also How to align picture top left in a table? and float left figure in titlepage which are similar.

Here my code which also shows some of the other elements like bold math and stacking:

\documentclass{article}

\usepackage{booktabs}
\usepackage{amsmath}

\providecommand{\textsubscript}[1]{%
\mbox{$_\text{#1}$}%
}

\newcommand{\mystack}[1]{%
\mbox{$\vcenter{% \hbox{\shortstack{#1}}% }% \mathsurround=0pt$}
}

\begin{document}

\begin{tabular}{ccccc}
\toprule
\bfseries Scalar mode &
\bfseries Vector mode &
\bfseries Degeneracy &
$\mathbf{n_{\text{\bfseries eff}}}$ &
\bfseries Near field ($\mathbf{S_Z}$) \\
\midrule
LP\textsubscript{01} &
HP\textsubscript{11} &
2 & 1.44398 & \adjustimage{height=2cm,valign=m}{image1} \\
LP\textsubscript{11} &
\mystack{%
HP\textsubscript{11} \\
TE\textsubscript{01} \\
TM\textsubscript{01}
} &
4 & 1.44381 & \adjustimage{height=2cm,valign=m}{image2} \\
.. \\
\midrule
\midrule
.. \\
\bottomrule
\multicolumn{5}{l}{%
*The LP\textsubscript{31} is four-fold ...
}\\
\end{tabular}

\end{document}


-

There are a range of approaches to vertically-centring material. The LaTeX3 'coffin' concept makes this pretty easy to achieve:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{xcoffins}
\NewCoffin\tablecoffin
\NewDocumentCommand\Vcentre{m}
{%
\SetHorizontalCoffin\tablecoffin{#1}%
\TypesetCoffin\tablecoffin[l,vc]%
}
\begin{document}
\begin{tabular}{ccc}
\Vcentre{A} & \Vcentre{B} &
\Vcentre{\includegraphics[width = 1 cm, height = 1 cm]{demo}}
\end{tabular}
\end{document}


The idea here is that the 'coffin' is places such that it's vertical centre is in line with the current baseline, while it is horizontally placed at the current insertion point. (I have used the demo option for the graphicx package so that something appears: the black blob. For a real document, this is not needed.)

As Mark has already said, for the rules booktabs is the way to go.

-
xcoffins has documentation now! Excellent. I've been waiting for this... – Seamus Nov 9 '11 at 15:16
Wow, didn't know about xcoffins. This always bothered me a bit. Time to do some reading... – qubyte Nov 9 '11 at 15:34
We're still not 100% sure on the best user interface, hence xcoffins being 'l3experimental'. Feedback most welcome :-) – Joseph Wright Nov 9 '11 at 17:48

You'll get pretty close output for the table itself with the booktabs package. As for the images, a straightforward \includegraphics should do the trick.

\usepackage[demo]{graphicx}
\usepackage{booktabs}
\usepackage{array}

\begin{document}
\begin{tabular}{m{1.5cm}m{1.5cm}m{1.5cm}}
\toprule