[Tex/LaTex] gnuplot true standalone

gnuplotstandalonetikz-pgf

Finally I have decided to go PDF. I can add pictures without EPS wrapper, and do drawings with TikZ – life is good :o)

But how do I use gnuplot? For consistency I would like to use the tikz terminal, and I would like to be able to preview my graphs without including them in a document. This

set term tikz standalone preamble '\usepackage[version=3]{mhchem}'
set output "test.tex"
plot x title '\ce{H2O}'

will make an article class document that can compile alone, but it can not be included in another document.

One solution would be not to use the standalone option, and then make a small script, that wraps the output in the standalone class. Now the document can compile alone, and it can be included in a document, but I would not be able to specify an additional preamble. :o(

Does anyone have a smart solution?

Best Answer

With standaloneand gnuplottexyou can get only the picture but pgfplots is preferable because it's hard to manage the font for the labels between gnuplot and latex

\documentclass{standalone}
\usepackage[]{gnuplottex} 
\usepackage[version=3]{mhchem}

\begin{document}       
  \begin{gnuplot}
      plot x title '\ce{H2O}'
  \end{gnuplot}        
\end{document} 

enter image description here