1

I'd like to know how to center de text in the first column for this table:

\begin{figure}
\newcolumntype{a}{>{\columncolor{gray!30}} c}
\centering
\begin{tabular}[!htb]{|a|c|c|c|  }
\hline
\rowcolor{gray!50} 
F/B & 0 [T] & 1 [T] & 4 [T] \\
\toprule
0.03$\left[{\frac{kV}{cm}}\right]$
&\includegraphics[width=38mm]{Graficos/Tablas/Rt_10_F_3000_B_0.pdf}&\includegraphics[width=38mm]{Graficos/Tablas/Rt_10_F_3000_B_2.pdf} &
\includegraphics[width=38mm]{Graficos/Tablas/Rt_10_F_3000_B_4.pdf}\\
\hline \addlinespace[1pt]
...
\end{tabular}
\end{figure}

The result is this: u.u

JPi
  • 13,595
Ana
  • 49
  • See https://tex.stackexchange.com/questions/113022/vertical-alignment-in-tabular-cells-with-variable-height – JPi May 11 '17 at 02:24
  • this question is not duplicate to https://tex.stackexchange.com/questions/113022/vertical-alignment-in-tabular-cells-with-variable-height. however similar questions with images in tables, which has some specific and can be solved on different /more elegant ?/ ways as proposed in answers in link, has been asked many times. Already John Kormilo answer gives better help than answers in links. – Zarko May 11 '17 at 06:02

1 Answers1

1

One solution is to determine the height of the picture and use \raisebox to lift the text half way. The other is to use \raisebox on every picture to center the baseline.

For graphics, \raisebox is better than \parbox.

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{array}
\usepackage{colortbl}
\usepackage{booktabs}

\newlength{\tempdima}

\newcommand{\vcgraphics}[1]% #1 = filename
{\raisebox{-0.5\height}{\includegraphics[width=38mm]{#1}}}

\newcolumntype{a}{>{\columncolor{gray!30}} c}
\begin{document}

\begin{figure}
\settoheight{\tempdima}{\includegraphics[width=38mm]{example-image}}% get image height
\centering
\begin{tabular}[!htb]{|a|c|c|c|  }
\hline
\rowcolor{gray!50} 
F/B & 0 [T] & 1 [T] & 4 [T] \\
\toprule
\raisebox{0.5\tempdima}{0.03$\left[{\frac{kV}{cm}}\right]$}
&\includegraphics[width=38mm]{example-image-a}&\includegraphics[width=38mm]{example-image-b} &
\includegraphics[width=38mm]{example-image-c}\\
\hline \addlinespace[1pt]
0.03$\left[{\frac{kV}{cm}}\right]$
&\vcgraphics{example-image-a}&\vcgraphics{example-image-b} &
\vcgraphics{example-image-c}
\end{tabular}
\end{figure}

\end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thank you, that works very well !!! <3 :3 I tried the answers for others post but those didn't work for me. – Ana May 11 '17 at 15:25