![像下面的例子一样,获取每个答案选项的图表的最简单方法是什么](https://linux22.com/image/302554/%E5%83%8F%E4%B8%8B%E9%9D%A2%E7%9A%84%E4%BE%8B%E5%AD%90%E4%B8%80%E6%A0%B7%EF%BC%8C%E8%8E%B7%E5%8F%96%E6%AF%8F%E4%B8%AA%E7%AD%94%E6%A1%88%E9%80%89%E9%A1%B9%E7%9A%84%E5%9B%BE%E8%A1%A8%E7%9A%84%E6%9C%80%E7%AE%80%E5%8D%95%E6%96%B9%E6%B3%95%E6%98%AF%E4%BB%80%E4%B9%88.png)
我正在尝试制作一个包含多个问题的考试,这些问题的答案选项为图表。我希望它们按如下所示对齐。
先感谢您!
答案1
这是一个使用exam
类和groupplots
来自的解决方案pgfplots
。应用了两种不同的标签技能。一个在底部,是(需要 AlphaAlpha 包)
\makeatletter
\pgfplotsset{
auto title/.style={title=(\AlphAlph{\pgfplots@group@current@plot})
}
}
\makeatother
其他用途,在顶部
\node (A) at (group c1r1.north west) {A};
代码
\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}