表格中文本和图像的垂直对齐问题

表格中文本和图像的垂直对齐问题

在此处输入图片描述我正在尝试创建一个表格,其中文本和图像(在单独的单元格中)都左对齐、上对齐。这是我得到的:附件 pdf。我在 Google 上搜索过 StackExchange,但没有成功。请帮忙。提前致谢。

\documentclass[14pt]{extarticle}
\usepackage{graphicx}
\usepackage{geometry}

\usepackage{tabularx}
\usepackage{wrapfig}
\usepackage{array}
 \geometry{
     letterpaper,
     total={170mm,257mm},
     left=20mm,
     top=20mm,}
\graphicspath{ {C:/Users/Mark/Desktop/Tutoring/Math and Science Images/Geometry} }

\begin{document}
 
\begin{tabular}{p{0.6cm}|p{6cm}|p{7cm}}
\hline\\
1. & This is a test question: $y =\sqrt{x-3}$. And continue to say something useless in order to see what this will look like. & \includegraphics[width=4cm]{Triangle Right - Three Sides and Labeled a b c.jpg} \\
\hline\\
2. &  If a = 12 and b = 10                                                           &  Image\\
   &                                                             &  \\
   &                                                             & 
\end{tabular}


\end{document}

答案1

如果可以将图像绘制为tikzpicture(可以从所讨论的图像中得出结论),那么使用tabularray包可以轻松获得以下结果:

在此处输入图片描述

前两列的内容被推到单元格顶部,tikzpicture在图片垂直中心定义了基线:

\documentclass[14pt]{extarticle}
\usepackage[margin=20mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,
                quotes}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{width=0.75\linewidth,
             hlines, vline{2-Y},
             colspec = {Q[c,h] X[j,h] X[l]},
             rowsep=5pt
             }
1.  &   This is a test question: $y =\sqrt{x-3}$. And continue to say something useless in order to see what this will look like.
        &   \tikz[baseline=(current bounding box.center),
                  node distance=33mm and 44mm]%
                  {
                 \coordinate (a);
                 \coordinate[right=of a] (b);
                 \coordinate[above=of b] (c);
                 \draw  (a) to["$a$"]   (b)
                            to["$b$"]   (c)
                            to["$c$"]  cycle; 
                }               \\
2.  &   If $a = 12$ and $b = 10$
        &  Image                \\
\end{tblr}

\end{document}

相关内容