Willem van Engen wrote:
Hi,

LyX has been a real blessing, thanks a lot! Now I've come across a
problem that I don't know how to solve, maybe you can help me here.

I'm using tikz/pgf in ERT to create graphics, and in one of them I use
an external data file to create a plot. I'd really like to use pgf to
add annotations and other imagery. Simple example:

        \begin{tikzpicture}
          % axes
          \draw (-2, 0) -- ( 2, 0);
          \draw ( 0,-2) -- ( 0, 2);
          \draw (0,1.9) node[anchor=east]{$M$};
          \draw (1.9,0) node[anchor=north]{$H_0$};
          % magnetic curve
          \draw[thick, solid, domain=-2:2]
             plot file{images/plotdata/langevin.table};
        \end{tikzpicture}

But this doesn't work, since LyX doesn't know that it should copy the
file images_plotdata_langevin.table. And if LyX's copying-scheme would
be used, even the file command itself should point to
images_plotdata_langevin.table instead (but not for LaTeX export if I'm
right). Is there a way to achieve this, or should I just start over
again and use gnuplot instead?


I suspect there is no elegant solution, but there are two solutions that are arguably better than switching to gnuplot. One is to use LyX to write the document with everything but the plot in it, then export to a .tex file and run LaTeX yourself. The other is to write a small document that does just the plot, producing say a PDF file. (You'll have to run LaTeX against it manually for the reason you articulated above.) Then use includegraphics in your ERT to load the PDF. LyX will recognize the includegraphics command in the ERT and copy the file properly.

I've used TiKZ to annotate a PDF image (generated by an external program). Here's the relevant code snippet (done in ERT in LyX), with the image in the file ttest.pdf, located in the same directory as the LyX file:

\begin{tikzpicture}
\pgftext[left]{\includegraphics[width=90mm]{ttest}}
\draw (60mm,0mm) node[anchor=south west]{$T_{crit}=1.328$};
% more draws here
\end{tikzpicture}

HTH,
Paul

Reply via email to