# how to use \insert{_file_} to include tikz \draw command?

I'm using Stata to run some simultions, and my data change every time I run my do file. My data have a discontinuity that changes with each run and I'd like a curly brace that reflects the size of the discontinuity. I thought I could do this by having Stata write to file the following info, where the numbers change with every run:

\draw[decorate,decoration={brace},thick] (axis cs:0.1,0.846) to
node[midway,right] (bracket) {0.339}
(axis cs:0.1,0.507);


And then using an \insert{filename} command to call that, as below:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
ylabel={$\hat{\delta}$},
xlabel={$x$},
xmin=-4.5,
xmax=4.5
]
\insert{filename};
\end{axis}
\end{tikzpicture}
\end{document}


But I receive the following error:

ERROR: Missing number, treated as zero.

--- TeX said ---
{
l.39 \insert{
_filename_};


Any ideas?

-

Use \input instead of \insert. I'm not sure what \insert does, so I don't know why that doesn't work (\show\insert helpfully says \insert=\insert), but \input does work so use that.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
ylabel={$\hat{\delta}$},
xlabel={$x$},
xmin=-4.5,
xmax=4.5
]
\input{pgfplotsinsertion};
\end{axis}
\end{tikzpicture}
\end{document}


Result:

-
Hmm, image doesn't show for some reason. I'm pretty sure I uploaded one. –  Andrew Stacey Mar 18 '11 at 19:55
The image shows now. Sometimes imgur takes a while to process the image. –  Caramdir Mar 18 '11 at 20:18
According to TeX by Topic (chapter 29), \insert adds a floating box (or something like that, seems to be complicated). –  Caramdir Mar 18 '11 at 20:25
I think I just misread the manual. mea culpa - thanks for straightening me out! –  PaulB Mar 18 '11 at 20:43