我想创建一个包含可能选项的问题。每个选项将是一个 tikz 图形。我如何插入标题以使其看起来像
(A) (B)
(C) (D)
直接位于每个数字下方?
La d\'{e}riv\'{e}e d'une fonction est $f'(x) = (x+1)(x-3)$.
Lequel des \'{e}l\'{e}ments suivants pourrait \^{e}tre un croquis de la fonction?
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {(1/3)*x^3-x^2-3*x+10};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {-(1/3)*x^3+x^2+3*x};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {(1/3)*x^3+x^2+3*x};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {(2/3)*x^3-0.7*x^2-4*x};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\end{tikzpicture}
答案1
您可以使用类似这样的包subcaption
来创建子图,但您也可以像本例一样node
在底部添加一个tikzpicture
。如果您希望轴和标签之间留出更多空间,请将修改newcommand
为例如,below=3mm
而不仅仅是below
。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14,width=6cm}
\newcommand\tikzsublabel[1]{\node [below] at (current bounding box.south) {(#1)};}
\begin{document}
La d\'{e}riv\'{e}e d'une fonction est $f'(x) = (x+1)(x-3)$.
Lequel des \'{e}l\'{e}ments suivants pourrait \^{e}tre un croquis de la fonction?
\begin{center}
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {(1/3)*x^3-x^2-3*x+10};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\tikzsublabel{A}
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {-(1/3)*x^3+x^2+3*x};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\tikzsublabel{B}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {(1/3)*x^3+x^2+3*x};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\tikzsublabel{C}
\end{tikzpicture}
\qquad
\begin{tikzpicture}
\begin{axis}[
ticks=none, axis x line=middle, axis y line=middle,
ymin=-20, ymax=15, ylabel=$y$,
xmin=-4, xmax=4, xlabel=$x$,
]
\addplot[samples=40,domain=-4:4,thick] {(2/3)*x^3-0.7*x^2-4*x};
\draw[dashed] (-1,15) -- (-1,-14) node[below]{$x=-1$} ;
\draw[dashed] (3,15) -- (3,-14) node[below]{$x=3$};
\end{axis}
\tikzsublabel{D}
\end{tikzpicture}
\end{center}
\end{document}