Re: How to get a preview for custom graphics format?

2009-08-25 Thread Daniel Lohmann


On 14.08.2009, at 15:56, Pavel Sanda wrote:


Daniel Lohmann wrote:
Or am I mistaken here? I am still seeking for a definite answer  
regarding
the conversion route that to my understanding is automatically  
deduced by
LyX (TiKZ -- PDF | PDF -- Preview). It seem that (newer?)  
versions of LyX
just pass everything right through to ImageMagik and do not bother  
with

deducing a conversion route?


without looking into the code, creating tikz-png convertor wont help?
pavel


Just to close this thread:

Defining an additional tikz-png converter does indeed solve the  
problem. Another possible solution is to extend the convertDefault.py  
script to recognize TikZ: as input format. For convenience reasons,  
this is the route I have been taking.



If others would like to try this:  Here are the step-by-step  
instructions:


-- Under [File Handling -- File formats] add a new file format TikZ  
as Vector graphics format,Short Name: Tikz, Extension: tikz,  
and Editor: vim.


-- Under [File Handling -- Converters] add a Converter Definition  
TikZ -- PDF (ps2pdf)with Converter: pdflatex - 
interaction=nonstopmode $$i


-- Replace the convertDefault.py script by the attached version.

Disclaimer: This are my very first lines of Python code!

Note: According to the docs, it should be enough to put the customized  
version of convertDefault.py into $LYXUSER/scripts (~/Library/ 
Application Support/Lyx-1.x on the Mac). However, on my system (Mac OS  
X, LyX 1.6.3) it seems to remain unrecognized in this position, so I  
ended up with replacing the default version.



Daniel



#!/usr/bin/env python
# -*- coding: utf-8 -*-

# file convertDefault.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.

# \author Herbert Voß
# \author Bo Peng

# Full author contact details are available in file CREDITS.

# The default converter if no other has been defined by the user from the
# Conversion-Converter tab of the Preferences dialog.

# The user can also redefine this default converter, placing their
# replacement in ~/.lyx/scripts

# converts an image from $1 to $2 format
import os, re, sys

# We may need some extra options only supported by recent convert versions
re_version = re.compile(r'^Version:.*ImageMagick\s*(\d*)\.(\d*)\.(\d*).*$')
fout = os.popen('convert -version 21')
output = fout.readline()
fout.close()
version = re_version.match(output)
major = int(version.group(1))
minor = int(version.group(2))
patch = int(version.group(3))
version = hex(major * 65536 + minor * 256 + patch)

opts = -depth 8

# DL: If input format is TikZ convert it to pdf first by calling pdflatex 
# then use the generated pdf as input to ImageMagik's convert
if sys.argv[1][:5].lower() == 'tikz:':
if os.system(r'pdflatex -interaction=nonstopmode %s' % (sys.argv[1][5:])) != 0:
print  sys.stderr, sys.argv[0], 'ERROR'
print  sys.stderr, 'Execution of pdflatex failed.'
sys.exit(1)

# Now use the generated pdf as input format.
sys.argv[1] = pdf:+sys.argv[1][5:-4]+pdf

# If supported, add the -define option for pdf source formats 
if sys.argv[1][:4] == 'pdf:' and version = 0x060206:
opts = '-define pdf:use-cropbox=true ' + opts

# If supported, add the -flatten option for ppm target formats (see bug 4749)
if sys.argv[2][:4] == 'ppm:' and version = 0x060305:
opts = opts + ' -flatten'

if os.system(r'convert %s %s %s' % (opts, sys.argv[1], sys.argv[2])) != 0:
print  sys.stderr, sys.argv[0], 'ERROR'
print  sys.stderr, 'Execution of convert failed.'
sys.exit(1)






Re: How to get a preview for custom graphics format?

2009-08-25 Thread Daniel Lohmann


On 14.08.2009, at 15:56, Pavel Sanda wrote:


Daniel Lohmann wrote:
Or am I mistaken here? I am still seeking for a definite answer  
regarding
the conversion route that to my understanding is automatically  
deduced by
LyX (TiKZ -- PDF | PDF -- Preview). It seem that (newer?)  
versions of LyX
just pass everything right through to ImageMagik and do not bother  
with

deducing a conversion route?


without looking into the code, creating tikz-png convertor wont help?
pavel


Just to close this thread:

Defining an additional tikz-png converter does indeed solve the  
problem. Another possible solution is to extend the convertDefault.py  
script to recognize TikZ: as input format. For convenience reasons,  
this is the route I have been taking.



If others would like to try this:  Here are the step-by-step  
instructions:


-- Under [File Handling -- File formats] add a new file format TikZ  
as Vector graphics format,Short Name: Tikz, Extension: tikz,  
and Editor: vim.


-- Under [File Handling -- Converters] add a Converter Definition  
TikZ -- PDF (ps2pdf)with Converter: pdflatex - 
interaction=nonstopmode $$i


-- Replace the convertDefault.py script by the attached version.

Disclaimer: This are my very first lines of Python code!

Note: According to the docs, it should be enough to put the customized  
version of convertDefault.py into $LYXUSER/scripts (~/Library/ 
Application Support/Lyx-1.x on the Mac). However, on my system (Mac OS  
X, LyX 1.6.3) it seems to remain unrecognized in this position, so I  
ended up with replacing the default version.



Daniel



#!/usr/bin/env python
# -*- coding: utf-8 -*-

# file convertDefault.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.

# \author Herbert Voß
# \author Bo Peng

# Full author contact details are available in file CREDITS.

# The default converter if no other has been defined by the user from the
# Conversion-Converter tab of the Preferences dialog.

# The user can also redefine this default converter, placing their
# replacement in ~/.lyx/scripts

# converts an image from $1 to $2 format
import os, re, sys

