文本和图像对齐问题 Minipage 环境

文本和图像对齐问题 Minipage 环境

我一直在交易所寻找解决方案,但没有取得多大成功。我反复尝试对齐图形和文本,但无法使它们的高度相同。

\documentclass[11pt]{exam}                  
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts} 
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{graphics,graphicx}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.18}
 

        
\pgfplotsset{my style polar/.append style={xticklabels={,,
$\frac{\pi}{6}$, $\frac{\pi}{3}$, $\frac{\pi}{2}$, $\frac{2\pi}{3}$,
$\frac{5\pi}{6}$, $\pi$, $\frac{7\pi}{6}$, $\frac{4\pi}{3}$,
$\frac{3\pi}{2}$, $\frac{5\pi}{3}$,$\frac{11\pi}{6}$,}, thick }}

                        % Activate to display a given date or no dat
\begin{document}

\begin{questions}
\begin{minipage}[t]{8cm}
    \question Given a point with rectangular coordinates $\big(-3,3\sqrt{3}\big)$ find a polar coordinate where $r<0$ and $0\leq \theta<2\pi$ \textbf{use exact answer for $\theta$}.
\end{minipage}
\begin{minipage}{5cm}
\includegraphics[scale=.5]{/Users/nbennett/Dropbox/Mathematics/Courses/2021-2022/PCH/Unit 8/Assessment/graph1.png}
\end{minipage}
\end{questions}

\end{document}

在此处输入图片描述

感谢您的任何帮助

答案1

我不确定我是否正确理解了您的对齐要求,但这里有两个示例,说明如何将问题文本的第一行与图像顶部对齐。在这两个示例中,我都使用了添加到序言valign=t时提供的选项:\usepackage[export]{adjustbox}

红线表示边距:

在此处输入图片描述

\documentclass{exam}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts} 
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{graphics,graphicx}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.18}
 \usepackage[export]{adjustbox} % <----- added in order to provide the valign option used below

        
\pgfplotsset{my style polar/.append style={xticklabels={,,
$\frac{\pi}{6}$, $\frac{\pi}{3}$, $\frac{\pi}{2}$, $\frac{2\pi}{3}$,
$\frac{5\pi}{6}$, $\pi$, $\frac{7\pi}{6}$, $\frac{4\pi}{3}$,
$\frac{3\pi}{2}$, $\frac{5\pi}{3}$,$\frac{11\pi}{6}$,}, thick }}

                        % Activate to display a given date or no dat


\begin{document}

\begin{questions}
\begin{minipage}[t]{8cm}
    \question Given a point with rectangular coordinates $(-3,3\sqrt{3})$ find a polar coordinate where $r<0$ and $0\leq \theta<2\pi$ \textbf{use exact answer for $\theta$}.
\end{minipage}
\quad % <------ added for a small additional amount of horizontal space between question and image
\includegraphics[scale=.5,valign=t]{example-image} % <------ added valign=t, rmoved surrounding minipage environment
\end{questions}


\begin{questions}
\begin{minipage}[t]{\dimexpr\linewidth-5cm-2em}
    \question Given a point with rectangular coordinates $(-3,3\sqrt{3})$ find a polar coordinate where $r<0$ and $0\leq \theta<2\pi$ \textbf{use exact answer for $\theta$}.
\end{minipage}
\hfill 
\includegraphics[width=5cm,valign=t]{example-image} % <------ added valign=t
\end{questions}

\end{document}

相关内容