在表格环境中浮动图像

在表格环境中浮动图像

我正在尝试为正在创建的工作表创建一个简单的 2x2 问题设置。我的问题是我无法让图形在问题 #2 中很好地浮动。我尝试了各种浮动环境并以不同的方式换行,但无法让它浮动到图形顶部与文本行齐平并悬挂在文本行下方的位置。提前致谢。

\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}

抛物线

答案1

借助valign=t该包引入的选项,adjustbox无需测量:

在此处输入图片描述

\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}

除了手动调整列宽之外,您还可以使用tabularx以下方法:

\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}

对于更自动化的方法(至少在编号方面),您可能需要查看一下包tasks

\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}

答案2

用于\raisebox将图像降低到以下位置:

在此处输入图片描述

\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}

在 中tabular,常规\baselineskip可用为\normalbaselineskip。因此,我们通过 将图像降低到基线(因此其顶部位于基线上)-\height,然后将其提升回 的 70% \normalbaselineskip

相关内容