I am trying to make an exam with multiple questions having graphs as answer choices. I want them to be aligned as shown below.
Thank you in advance!
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI am trying to make an exam with multiple questions having graphs as answer choices. I want them to be aligned as shown below.
Thank you in advance!
This is a solution uses exam
class and groupplots
from pgfplots
. Two different lablel skills are applied. One, on the bottom, is (requiring AlphaAlpha package)
\makeatletter
\pgfplotsset{
auto title/.style={title=(\AlphAlph{\pgfplots@group@current@plot})
}
}
\makeatother
The other uses, on the top
\node (A) at (group c1r1.north west) {A};
Code
\documentclass[12pt,a4paper]{exam}%,answers
\usepackage{tikz}
\usepackage{alphalph}
\usepackage{pgfplots,geometry} % for plots
\usepgfplotslibrary{groupplots}
\usetikzlibrary{arrows}
\makeatletter
\pgfplotsset{
auto title/.style={ title=(\AlphAlph{\pgfplots@group@current@plot})
}
}
\makeatother
\begin{document}
\begin{questions}
\question[10]
Sketch the parent graph and translate it to obtain a graph of $y+1=|x-5|$.
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[group style={rows=2,columns=2, vertical sep=15mm},
width=3cm,height=2cm, axis x line=center,
axis y line=center, scale only axis,
xmin=-1,xmax=1,ymin=-2,ymax=2,]
\nextgroupplot[] \addplot [domain=-1:1, thick, cyan] {x};
\nextgroupplot[] \addplot [domain=-1:1, thick, cyan] {x^2};
\nextgroupplot[] \addplot [domain=-1:1, thick, cyan] {x};
\nextgroupplot[] \addplot [domain=-1:1, thick, cyan] {x^2};
\end{groupplot}
\node (A) at (group c1r1.north west) {A};
\node (B) at (group c2r1.north west) {B};
\node (C) at (group c1r2.north west) {C};
\node (D) at (group c2r2.north west) {D};
\end{tikzpicture}
\question[10] $3x+7y=21$
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[group style={rows=2,columns=2,
vertical sep=15mm},
width=3cm,height=2cm, scale only axis, xmin=-1,xmax=1,ymin=-2,ymax=2]
\nextgroupplot[auto title] \addplot [domain=-1:1, thick, cyan] {x};
\nextgroupplot[auto title] \addplot [domain=-1:1, thick, cyan] {x^2};
\nextgroupplot[auto title] \addplot [domain=-1:1, thick, cyan] {x};
\nextgroupplot[auto title] \addplot [domain=-1:1, thick, cyan] {x^2};
\end{groupplot}
\end{tikzpicture}
\end{questions}
\end{document}
grid=both
right after the group style={...}
, I just double checked.
may be the simplest is to use a table
\documentclass[10pt,notitlepage]{article}%
\usepackage[margin={2.5cm}]{geometry}%
\usepackage{picins}
\usepackage{graphicx}
\makeatletter %from http://tex.stackexchange.com/questions/44195/placeholder-for-figure-includegraphics
\def\Ginclude@graphics#1{%
\parpic(\Gin@@ewidth,\Gin@@eheight)[d]{#1}\picskip{0}}%
\makeatother
\begin{document}
\begin{enumerate}
\item sketch the parent graph and translate it to obtain the graph of
$y+1=|x-5|$
\begin{table}[!htbp]
\begin{tabular}{p{3in}p{3in}}
A&C\\
\includegraphics[width=4cm,height=4cm]{foo.png}%
&
\includegraphics[width=4cm,height=4cm]{foo.png}%
\\
B&D\\
\includegraphics[width=4cm,height=4cm]{foo.png}%
&
\includegraphics[width=4cm,height=4cm]{foo.png}%
\\
\end{tabular}
\end{table}
\item Graph $3x+7y=1$
\begin{table}[!htbp]
\begin{tabular}{p{3in}p{3in}}
A&C\\
\includegraphics[width=4cm,height=4cm]{foo.png}%
&
\includegraphics[width=4cm,height=4cm]{foo.png}%
\\
B&D\\
\includegraphics[width=4cm,height=4cm]{foo.png}%
&
\includegraphics[width=4cm,height=4cm]{foo.png}%
\\
\end{tabular}
\end{table}
\end{enumerate}
\end{document}