1

I need a table where each row has two images and an equation (matrix), however the vertical alignment is going crazy.

How do I specify that both figures and the equation are vertically aligned?

Image and code is below.

enter image description here

\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|}
    \hline
    Point Cloud     & Convergence & Fabric Tensor \\
    \hline
    \includegraphics[width= 4.5cm]{figures/MILDataAll/2.png} &
    \includegraphics[width= 4.5cm]{figures/MILDataAll/ani1.png} &
    \(\begin{bmatrix}0.026&-0.912&-0.41\\-0.996&-0.056&0.063\\-0.081&0.407&-0.91\end{bmatrix}\) \\          
    \hline

\end{tabular}

\end{table}

3
  • 1
    welcome to tex.se! more simple is answer your question if you will extend code snippet to complete small document. for example one of possible solution is \includegraphics[width= 4.5cm, valign=m]{figures/MILDataAll/2.png} ... however this is without knowing document preamble not very useful to you ...
    – Zarko
    Jan 4 '18 at 14:12
  • Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. A MWE should compile and be as small as possible to demonstrate your problem. it's much easier to help you if we have full working code to start from.
    – user30471
    Jan 4 '18 at 14:14
  • Boxes (everything in LaTeX is a box) are aligned by their baselines. Images have their baseline at the bottom. Equations have their baseline in the center. One can use \raisebox to adjust the baseline. For example, \raisebox{-0.5\height}{...} will center an image. Jan 4 '18 at 14:32
0

like this?

enter image description here

extract from my testbed containing code of your table is:

    \begin{table}%
\begin{tabular}{|c|c|>{$}c<{$}|}
\hline
Point Cloud &   Convergence &   Fabric Tensor   \\
\hline
\inserigraphics{figures/MILDataAll/2.png}       
    &
\inserigraphics{figures/MILDataAll/ani1.png} 
    &
\begin{bmatrix}
    0.026   &   -0.912  &   -0.41\\
    -0.996  &   -0.056  &   0.063\\
    -0.081  &   0.407   &   -0.91
    \end{bmatrix}   \\
\hline
\end{tabular}
    \end{table}

and extract of relevant part of preamble is:

\usepackage[demo]{graphics}
\usepackage[export]{adjustbox}
\newcommand\inserigraphics[1]{% shortnes for case that all images has the same width
    \includegraphics[width= 4.5cm,valign=m, margin=0pt 3pt 0pt 3pt]{#1}%
                            }
\usepackage{amsmath}
\usepackage{array}

beside this are other possible solutions (see John Kormylo's comment above. however all move images' and equation's baseline so, that they become vertical aligned.

1

Use adjustbox and the valign=c key:

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{array, makecell}
\usepackage{graphicx, adjustbox}

\DeclareUnicodeCharacter{200E}{}%{Left-to-Right!!!}

\begin{document}

\begin{table}[!htb]
\centering\setcellgapes{3pt}\makegapedcells
\begin{tabular}{|c|c|c|}
    \hline
    Point Cloud & Convergence & Fabric Tensor \\
    \hline
    \adjincludegraphics[width= 4.3cm, valign = c]{AliceSteadman} &
    \adjincludegraphics[width= 4.3cm, valign = c]{Charles-Dodgson} &
    \(\begin{bmatrix}0.026&-0.912&-0.41\\-0.996&-0.056&0.063\\-0.081&0.407&-0.91\end{bmatrix}\) \\
    \hline
\end{tabular}
\end{table}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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