1

enter image description hereI am trying to create a table with both text and images (in separate cells) are left, top justified. This is what I get: attached pdf. I have googled and searched StackExchange but no luck. Please help. Thanks in advance.

\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}
2
  • Remove the \\ after the \hline commands, add \usepackage[export]{adjustbox} to the preamble ans use \includegraphics[width=4cm, valign=t].
    – leandriis
    Apr 22, 2022 at 18:22
  • Thank you so much @leandriis It worked!
    – Mark Barry
    Apr 22, 2022 at 18:30

1 Answer 1

1

If image can be drawn as tikzpicture (as can be concluded from image in question), than with use of tabularray package can be easy obtain the following result:

enter image description here

Content of the first two columns are push to top of cells, tikzpicture has defined baseline at picture vertical center:

\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}
2
  • Thank you for this suggestion.
    – Mark Barry
    Apr 23, 2022 at 14:24
  • 1
    @MarkBarry, does answer solve your problem? If yes, you may consider to accept them (by clicking on check mark at top left side of answer) :-)
    – Zarko
    May 23, 2022 at 1:18

You must log in to answer this question.

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