Title says it all:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\usepackage{caption}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
title=myTtitle,
xlabel=$x$,
ylabel=$y$]
\addplot coordinates {
(10, 1)
(20, 2)
};
\end{axis}
\end{tikzpicture}
\caption{A caption.}
\end{figure}
\end{document}
Error:
LaTeX Error: Something's wrong--perhaps a missing \item.
on \begin{figure}
.
Shall you change standalone
to document
it will work, but it will make the plot so small in comparison with the standalone
version... :/
varwidth
option to the documentclass, but why do you want to do this at all?preview
, result differ from case of usevarwidth
(caption is centerred).