Vertical alignment of figure in a tabular. (Automatic width)

I'm trying to align photos and text vertically and horizontally in the middle of each tabular. I've tried the 'array' package but it seems like I need to define the width of the column. I want the column to be adjusted by max length of any object.

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}
\begin{tabular}{lcr}
&                   $\downarrow$                   &              \\
$\rightarrow$ & \rule{4cm}{4cm} & $\leftarrow$ \\
&                    $\uparrow$                    &
\end{tabular}
\end{table}
\end{document}


Where I'm using the \rule function in this example. I want to use a regular figure.

One option is to use adjustbox with export option. Then valign is available as a key to \includegraphics

\documentclass{article}
\usepackage{array}
\usepackage{graphicx}
\begin{document}
\begin{table}
\begin{tabular}{lcr}
&                   $\downarrow$                   &              \\
$\rightarrow$ & \includegraphics[valign=c,width=3cm]{example-image-a} & $\leftarrow$ \\
&                    $\uparrow$                    &
\end{tabular}
\end{table}
\end{document}


And another option is to use raisebox

\documentclass{article}
\usepackage{array}
\usepackage{graphicx}
\begin{document}
\begin{table}
\begin{tabular}{lcr}
&                   $\downarrow$                   &              \\
$\rightarrow$ &
\raisebox{-0.5\height}{\includegraphics[width=3cm]{example-image-a}} & $\leftarrow$ \\
&                    $\uparrow$                    &
\end{tabular}
\end{table}
\end{document}


To be precise, this should be (thanks to Manuel)

\raisebox{\dimexpr-0.5\height+\fontdimen22\textfont2\relax}{\includegraphics[width=3cm]{example-image-a}}

• Perfect... Just perfect. Exactly what I've been trying to achieve. :D Thanks. – Bjartmar Mar 5 '15 at 0:47
• IIRC, the correct value would be \dimexpr-0.5\height+\fontdimen22\textfont2\relax – Manuel Mar 5 '15 at 14:50
• @Manuel Right, next level of procrastination, Thanks :-) – user11232 Mar 5 '15 at 14:54

Well \rule has an optional argument to adjust the vertical alignment:

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}
\begin{tabular}{lcr}
&                   $\downarrow$                   &              \\
$\rightarrow$ & \rule[-2cm]{4cm}{4cm} & $\leftarrow$ \\
&                    $\uparrow$                    &
\end{tabular}
\end{table}
\end{document}


• Thanks for the answer. But I only used the rule command just to add something with large dimension in the table. I'm including figures instead of using black box. I'm sorry, I should've make that clear. – Bjartmar Mar 5 '15 at 0:40