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 4222 times
T2_Q1_C.png
T2_Q1_C.png (4.5 KiB) Viewed 4222 times
T2_Q1_B.png
T2_Q1_B.png (5.21 KiB) Viewed 4222 times
T2_Q1_A.png
T2_Q1_A.png (4.58 KiB) Viewed 4222 times

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
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