# We may need some extra options only supported by recent convert versions
re_version = re.compile(r'^Version:.*ImageMagick\s*(\d*)\.(\d*)\.(\d*).*$')
fout = os.popen('convert -version 21')
output = fout.readline()
fout.close()
version = re_version.match(output)
major = int(version.group(1))
minor = int(version.group(2))
patch = int(version.group(3))
version = hex(major * 65536 + minor * 256 + patch)

opts = -depth 8

# DL: If input format is TikZ convert it to pdf first by calling pdflatex 
# then use the generated pdf as input to ImageMagik's convert
if sys.argv[1][:5].lower() == 'tikz:':
if os.system(r'pdflatex -interaction=nonstopmode %s' % (sys.argv[1][5:])) != 0:
print  sys.stderr, sys.argv[0], 'ERROR'
print  sys.stderr, 'Execution of pdflatex failed.'
sys.exit(1)

# Now use the generated pdf as input format.
sys.argv[1] = pdf:+sys.argv[1][5:-4]+pdf

# If supported, add the -define option for pdf source formats 
if sys.argv[1][:4] == 'pdf:' and version = 0x060206:
opts = '-define pdf:use-cropbox=true ' + opts

# If supported, add the -flatten option for ppm target formats (see bug 4749)
if sys.argv[2][:4] == 'ppm:' and version = 0x060305:
opts = opts + ' -flatten'

if os.system(r'convert %s %s %s' % (opts, sys.argv[1], sys.argv[2])) != 0:
print  sys.stderr, sys.argv[0], 'ERROR'
print  sys.stderr, 'Execution of convert failed.'
sys.exit(1)






Re: How to get a preview for "custom" graphics format?

2009-08-25 Thread Daniel Lohmann


On 14.08.2009, at 15:56, Pavel Sanda wrote:


Daniel Lohmann wrote:
Or am I mistaken here? I am still seeking for a definite answer  
regarding
the conversion route that to my understanding is automatically  
deduced by
LyX (TiKZ --> PDF | PDF --> Preview). It seem that (newer?)  
versions of LyX
just pass everything right through to ImageMagik and do not bother  
with

deducing a conversion route?


without looking into the code, creating tikz->png convertor wont help?
pavel


Just to close this thread:

Defining an additional tikz->png converter does indeed solve the  
problem. Another possible solution is to extend the convertDefault.py  
script to recognize "TikZ:" as input format. For convenience reasons,  
this is the route I have been taking.



If others would like to try this:  Here are the step-by-step  
instructions:


-- Under [File Handling --> File formats] add a new file format "TikZ"  
as Vector graphics format,Short Name: "Tikz", Extension: "tikz",  
and Editor: "vim".


-- Under [File Handling --> Converters] add a Converter Definition  
"TikZ --> PDF (ps2pdf)"with Converter: "pdflatex - 
interaction=nonstopmode $$i"


-- Replace the convertDefault.py script by the attached version.

Disclaimer: This are my very first lines of Python code!

Note: According to the docs, it should be enough to put the customized  
version of convertDefault.py into $LYXUSER/scripts (~/Library/ 
Application Support/Lyx-1.x on the Mac). However, on my system (Mac OS  
X, LyX 1.6.3) it seems to remain unrecognized in this position, so I  
ended up with replacing the default version.



Daniel



#!/usr/bin/env python
# -*- coding: utf-8 -*-

# file convertDefault.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.

# \author Herbert Voß
# \author Bo Peng

# Full author contact details are available in file CREDITS.

# The default converter if no other has been defined by the user from the
# Conversion->Converter tab of the Preferences dialog.

# The user can also redefine this default converter, placing their
# replacement in ~/.lyx/scripts

# converts an image from $1 to $2 format
import os, re, sys

# We may need some extra options only supported by recent convert versions
re_version = re.compile(r'^Version:.*ImageMagick\s*(\d*)\.(\d*)\.(\d*).*$')
fout = os.popen('convert -version 2>&1')
output = fout.readline()
fout.close()
version = re_version.match(output)
major = int(version.group(1))
minor = int(version.group(2))
patch = int(version.group(3))
version = hex(major * 65536 + minor * 256 + patch)

opts = "-depth 8"

# DL: If input format is "TikZ" convert it to pdf first by calling pdflatex 
# then use the generated pdf as input to ImageMagik's convert
if sys.argv[1][:5].lower() == 'tikz:':
if os.system(r'pdflatex -interaction=nonstopmode "%s"' % (sys.argv[1][5:])) != 0:
print >> sys.stderr, sys.argv[0], 'ERROR'
print >> sys.stderr, 'Execution of "pdflatex" failed.'
sys.exit(1)

# Now use the generated pdf as input format.
sys.argv[1] = "pdf:"+sys.argv[1][5:-4]+"pdf"

# If supported, add the -define option for pdf source formats 
if sys.argv[1][:4] == 'pdf:' and version >= 0x060206:
opts = '-define pdf:use-cropbox=true ' + opts

# If supported, add the -flatten option for ppm target formats (see bug 4749)
if sys.argv[2][:4] == 'ppm:' and version >= 0x060305:
opts = opts + ' -flatten'

if os.system(r'convert %s "%s" "%s"' % (opts, sys.argv[1], sys.argv[2])) != 0:
print >> sys.stderr, sys.argv[0], 'ERROR'
print >> sys.stderr, 'Execution of "convert" failed.'
sys.exit(1)






Re: How to get a preview for custom graphics format?

2009-08-14 Thread Pavel Sanda
Daniel Lohmann wrote:
 Or am I mistaken here? I am still seeking for a definite answer regarding 
 the conversion route that to my understanding is automatically deduced by 
 LyX (TiKZ -- PDF | PDF -- Preview). It seem that (newer?) versions of LyX 
 just pass everything right through to ImageMagik and do not bother with 
 deducing a conversion route?

without looking into the code, creating tikz-png convertor wont help?
pavel


Re: How to get a preview for custom graphics format?

