4

Example

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!

6

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

enter image description here

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}
  • Thank you for the response, how would you add a grid to the plots? – 1028 Dec 3 '14 at 2:17
  • 1
    add grid=both in the plot options. – Jesse Dec 3 '14 at 2:23
  • You are welcome. Add grid=both right after the group style={...}, I just double checked. – Jesse Dec 3 '14 at 2:27
6

may be the simplest is to use a table

Mathematica graphics

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.