1

This question already has an answer here:

I have a table with images and text and I want to align them to the centre of the cells they're in. Most questions like this one have answers which first fix the cell size and then centre its contents.

How can I do this without having to fix the dimensions of the cell and just align contents of every cell to its centre (I'm specifically referring to vertical alignment since horizontal alignment is taken care of by |c|c|...)

 \begin{table}[H]
    \centering
    \begin{tabular}{c|c|c|c|c}

    \hline \includegraphics[height=1in]{IMG1.jpg} & 1 & 2 & 2 kHz & 1 kHz \\

    \hline \includegraphics[height=1in]{IMG2.jpg} & 1 & 3 & 3 kHz & 1 kHz \\

    \hline \includegraphics[height=1in]{IMG3.jpg} & 2 & 5 & 5 kHz & 2 kHz \\

    \hline

\end{tabular}
\caption{random caption}

\end{table}

This is what the code for my table looks like. The only problem is, in every cell, the image is vertically aligned to the top and the text is vertically aligned to the bottom. How can I fix this?

marked as duplicate by leandriis, Stefan Pinnow, Bobyandbob, TeXnician, Troy Aug 12 '18 at 13:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    welcome to tex.se! to clarify what is your problem, please provide an example of your table in complete but small document beginning with\documentclass{...}and ending with \end{document} – Zarko Aug 12 '18 at 7:43
  • Just like you said, I've added the code – TEC0001 Aug 12 '18 at 7:55
  • Doing that didn't align the image vertically to the centre of the cell. – TEC0001 Aug 12 '18 at 8:11
  • @TEC0001: What exactly does 'that' refer to? The question I linked to contains four answers with different approaches. As one can see in Ignasi's answer, the valign/align option from either the adjustbox od the graphbox package will lead to vertically centered texts and images. – leandriis Aug 12 '18 at 8:16
2

do you looking for something like this:

enter image description here

a complete small document (called mwe: minimal working example), is:

\documentclass[margin=3mm]{standalone}
\usepackage[export, demo]{adjustbox} % it also load "graphicx"
                                     % in real document delete option "demo"
\usepackage{siunitx}                 % added for used units

\begin{document}
\begin{tabular}{c|c|c|c|c}
\hline 
\includegraphics[height=1in, valign=c, margin=0pt 6pt 0pt 6pt]{IMG1.jpg} & 1 & 2 & \SI{2}{kHz} & \SI{1}{kHz} \\
\hline 
\includegraphics[height=1in, valign=c, margin=0pt 6pt 0pt 6pt]{IMG2.jpg} & 1 & 3 & \SI{3}{kHz} & \SI{1}{kHz} \\
\hline 
\includegraphics[height=1in, valign=c, margin=0pt 6pt 0pt 6pt]{IMG3.jpg} & 2 & 5 & \SI{5}{kHz} & \SI{2}{kHz} \\
\hline
\end{tabular}

\end{document}

table code as well necessary preamble should be simple to transfer in your real document.

Not the answer you're looking for? Browse other questions tagged or ask your own question.