GeneralVertical centering of text in a table containing images

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Scribe
Posts: 2
Joined: Fri Jun 13, 2008 8:04 am

Vertical centering of text in a table containing images

Post by Scribe »

Hello,

Trying to center text vertically on the first column of a 4-column table containing images on the remaining 3 columns. I have as preamble a convenient definition for including three images on a line :

Code: Select all

% COMMAND FOR PUTTING THREE IMAGES SIDE BY SIDE
\newcommand{\threeimg}[3]{\includegraphics{#1} & \includegraphics{#2} & \includegraphics{#3}\\
}

% COMMAND FOR PUTTING THREE LABELS SIDE BY SIDE
\newcommand{\threelabels}[3]{#1 & #2 & #3 \\[2mm]}
Then later the figure with the problem :

Code: Select all

\begin{figure*}[!t]
    \centering
    \setkeys{Gin}{width=50mm}
    \begin{tabular}{m{0.12in}ccc}
     & \threelabels{Label 1}{Label 2}{Label 3}
      \begin{sideways}Text 1\end{sideways} & \threeimg{image1.png}{image1.png}{image1.png}
      \begin{sideways}Text2 \end{sideways} & \threeimg{image1.png}{image1.png}{image1.png}
    \end{tabular}
    \caption{Caption}
    \label{fig:ChangeComp}
\end{figure*}
I would like the text of the first column to be centered vertically compared to the vertical extent of the images on the same line. The code here produces text somehow in-between two lines. Replacing "m{0.12in}" by "c" gives slightly better result - bottom aligned. Top alignment "p{0.12in}" doesn't work in that case. Would there be another solution than to use \hspace ?

Thanks in advance for your help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Vertical centering of text in a table containing images

Post by Stefan Kottwitz »

Hi Scribe,

welcome to the LaTeX Community Forum!

You could use m-columns for the remaining columns too. Their horizontal center alignment could be forced by \centering:

Code: Select all

\begin{tabular}{m{0.12in}>{\centering}m{1in}>{\centering}%
  m{1in}>{\centering\arraybackslash}m{1in}}
...
\end{tabular}
Stefan
LaTeX.org admin
Scribe
Posts: 2
Joined: Fri Jun 13, 2008 8:04 am

Vertical centering of text in a table containing images

Post by Scribe »

Thanks, worked like a charm when adapting the column width.

Code: Select all

\begin{tabular}{m{0.12in}>{\centering}m{50mm}>{\centering}m{50mm}>{\centering\arraybackslash}m{50mm}}
Post Reply