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!

1028
  • 647
  • 5
  • 16
  • How about using tabular? \begin{center} \begin{tabular}{ |c| } \hline \begin{tikzpicture} \begin{axis} [axis lines=center] \addplot [domain=-3:3, smooth, thick] { x^3-6*x }; \end{axis} \end{tikzpicture}\ \hline \end{tabular} \end{center} – Zuriel Oct 04 '22 at 23:33

1 Answers1

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}
Jesse
  • 29,686