我需要一个表格,其中每行有两幅图像和一个方程(矩阵),但是垂直对齐变得疯狂。
如何指定图形和方程式垂直对齐?
图像和代码如下。
\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}
\茶几}
答案1
像这样?
从我的测试平台中提取的包含您表格的代码是:
\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}
序言相关部分的摘录如下:
\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}
除此之外还有其他可能的解决方案(见约翰·科米洛 上面的评论。然而,所有移动图像和方程的基线,以便它们垂直对齐。
答案2
使用方法adjustbox
及valign=c
关键:
\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}