Graphics, Figures & TablesImage alignment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Image alignment

Post by Singularity »

How can I get the letter choices for the following multiple choice question to align at the top of the image?

MWE:

Code: Select all

\documentclass[fleqn,addpoints
%,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools}
\usepackage{color}
\usepackage{multicol}

\everymath{\displaystyle}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\shadedsolutions

\begin{document}

\begin{questions}

\question Determine which plot shows the strongest linear correlation.

\begin{choices}
	\begin{multicols}{2}
		\correctchoice 	\includegraphics{T2_Q1_D.png}
		\choice 	\includegraphics{T2_Q1_B.png}
		\choice 	\includegraphics{T2_Q1_A.png}
		\choice 	\includegraphics{T2_Q1_C.png}
	\end{multicols}
\end{choices}
\answerline[A]

\end{questions}

\end{document}
Attachments
T2_Q1_D.png
T2_Q1_D.png (4.48 KiB) Viewed 4135 times
T2_Q1_C.png
T2_Q1_C.png (4.5 KiB) Viewed 4135 times
T2_Q1_B.png
T2_Q1_B.png (5.21 KiB) Viewed 4135 times
T2_Q1_A.png
T2_Q1_A.png (4.58 KiB) Viewed 4135 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Image alignment

Post by Stefan Kottwitz »

Very good complete example! You could load the adjustbox package and use \adjincludegraphics[valign=t] instead of \includegraphics:

Code: Select all

\documentclass[fleqn,addpoints
%,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools}
\usepackage{color}
\usepackage{multicol}
\usepackage{adjustbox}
\everymath{\displaystyle}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\shadedsolutions
\begin{document}

\begin{questions}

\question Determine which plot shows the strongest linear correlation.

\begin{choices}
        \begin{multicols}{2}
                \correctchoice  \adjincludegraphics[valign=t]{T2_Q1_D.png}
                \choice         \adjincludegraphics[valign=t]{T2_Q1_B.png}
                \choice         \adjincludegraphics[valign=t]{T2_Q1_A.png}
                \choice         \adjincludegraphics[valign=t]{T2_Q1_C.png}
        \end{multicols}
\end{choices}
\answerline[A]

\end{questions}

\end{document}
Stefan
LaTeX.org admin
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Re: Image alignment

Post by Singularity »

Works perfectly the first time. TY.
Post Reply