How to make a table with centered images?
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.
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{adjustbox}
\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
\multicolumn{5}{c}{\bfseries Originally cladding modes} \\
\midrule
.. \\
\bottomrule
\multicolumn{5}{l}{%
*The LP\textsubscript{31} is four-fold ...
}\\
\end{tabular}
\end{document}
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
Header 1 & Header 2 & Header 3\\
\midrule
One & Two & \includegraphics[width=1cm, height=1cm]{fig1}\\
Three & Four & \includegraphics[width=1cm, height=1cm]{fig2}\\
\bottomrule
\end{tabular}
\end{document}
Produces this: