0

I'm creating a table with a column full of images. The text in the remaining columns is placed in the bottom of the cells. How can I align the text in the center of the cell, considerating the image?

\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{graphicx}
\usepackage{multicol}
\begin{document}
\begin{table}[htb]
\footnotesize
\centering
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{\textbf{Head 1}} &
\textbf{Head 2 (\si{\cm})}          &
\textbf{Head 3 (\si{\mm})}          \\ 
\midrule
\includegraphics[width=0.15\linewidth]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\ 
\includegraphics[width=0.15\linewidth]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\includegraphics[width=0.15\linewidth]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\includegraphics[width=0.15\linewidth]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

3 Answers 3

2

you want the baseline of the image to be in the centre rather than its bottom edge, you can do this as

\raisebox{-.5\height}{\includegraphics{...}}

or more easily use

\usepackage[export]{adjustbox}

then

\includegraphics[valign=m]{...}
1
  • Thank you! I used the second suggestion. I loaded \usepackage[export]{adjustbox}, then I included the figures in the table using \includegraphics[valing=m,width=0.15\linewidth]{example-image-a} Sep 23, 2017 at 9:00
2

Use the \adjincludegraphics from adjustbox (an extension of the graphicx package) – and add some padding between fiures:

\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{adjustbox}
\usepackage{multicol}

\begin{document}

\begin{table}[htb]
\footnotesize
\centering
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{\textbf{Head 1}} &
\textbf{Head 2 (\si{\cm})} &
\textbf{Head 3 (\si{\mm})} \\
\midrule
\adjincludegraphics[width=0.15\linewidth, valign=c]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\addlinespace
\adjincludegraphics[width=0.15\linewidth, valign=c]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\addlinespace
\adjincludegraphics[width=0.15\linewidth, valign=c]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\addlinespace
\adjincludegraphics[width=0.15\linewidth, valign=c]{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\bottomrule
\end{tabular}
\end{table}

\end{document}
[![enter image description here][1]][1]
0

as supplement to David Carlisle answer. in case that all images has equal options (size) and for add some vertical space around it and for shorter table code, try the following:

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\newcommand\insertimage[1]{% for shorter code in table
    \includegraphics[width=0.15\linewidth,valign=m, margin=0pt 3pt 0pt 3pt]%
                    {#1}}

\begin{document}
\begin{table}[htb]
\footnotesize
\centering
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{\textbf{Head 1}} &
\textbf{Head 2 (\si{\cm})}          &
\textbf{Head 3 (\si{\mm})}          \\
\midrule
\insertimage{example-image-a} & Text & 30 & \numrange{2,4}{4,8} \\
\insertimage{example-image-b} & Text & 30 & \numrange{2,4}{4,8} \\
\insertimage{example-image-b} & Text & 30 & \numrange{2,4}{4,8} \\
\insertimage{example-image}   & Text & 30 & \numrange{2,4}{4,8} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .