4

I am trying to create a simple 2x2 question set-up for a worksheet I am creating. My problem is that I cannot get my graphic to float nicely with problem #2. I have tried various float environments and wrapping my text in different ways, but can't get it to float to where the top of the graphic is even with the text line and hangs below the text line. Thanks in advance.

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{tabu}
\usepackage{tikz}

\usepackage{wrapfig}
\usepackage{float}

\begin{document}

\noindent {\bf Determine whether each relation is a function.}\\

\begin{table}[ht]
\begin{tabular}{p{0.5\linewidth} p{0.5\linewidth}}
1.  $\left\{(5, -7) (6, -7), (-8, -1), (0, -1)\right\}$ & 2. \includegraphics{parabola}\\
3.   $y=3x-2$ \hspace{20mm} 4.  other stuff \\
\end{tabular}
\end{table}
\end{document}

parabola

2

With the help of the valign=t option introduced by the adjustbox package there is no need for measuring:

enter image description here

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[demo]{graphicx}
\usepackage{calc}

\usepackage[export]{adjustbox}

\begin{document}

\noindent {\bfseries Determine whether each relation is a function.}\\

\begin{table}[ht]
\begin{tabular}{p{0.5\linewidth-2\tabcolsep} p{0.5\linewidth-2\tabcolsep}}
1.  $\left\{(5, -7) (6, -7), (-8, -1), (0, -1)\right\}$ & 2. \includegraphics[valign=t]{parabola}\\
3.   $y=3x-2$ &  4.  other stuff \\
\end{tabular}
\end{table}
\end{document}

As an alternative to manually adjusting the width of the columns, you could also use tabularx as follows:

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[demo]{graphicx}
\usepackage{tabularx}

\usepackage[export]{adjustbox}

\begin{document}

\noindent {\bfseries Determine whether each relation is a function.}\\
\begin{table}[ht]
\begin{tabularx}{\textwidth}{XX}
1.  $\left\{(5, -7) (6, -7), (-8, -1), (0, -1)\right\}$ & 2. \includegraphics[valign=t]{parabola}\\
3.   $y=3x-2$ &  4.  other stuff \\
\end{tabularx}
\end{table}
\end{document}

For an even more automated approach (at least with respect to the numbering) you might want to have a look into the tasks package:

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[demo]{graphicx}
\usepackage{tasks}
\settasks{item-indent=2em, counter-format =tsk[1].}
\usepackage[export]{adjustbox}

\begin{document}

\noindent {\bfseries Determine whether each relation is a function.}\\

\begin{tasks}(2)
\task  $\left\{(5, -7) (6, -7), (-8, -1), (0, -1)\right\}$
\task  \includegraphics[valign=t]{parabola}
\task  $y=3x-2$
\task  other stuff
\end{tasks}
\end{document}
1

Use \raisebox to lower the image into position:

enter image description here

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\noindent \textbf{Determine whether each relation is a function.}

\medskip

\begin{tabular}{p{0.5\linewidth} p{0.5\linewidth}}
  1. $\{(5, -7) (6, -7), (-8, -1), (0, -1)\}$ & 
    2. \raisebox{\dimexpr-\height+.7\normalbaselineskip}{\includegraphics[width=5em]{example-image}} \\
  3. $y = 3x - 2$ & 
    4. other stuff
\end{tabular}

\end{document}

Within a tabular, the regular \baselineskip is available as \normalbaselineskip. So we lower the image to the baseline (so it's top sits on the baseline) via -\height, and then raise it back up 70% of the \normalbaselineskip.

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.