2009-08-14 Thread Pavel Sanda
Daniel Lohmann wrote:
 Or am I mistaken here? I am still seeking for a definite answer regarding 
 the conversion route that to my understanding is automatically deduced by 
 LyX (TiKZ -- PDF | PDF -- Preview). It seem that (newer?) versions of LyX 
 just pass everything right through to ImageMagik and do not bother with 
 deducing a conversion route?

without looking into the code, creating tikz-png convertor wont help?
pavel


Re: How to get a preview for "custom" graphics format?

2009-08-14 Thread Pavel Sanda
Daniel Lohmann wrote:
> Or am I mistaken here? I am still seeking for a definite answer regarding 
> the conversion route that to my understanding is automatically deduced by 
> LyX (TiKZ --> PDF | PDF --> Preview). It seem that (newer?) versions of LyX 
> just pass everything right through to ImageMagik and do not bother with 
> deducing a conversion route?

without looking into the code, creating tikz->png convertor wont help?
pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Paul Johnson wrote:
 I am sorry if I am telling you something you already know, but...

thanks for info (i know basically nothing about tikz)

 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. 

this makes the _proper_ support of tikz by lyx much harder (if you want
instant preview).

 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.

i see three possibilities:

- one possibility would be to make external template which tries to
  the instant preview from the included file only. it will work 100%
  for typeset output, preview will work for figures and somewhat unreliably
  for the documents i guess.
  (but as noted previously this maybe does not need external template at all 
  for the tikz case.)

- to make a python script which would take the parent document dumps the 
preamble,
  then inputs tikz, latex it and returns figure for both preview and output.

- enhance the lyx code for external templates itself; more possibilities then
  -dump the preamble for your scritp somewhere (some tag like ParentPreamble 
dumpfile.tmp)
  -make some particular command for preview generation etc.

pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
 i see three possibilities:

 - one possibility would be to make external template which tries to
   the instant preview from the included file only. it will work 100%
   for typeset output, preview will work for figures and somewhat unreliably
   for the documents i guess.
   (but as noted previously this maybe does not need external template at
 all for the tikz case.)

 - to make a python script which would take the parent document dumps the
 preamble, then inputs tikz, latex it and returns figure for both preview
 and output.

 - enhance the lyx code for external templates itself; more possibilities
 then -dump the preamble for your scritp somewhere (some tag like
 ParentPreamble dumpfile.tmp) -make some particular command for preview
 generation etc.

The problem is that instant-preview (and most notably dvipng) do not support 
pgf/tikz properly yet.

You can put your tikz figures in an external tex file and \input that (this is 
how I handle my tikz figures). This works very well, however, if you activate 
Preview for the include inset, you'll get a very garbled preview.

IMHO the only way to go is an external inset that

* outputs \input{myfigure.tiks} to LaTeX
and
* uses the graphics approach for the preview.

I think this should be possible with the current external templates approach.

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
 IMHO the only way to go is an external inset that
 
 * outputs \input{myfigure.tiks} to LaTeX
 and
 * uses the graphics approach for the preview.
 
 I think this should be possible with the current external templates approach.

and the parent preamble?
pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
 and the parent preamble?

I guess the tikz file would need its own preamble.

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
 Pavel Sanda wrote:
  and the parent preamble?
 
 I guess the tikz file would need its own preamble.

well, i have written my ideas with taking into account Paul's concerns:

 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.

pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
  I guess the tikz file would need its own preamble.

 well, i have written my ideas with taking into account Paul's concerns:
  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.

I thought Paul's concerns only apply to the document output, not the preview. 
I would not mind if the preview would not use the font of the document output.

My point was: having instant preview should not be at the cost of the output 
quality, thus the splitted approach (original LaTeX code for the output, 
graphics for the preview [only]).

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
 - to make a python script which would take the parent document dumps the
 preamble, then inputs tikz, latex it and returns figure for both preview
 and output.

Here is such a python script (although it is a bit too UNIX-centric):
http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/

But as said, I would use that for preview only, not for the output.

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
 Pavel Sanda wrote:
  - to make a python script which would take the parent document dumps the
  preamble, then inputs tikz, latex it and returns figure for both preview
  and output.
 
 Here is such a python script (although it is a bit too UNIX-centric):
 http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/

in a case some of the intersted people write and test the external template
we could include it with this script in a proper lyx release.

 But as said, I would use that for preview only, not for the output.

this would be fine with me.
pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Daniel Lohmann


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


On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmanndaniel.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


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Daniel Lohmann


On 12.08.2009, at 09:53, Guenter Milde wrote:


On 2009-08-11, Pavel Sanda wrote:

Daniel Lohmann wrote:
that mean that it is *not possible* to achieve goal (1) (the  
preview in

LyX, everything else works) via file formats and converters only?



unless imagemagick convert utility knows how to deal with it (i think
it doesn't) i'm not aware of such a plain route.


As the tkiz - PDF (ps2pdf) conversion seems to work, the problem  
should be

solvable with a definition for PDF (ps2pdf) - PNG.



I think I am going to try this. The point is that I still do not  
understand why this possibly could help!


- As far as I understand PDF (ps2pdf) is just the default PDF- 
Format (pdf1).
- LyX is able to create previews from files in this format  
automagically.


Or am I mistaken here? I am still seeking for a definite answer  
regarding the conversion route that to my understanding is  
automatically deduced by LyX (TiKZ -- PDF | PDF -- Preview). It seem  
that (newer?) versions of LyX just pass everything right through to  
ImageMagik and do not bother with deducing a conversion route?


Daniel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Daniel Lohmann


On 13.08.2009, at 11:22, Pavel Sanda wrote:


Jürgen Spitzmüller wrote:

Pavel Sanda wrote:
- to make a python script which would take the parent document  
dumps the
preamble, then inputs tikz, latex it and returns figure for both  
preview

and output.


Here is such a python script (although it is a bit too UNIX-centric):
http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/


in a case some of the intersted people write and test the external  
template

we could include it with this script in a proper lyx release.


The real problem is to get the preamble right. Because TikZ is a huge  
package that has a noticeable impact on LaTeX compilation times (and  
memory consumption), it is pretty well modularized into multiple  
libraries. A typical preamble for a TikZ figure looks as follows:


\usepackage{tikz}
\usetikzlibrary{fit,positioning,shapes,shapes.multipart, depends on  
what you actually use in the figure}


With the external-template mechanism, as far as I understand it, the  
additional stuff for the preamble can only be hard-code in the  
template and not be examined (e.g. by invoking some script) for the  
actual TikZ figures to embed.



Daniel 

Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Daniel Lohmann wrote:
 The real problem is to get the preamble right. Because TikZ is a huge  
 package that has a noticeable impact on LaTeX compilation times (and  
 memory consumption), it is pretty well modularized into multiple  
 libraries. A typical preamble for a TikZ figure looks as follows:

 \usepackage{tikz}
 \usetikzlibrary{fit,positioning,shapes,shapes.multipart, depends on  
 what you actually use in the figure}

 With the external-template mechanism, as far as I understand it, the  
 additional stuff for the preamble can only be hard-code in the  
 template and not be examined (e.g. by invoking some script) for the  
 actual TikZ figures to embed.

Actually, the script tries to parse the tex file and copy the preamble to the 
file which is used for generating the preview. It only falls back to a 
hardcoded preamble if it cannot find the tex file.

For the LyX usage, such a script would need to take care that there is 
actually a tex file. Also, the script should perform the compilation in the 
temp directory, not in the home directory.

So I think the referred script can only serve as a model for what LyX would 
use (and actually, the license of the script is not ideal for inclusion in 
LyX).

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Paul Johnson wrote:
 I am sorry if I am telling you something you already know, but...

thanks for info (i know basically nothing about tikz)

 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. 

this makes the _proper_ support of tikz by lyx much harder (if you want
instant preview).

 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.

i see three possibilities:

- one possibility would be to make external template which tries to
  the instant preview from the included file only. it will work 100%
  for typeset output, preview will work for figures and somewhat unreliably
  for the documents i guess.
  (but as noted previously this maybe does not need external template at all 
  for the tikz case.)

- to make a python script which would take the parent document dumps the 
preamble,
  then inputs tikz, latex it and returns figure for both preview and output.

- enhance the lyx code for external templates itself; more possibilities then
  -dump the preamble for your scritp somewhere (some tag like ParentPreamble 
dumpfile.tmp)
  -make some particular command for preview generation etc.

pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
 i see three possibilities:

 - one possibility would be to make external template which tries to
   the instant preview from the included file only. it will work 100%
   for typeset output, preview will work for figures and somewhat unreliably
   for the documents i guess.
   (but as noted previously this maybe does not need external template at
 all for the tikz case.)

 - to make a python script which would take the parent document dumps the
 preamble, then inputs tikz, latex it and returns figure for both preview
 and output.

 - enhance the lyx code for external templates itself; more possibilities
 then -dump the preamble for your scritp somewhere (some tag like
 ParentPreamble dumpfile.tmp) -make some particular command for preview
 generation etc.

The problem is that instant-preview (and most notably dvipng) do not support 
pgf/tikz properly yet.

You can put your tikz figures in an external tex file and \input that (this is 
how I handle my tikz figures). This works very well, however, if you activate 
Preview for the include inset, you'll get a very garbled preview.

IMHO the only way to go is an external inset that

* outputs \input{myfigure.tiks} to LaTeX
and
* uses the graphics approach for the preview.

I think this should be possible with the current external templates approach.

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
 IMHO the only way to go is an external inset that
 
 * outputs \input{myfigure.tiks} to LaTeX
 and
 * uses the graphics approach for the preview.
 
 I think this should be possible with the current external templates approach.

and the parent preamble?
pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
 and the parent preamble?

I guess the tikz file would need its own preamble.

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
 Pavel Sanda wrote:
  and the parent preamble?
 
 I guess the tikz file would need its own preamble.

well, i have written my ideas with taking into account Paul's concerns:

 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.

pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
  I guess the tikz file would need its own preamble.

 well, i have written my ideas with taking into account Paul's concerns:
  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.

I thought Paul's concerns only apply to the document output, not the preview. 
I would not mind if the preview would not use the font of the document output.

My point was: having instant preview should not be at the cost of the output 
quality, thus the splitted approach (original LaTeX code for the output, 
graphics for the preview [only]).

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
 - to make a python script which would take the parent document dumps the
 preamble, then inputs tikz, latex it and returns figure for both preview
 and output.

Here is such a python script (although it is a bit too UNIX-centric):
http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/

But as said, I would use that for preview only, not for the output.

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
 Pavel Sanda wrote:
  - to make a python script which would take the parent document dumps the
  preamble, then inputs tikz, latex it and returns figure for both preview
  and output.
 
 Here is such a python script (although it is a bit too UNIX-centric):
 http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/

in a case some of the intersted people write and test the external template
we could include it with this script in a proper lyx release.

 But as said, I would use that for preview only, not for the output.

this would be fine with me.
pavel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Daniel Lohmann


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


On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmanndaniel.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


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Daniel Lohmann


On 12.08.2009, at 09:53, Guenter Milde wrote:


On 2009-08-11, Pavel Sanda wrote:

Daniel Lohmann wrote:
that mean that it is *not possible* to achieve goal (1) (the  
preview in

LyX, everything else works) via file formats and converters only?



unless imagemagick convert utility knows how to deal with it (i think
it doesn't) i'm not aware of such a plain route.


As the tkiz - PDF (ps2pdf) conversion seems to work, the problem  
should be

solvable with a definition for PDF (ps2pdf) - PNG.



I think I am going to try this. The point is that I still do not  
understand why this possibly could help!


- As far as I understand PDF (ps2pdf) is just the default PDF- 
Format (pdf1).
- LyX is able to create previews from files in this format  
automagically.


Or am I mistaken here? I am still seeking for a definite answer  
regarding the conversion route that to my understanding is  
automatically deduced by LyX (TiKZ -- PDF | PDF -- Preview). It seem  
that (newer?) versions of LyX just pass everything right through to  
ImageMagik and do not bother with deducing a conversion route?


Daniel


Re: How to get a preview for custom graphics format?

2009-08-13 Thread Daniel Lohmann


On 13.08.2009, at 11:22, Pavel Sanda wrote:


Jürgen Spitzmüller wrote:

Pavel Sanda wrote:
- to make a python script which would take the parent document  
dumps the
preamble, then inputs tikz, latex it and returns figure for both  
preview

and output.


Here is such a python script (although it is a bit too UNIX-centric):
http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/


in a case some of the intersted people write and test the external  
template

we could include it with this script in a proper lyx release.


The real problem is to get the preamble right. Because TikZ is a huge  
package that has a noticeable impact on LaTeX compilation times (and  
memory consumption), it is pretty well modularized into multiple  
libraries. A typical preamble for a TikZ figure looks as follows:


\usepackage{tikz}
\usetikzlibrary{fit,positioning,shapes,shapes.multipart, depends on  
what you actually use in the figure}


With the external-template mechanism, as far as I understand it, the  
additional stuff for the preamble can only be hard-code in the  
template and not be examined (e.g. by invoking some script) for the  
actual TikZ figures to embed.



Daniel 

Re: How to get a preview for custom graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Daniel Lohmann wrote:
 The real problem is to get the preamble right. Because TikZ is a huge  
 package that has a noticeable impact on LaTeX compilation times (and  
 memory consumption), it is pretty well modularized into multiple  
 libraries. A typical preamble for a TikZ figure looks as follows:

 \usepackage{tikz}
 \usetikzlibrary{fit,positioning,shapes,shapes.multipart, depends on  
 what you actually use in the figure}

 With the external-template mechanism, as far as I understand it, the  
 additional stuff for the preamble can only be hard-code in the  
 template and not be examined (e.g. by invoking some script) for the  
 actual TikZ figures to embed.

Actually, the script tries to parse the tex file and copy the preamble to the 
file which is used for generating the preview. It only falls back to a 
hardcoded preamble if it cannot find the tex file.

For the LyX usage, such a script would need to take care that there is 
actually a tex file. Also, the script should perform the compilation in the 
temp directory, not in the home directory.

So I think the referred script can only serve as a model for what LyX would 
use (and actually, the license of the script is not ideal for inclusion in 
LyX).

Jürgen


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Pavel Sanda
Paul Johnson wrote:
> I am sorry if I am telling you something you already know, but...

thanks for info (i know basically nothing about tikz)

> 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. 

this makes the _proper_ support of tikz by lyx much harder (if you want
instant preview).

> 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.

i see three possibilities:

- one possibility would be to make external template which tries to
  the instant preview from the included file only. it will work 100%
  for typeset output, preview will work for figures and somewhat unreliably
  for the documents i guess.
  (but as noted previously this maybe does not need external template at all 
  for the tikz case.)

- to make a python script which would take the parent document dumps the 
preamble,
  then inputs tikz, latex it and returns figure for both preview and output.

- enhance the lyx code for external templates itself; more possibilities then
  -dump the preamble for your scritp somewhere (some tag like ParentPreamble 
dumpfile.tmp)
  -make some particular command for preview generation etc.

pavel


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
> i see three possibilities:
>
> - one possibility would be to make external template which tries to
>   the instant preview from the included file only. it will work 100%
>   for typeset output, preview will work for figures and somewhat unreliably
>   for the documents i guess.
>   (but as noted previously this maybe does not need external template at
> all for the tikz case.)
>
> - to make a python script which would take the parent document dumps the
> preamble, then inputs tikz, latex it and returns figure for both preview
> and output.
>
> - enhance the lyx code for external templates itself; more possibilities
> then -dump the preamble for your scritp somewhere (some tag like
> ParentPreamble dumpfile.tmp) -make some particular command for preview
> generation etc.

The problem is that instant-preview (and most notably dvipng) do not support 
pgf/tikz properly yet.

You can put your tikz figures in an external tex file and \input that (this is 
how I handle my tikz figures). This works very well, however, if you activate 
"Preview" for the include inset, you'll get a very garbled preview.

IMHO the only way to go is an external inset that

* outputs \input{myfigure.tiks} to LaTeX
and
* uses the graphics approach for the preview.

I think this should be possible with the current external templates approach.

Jürgen


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
> IMHO the only way to go is an external inset that
> 
> * outputs \input{myfigure.tiks} to LaTeX
> and
> * uses the graphics approach for the preview.
> 
> I think this should be possible with the current external templates approach.

and the parent preamble?
pavel


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
> and the parent preamble?

I guess the tikz file would need its own preamble.

Jürgen


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
> Pavel Sanda wrote:
> > and the parent preamble?
> 
> I guess the tikz file would need its own preamble.

well, i have written my ideas with taking into account Paul's concerns:

> 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.

pavel


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
> > I guess the tikz file would need its own preamble.
>
> well, i have written my ideas with taking into account Paul's concerns:
> > 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.

I thought Paul's concerns only apply to the document output, not the preview. 
I would not mind if the preview would not use the font of the document output.

My point was: having instant preview should not be at the cost of the output 
quality, thus the splitted approach (original LaTeX code for the output, 
graphics for the preview [only]).

Jürgen


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Pavel Sanda wrote:
> - to make a python script which would take the parent document dumps the
> preamble, then inputs tikz, latex it and returns figure for both preview
> and output.

Here is such a python script (although it is a bit too UNIX-centric):
http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/

But as said, I would use that for preview only, not for the output.

Jürgen


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Pavel Sanda
Jürgen Spitzmüller wrote:
> Pavel Sanda wrote:
> > - to make a python script which would take the parent document dumps the
> > preamble, then inputs tikz, latex it and returns figure for both preview
> > and output.
> 
> Here is such a python script (although it is a bit too UNIX-centric):
> http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/

in a case some of the intersted people write and test the external template
we could include it with this script in a proper lyx release.

> But as said, I would use that for preview only, not for the output.

this would be fine with me.
pavel


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Daniel Lohmann


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


On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmann 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


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Daniel Lohmann


On 12.08.2009, at 09:53, Guenter Milde wrote:


On 2009-08-11, Pavel Sanda wrote:

Daniel Lohmann wrote:
that mean that it is *not possible* to achieve goal (1) (the  
preview in

LyX, everything else works) via file formats and converters only?



unless imagemagick convert utility knows how to deal with it (i think
it doesn't) i'm not aware of such a plain route.


As the tkiz -> PDF (ps2pdf) conversion seems to work, the problem  
should be

solvable with a definition for PDF (ps2pdf) -> PNG.



I think I am going to try this. The point is that I still do not  
understand why this possibly could help!


- As far as I understand "PDF (ps2pdf)" is just the "default" PDF- 
Format (pdf1).
- LyX is able to create previews from files in this format  
"automagically".


Or am I mistaken here? I am still seeking for a definite answer  
regarding the conversion route that to my understanding is  
automatically deduced by LyX (TiKZ --> PDF | PDF --> Preview). It seem  
that (newer?) versions of LyX just pass everything right through to  
ImageMagik and do not bother with deducing a conversion route?


Daniel


Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Daniel Lohmann


On 13.08.2009, at 11:22, Pavel Sanda wrote:


Jürgen Spitzmüller wrote:

Pavel Sanda wrote:
- to make a python script which would take the parent document  
dumps the
preamble, then inputs tikz, latex it and returns figure for both  
preview

and output.


Here is such a python script (although it is a bit too UNIX-centric):
http://kogs-www.informatik.uni-hamburg.de/~meine/tikz/process/


in a case some of the intersted people write and test the external  
template

we could include it with this script in a proper lyx release.


The real problem is to get the preamble right. Because TikZ is a huge  
package that has a noticeable impact on LaTeX compilation times (and  
memory consumption), it is pretty well modularized into multiple  
libraries. A typical preamble for a TikZ figure looks as follows:


\usepackage{tikz}
\usetikzlibrary{fit,positioning,shapes,shapes.multipart, what you actually use in the figure>}


With the external-template mechanism, as far as I understand it, the  
additional stuff for the preamble can only be hard-code in the  
template and not be examined (e.g. by invoking some script) for the  
actual TikZ figures to embed.



Daniel 

Re: How to get a preview for "custom" graphics format?

2009-08-13 Thread Jürgen Spitzmüller
Daniel Lohmann wrote:
> The real problem is to get the preamble right. Because TikZ is a huge  
> package that has a noticeable impact on LaTeX compilation times (and  
> memory consumption), it is pretty well modularized into multiple  
> libraries. A typical preamble for a TikZ figure looks as follows:
>
> \usepackage{tikz}
> \usetikzlibrary{fit,positioning,shapes,shapes.multipart,  what you actually use in the figure>}
>
> With the external-template mechanism, as far as I understand it, the  
> additional stuff for the preamble can only be hard-code in the  
> template and not be examined (e.g. by invoking some script) for the  
> actual TikZ figures to embed.

Actually, the script tries to parse the tex file and copy the preamble to the 
file which is used for generating the preview. It only falls back to a 
hardcoded preamble if it cannot find the tex file.

For the LyX usage, such a script would need to take care that there is 
actually a tex file. Also, the script should perform the compilation in the 
temp directory, not in the home directory.

So I think the referred script can only serve as a model for what LyX would 
use (and actually, the license of the script is not ideal for inclusion in 
LyX).

Jürgen


Re: How to get a preview for custom graphics format?

2009-08-12 Thread Guenter Milde
On 2009-08-11, Pavel Sanda wrote:
 Daniel Lohmann wrote:
 that mean that it is *not possible* to achieve goal (1) (the preview in 
 LyX, everything else works) via file formats and converters only?

 unless imagemagick convert utility knows how to deal with it (i think
 it doesn't) i'm not aware of such a plain route.

As the tkiz - PDF (ps2pdf) conversion seems to work, the problem should be
solvable with a definition for PDF (ps2pdf) - PNG.

However, there might be another problem at the base, as I remember that (at
least with newer QT versions) PDF can be shown in LyX also without further
definitions.

Günter



Re: How to get a preview for custom graphics format?

2009-08-12 Thread Pavel Sanda
Guenter Milde wrote:
 On 2009-08-11, Pavel Sanda wrote:
  Daniel Lohmann wrote:
  that mean that it is *not possible* to achieve goal (1) (the preview in 
  LyX, everything else works) via file formats and converters only?
 
  unless imagemagick convert utility knows how to deal with it (i think
  it doesn't) i'm not aware of such a plain route.
 
 As the tkiz - PDF (ps2pdf) conversion seems to work, the problem should be
 solvable with a definition for PDF (ps2pdf) - PNG.

i didn't read the original post carefully, this might be an option indeed.
pavel


Re: How to get a preview for custom graphics format?

2009-08-12 Thread Florian Rubach

Daniel Lohmann schrieb:

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...

...


Your  help is highly appreciated!

Daniel

Hello Daniel!

I'm sorry I can't help you, I just want to tell you that I'm also 
interested in having a preview for TikZ-Graphics. So if there's any 
progress in achieving that, please share it!


Regards,
Florian




Re: How to get a preview for custom graphics format?

2009-08-12 Thread Paul Johnson
On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmanndaniel.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 E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas


Re: How to get a preview for custom graphics format?

2009-08-12 Thread Guenter Milde
On 2009-08-11, Pavel Sanda wrote:
 Daniel Lohmann wrote:
 that mean that it is *not possible* to achieve goal (1) (the preview in 
 LyX, everything else works) via file formats and converters only?

 unless imagemagick convert utility knows how to deal with it (i think
 it doesn't) i'm not aware of such a plain route.

As the tkiz - PDF (ps2pdf) conversion seems to work, the problem should be
solvable with a definition for PDF (ps2pdf) - PNG.

However, there might be another problem at the base, as I remember that (at
least with newer QT versions) PDF can be shown in LyX also without further
definitions.

Günter



Re: How to get a preview for custom graphics format?

2009-08-12 Thread Pavel Sanda
Guenter Milde wrote:
 On 2009-08-11, Pavel Sanda wrote:
  Daniel Lohmann wrote:
  that mean that it is *not possible* to achieve goal (1) (the preview in 
  LyX, everything else works) via file formats and converters only?
 
  unless imagemagick convert utility knows how to deal with it (i think
  it doesn't) i'm not aware of such a plain route.
 
 As the tkiz - PDF (ps2pdf) conversion seems to work, the problem should be
 solvable with a definition for PDF (ps2pdf) - PNG.

i didn't read the original post carefully, this might be an option indeed.
pavel


Re: How to get a preview for custom graphics format?

2009-08-12 Thread Florian Rubach

Daniel Lohmann schrieb:

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...

...


Your  help is highly appreciated!

Daniel

Hello Daniel!

I'm sorry I can't help you, I just want to tell you that I'm also 
interested in having a preview for TikZ-Graphics. So if there's any 
progress in achieving that, please share it!


Regards,
Florian




Re: How to get a preview for custom graphics format?

2009-08-12 Thread Paul Johnson
On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmanndaniel.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 E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas


Re: How to get a preview for "custom" graphics format?

2009-08-12 Thread Guenter Milde
On 2009-08-11, Pavel Sanda wrote:
> Daniel Lohmann wrote:
>> that mean that it is *not possible* to achieve goal (1) (the preview in 
>> LyX, everything else works) via file formats and converters only?

> unless imagemagick convert utility knows how to deal with it (i think
> it doesn't) i'm not aware of such a plain route.

As the tkiz -> PDF (ps2pdf) conversion seems to work, the problem should be
solvable with a definition for PDF (ps2pdf) -> PNG.

However, there might be another problem at the base, as I remember that (at
least with newer QT versions) PDF can be shown in LyX also without further
definitions.

Günter



Re: How to get a preview for "custom" graphics format?

2009-08-12 Thread Pavel Sanda
Guenter Milde wrote:
> On 2009-08-11, Pavel Sanda wrote:
> > Daniel Lohmann wrote:
> >> that mean that it is *not possible* to achieve goal (1) (the preview in 
> >> LyX, everything else works) via file formats and converters only?
> 
> > unless imagemagick convert utility knows how to deal with it (i think
> > it doesn't) i'm not aware of such a plain route.
> 
> As the tkiz -> PDF (ps2pdf) conversion seems to work, the problem should be
> solvable with a definition for PDF (ps2pdf) -> PNG.

i didn't read the original post carefully, this might be an option indeed.
pavel


Re: How to get a preview for "custom" graphics format?

2009-08-12 Thread Florian Rubach

Daniel Lohmann schrieb:

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..."

...


Your  help is highly appreciated!

Daniel

Hello Daniel!

I'm sorry I can't help you, I just want to tell you that I'm also 
interested in having a preview for TikZ-Graphics. So if there's any 
progress in achieving that, please share it!


Regards,
Florian




Re: How to get a preview for "custom" graphics format?

2009-08-12 Thread Paul Johnson
On Fri, Aug 7, 2009 at 9:52 AM, Daniel
Lohmann 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 E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas


Re: How to get a preview for custom graphics format?

2009-08-11 Thread Daniel Lohmann


On 09.08.2009, at 17:31, Pavel Sanda wrote:


Daniel Lohmann wrote:

Your  help is highly appreciated!


try to mimic http://www.lyx.org/trac/changeset/27914
and ask for inclusion if you succeed. you may also
want to comment on bug 4882.


Hi Pavel,

Thanks for your answer!

However, I have to admit that I don't really get what you suggest me  
to do. As I read 27914, this introduces Dia support via  
external_templates. Does that mean that it is *not possible* to  
achieve goal (1) (the preview in LyX, everything else works) via file  
formats and converters only?  Do I have to go the external_templates  
route?


Thanks!

Daniel




Hi,

Even though I consider myself a LyX master in many respects, the  
exact usage of File Formats, Converters and External  
Material... have always remained a mystery to me. Today I gave it  
another try (LyX 1.6.3-mac) -- and failed again.


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...


So far I got (2) and (3) working, but not (1):

-- Under [File Handling -- File formats] I have added a new file  
format TikZ as Vector graphics format,Short Name: Tikz,  
Extension: tikz, and Editor: vim.


-- Under [File Handling -- Converters] I have added a Converter  
Definition TikZ -- PDF (ps2pdf)with Converter: pdflatex $$i


If I now embed a .tikz-file, external editing and PDF generation  
works fine, but LyX is not able to show a preview. As I interpret  
the output of lyx -dbg graphics, LyX does not know how to  
generate a pixmap  from the input format (TikZ). Do I have to  
define a converter to some pixmap format as well?  How to do so?


This is pretty confusing. As I understand the manuals (don't  
remember where exactly I have read this) LyX should be able to  
deduce its route through conversion rules automatically, that is,  
to convert from TikZ to PDF first  and then from PDF to the pixmap  
required for the preview functionality.


Re: How to get a preview for custom graphics format?

2009-08-11 Thread Pavel Sanda
Daniel Lohmann wrote:
 that mean that it is *not possible* to achieve goal (1) (the preview in 
 LyX, everything else works) via file formats and converters only?

unless imagemagick convert utility knows how to deal with it (i think it 
doesn't)
i'm not aware of such a plain route.
pavel


Re: How to get a preview for custom graphics format?

2009-08-11 Thread Daniel Lohmann


On 09.08.2009, at 17:31, Pavel Sanda wrote:


Daniel Lohmann wrote:

Your  help is highly appreciated!


try to mimic http://www.lyx.org/trac/changeset/27914
and ask for inclusion if you succeed. you may also
want to comment on bug 4882.


Hi Pavel,

Thanks for your answer!

However, I have to admit that I don't really get what you suggest me  
to do. As I read 27914, this introduces Dia support via  
external_templates. Does that mean that it is *not possible* to  
achieve goal (1) (the preview in LyX, everything else works) via file  
formats and converters only?  Do I have to go the external_templates  
route?


Thanks!

Daniel




Hi,

Even though I consider myself a LyX master in many respects, the  
exact usage of File Formats, Converters and External  
Material... have always remained a mystery to me. Today I gave it  
another try (LyX 1.6.3-mac) -- and failed again.


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...


So far I got (2) and (3) working, but not (1):

-- Under [File Handling -- File formats] I have added a new file  
format TikZ as Vector graphics format,Short Name: Tikz,  
Extension: tikz, and Editor: vim.


-- Under [File Handling -- Converters] I have added a Converter  
Definition TikZ -- PDF (ps2pdf)with Converter: pdflatex $$i


If I now embed a .tikz-file, external editing and PDF generation  
works fine, but LyX is not able to show a preview. As I interpret  
the output of lyx -dbg graphics, LyX does not know how to  
generate a pixmap  from the input format (TikZ). Do I have to  
define a converter to some pixmap format as well?  How to do so?


This is pretty confusing. As I understand the manuals (don't  
remember where exactly I have read this) LyX should be able to  
deduce its route through conversion rules automatically, that is,  
to convert from TikZ to PDF first  and then from PDF to the pixmap  
required for the preview functionality.


Re: How to get a preview for custom graphics format?

2009-08-11 Thread Pavel Sanda
Daniel Lohmann wrote:
 that mean that it is *not possible* to achieve goal (1) (the preview in 
 LyX, everything else works) via file formats and converters only?

unless imagemagick convert utility knows how to deal with it (i think it 
doesn't)
i'm not aware of such a plain route.
pavel


Re: How to get a preview for "custom" graphics format?

2009-08-11 Thread Daniel Lohmann


On 09.08.2009, at 17:31, Pavel Sanda wrote:


Daniel Lohmann wrote:

Your  help is highly appreciated!


try to mimic http://www.lyx.org/trac/changeset/27914
and ask for inclusion if you succeed. you may also
want to comment on bug 4882.


Hi Pavel,

Thanks for your answer!

However, I have to admit that I don't really get what you suggest me  
to do. As I read 27914, this introduces "Dia" support via  
external_templates. Does that mean that it is *not possible* to  
achieve goal (1) (the preview in LyX, everything else works) via file  
formats and converters only?  Do I have to go the external_templates  
route?


Thanks!

Daniel




Hi,

Even though I consider myself a "LyX master" in many respects, the  
exact usage of "File Formats", "Converters" and "External  
Material..." have always remained a mystery to me. Today I gave it  
another try (LyX 1.6.3-mac) -- and failed again.


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..."


So far I got (2) and (3) working, but not (1):

-- Under [File Handling --> File formats] I have added a new file  
format "TikZ" as Vector graphics format,Short Name: "Tikz",  
Extension: "tikz", and Editor: "vim".


-- Under [File Handling --> Converters] I have added a Converter  
Definition "TikZ --> PDF (ps2pdf)"with Converter: "pdflatex $$i"


If I now embed a .tikz-file, external editing and PDF generation  
works fine, but LyX is not able to show a preview. As I interpret  
the output of "lyx -dbg graphics", LyX does not know how to  
generate a pixmap  from the input format ("TikZ"). Do I have to  
define a converter to some pixmap format as well?  How to do so?


This is pretty confusing. As I understand the manuals (don't  
remember where exactly I have read this) LyX should be able to  
deduce its route through conversion rules automatically, that is,  
to convert from TikZ to PDF first  and then from PDF to the pixmap  
required for the preview functionality.


Re: How to get a preview for "custom" graphics format?

2009-08-11 Thread Pavel Sanda
Daniel Lohmann wrote:
> that mean that it is *not possible* to achieve goal (1) (the preview in 
> LyX, everything else works) via file formats and converters only?

unless imagemagick convert utility knows how to deal with it (i think it 
doesn't)
i'm not aware of such a plain route.
pavel


Re: How to get a preview for custom graphics format?

2009-08-09 Thread Pavel Sanda
Daniel Lohmann wrote:
 Your  help is highly appreciated!

try to mimic http://www.lyx.org/trac/changeset/27914
and ask for inclusion if you succeed. you may also
want to comment on bug 4882.
pavel


Re: How to get a preview for custom graphics format?

2009-08-09 Thread Pavel Sanda
Daniel Lohmann wrote:
 Your  help is highly appreciated!

try to mimic http://www.lyx.org/trac/changeset/27914
and ask for inclusion if you succeed. you may also
want to comment on bug 4882.
pavel


Re: How to get a preview for "custom" graphics format?

2009-08-09 Thread Pavel Sanda
Daniel Lohmann wrote:
> Your  help is highly appreciated!

try to mimic http://www.lyx.org/trac/changeset/27914
and ask for inclusion if you succeed. you may also
want to comment on bug 4882.
pavel