On 13.08.2009, at 06:47, Paul Johnson wrote:

On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmann<daniel.lohm...@informatik.uni-erlangen.de> wrote:
Hi,



So here is what I want to achieve:

I have some TikZ figures (which are actually stand-alone LaTeX- documents with the extension .tikz) that I want to embed (not the source, but the PDF/EPS via \includegraphics) into my LyX document in a way that (1) the LyX-Preview does work (2) PDF generation does work, and (3) the .tikz-file
is opened in vim when I select "Edit externally..."

I am sorry if I am telling you something you already know, but...

It seems to me you are throwing away the value of TikZ by doing this.


Recall that one of the strengths of TikZ/pgf is that the fonts and
such in the figure will match the document. If you persist in keeping
the TikZ as stand alone latex documents, you are destroying that
possibility.
I don't think the document will ever compile because of
the duplicate preambles and such that the latex system encounters.
On the  other hand, if the TikZ file is just the TikZ figure, then I'd
be more optimistic.

But I don't think it is wise to convert the tikz to pdf and embed that
with includegraphics.
Rather, I think you just want to include the tikz code itself. You can
just use input on the TikZ figure itself. If you put that inside a LyX
floating graphic or a minipage, it "just works" in the final
processing. In Lyx, choose "Insert" "File" "Child Document" and then
choose your tikz text file.  As long as it is just the figure, it is
all good. I've just tested it, and it does work.

But you won't get an in-document preview in LyX without a  bit of
messing about.  I think that's where the other guy who refers you to
the Dia code has a good idea.  I've tried to figure that part out, but
no solution yet. We need a way to tell LyX to pass the Tikz figure
code straight through to LaTeX, but we also want an on-screen preview
of what that will be like.  But it is inherently impossible to get a
preview of what that will be like without compiling the whole
document.  A conundrum for me.

Paul,

Your comments are very valid, but I intentionally want to have the possibility to compile the TikZ-figures externally and embedd them as PDF:

- TikZ can increase compilation times *dramatically*. If you embed dozens of nontrivial TikZ figures "as code" into your document, compilation of your LyX document may take minutes instead of seconds. - During the development of the TikZ figures (a time-consuming process of its own) I need to compile and debug them "stand alone" with short roundtrip times.
- PDF images are much easier to scale (to, e.g, pagewidth)
- Regarding the font (and styles and colors...) issue: I solve it by setting that up in a common preamble that is \input'ed into the LyX document and the TikZ figures. However, on some (rare) occasions I *want* to have different fonts in the figure than in the document. This, again, is easy to achieve via the PDF route, but requires quite same hacking if the figure is embedded into the source.

In fact, I can imagine only one situation I would prefer embedding TikZ figures by source: If they contain references into other parts of the document (such as clicking on a TikZ node should bring you to page 212 or you refer to some bibliography item within the figure).

Daniel

Reply via email to