2

I'd like to create a question with for possible choices. Each choice will be a tikz figure. How can I insert the caption to simply look like

(A) (B)
(C) (D)

Directly under each of the figures?

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 Answer 1

1

You could use a package like subcaption to create subfigures, but you could also just add a node at the bottom of the tikzpicture as in this example. If you want a bit more space between axis and label, modify the newcommand to say e.g. below=3mm instead of just below.

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .