Re: How to access graphics files exported from LyX from LaTeX insets?

2011-02-18 Thread Kuba Ober
On Feb 17, 2011, at 8:58 PM, Richard Heck wrote:

 On 02/17/2011 07:05 PM, Kuba Ober wrote:
 Now I'm trying to add graphics to the page header in the document preamble, 
 and I'd
 like to be able somehow to refer to the graphics file exported by LyX. What 
 I need
 is a way of knowing that file foo.eps got exported as baz_bar_foo.eps to the 
 temp
 directory.
 
 This also applies to not being able to, say, have an \includegraphics{foo} 
 in a LaTeX inset: LyX only processes graphics insets when exporting files, 
 it does not detect manually inserted \includegraphics.
 
 A solution to my problem would be either:
 1. how to predict (perhaps LyX could insert a macro for each exported 
 file?)
 exported graphics file's name.
 
 There's a specific routine in the LyX source that produces this mangled 
 filename. You can have a look at it if you want to see how it works.
 
 2. how to force LyX to automagically process \includegraphics{} in LaTeX 
 insets,
 document preamble, etc.
 
 It's kind of LyX's policy that you are on your own as far as ERT, etc, is 
 concerned. Parsing this stuff would be very difficult.
 
 That said, if the graphic is in some location LaTeX knows about---e.g., the 
 same directory as the LaTeX file, or somewhere else that LaTeX can find 
 it---then LaTeX will find it just as if you were running LaTeX manually on 
 the file. So you don't need to refer to LyX's exported file but can just 
 refer to your original.

The problem is that the LaTeX file is in a transient, temporary location that 
LyX creates when exporting (say to dvi). There is no way for me to put anything 
there.

This problem seems to apply not only to graphics, but to any file that's 
included/referenced in ERT, document preamble, etc.

So, the general problem is thus: LyX prevents me from referencing any files 
that it doesn't know about in the LaTeX output.

This completely breaks things that are easy when you use plain LaTeX: say that 
you want to include graphics in the page header/footer. There's no way to do it 
directly in LyX (or is there?), so you have to put the header
definition in ERT or in the preamble. But the files that I have in the 
directory where the .lyx document resides are inaccessible to LaTeX unless LyX 
knows about them and copies them into the temp directory!

In general case, you cannot refer to files outside of the directory where the 
exported LaTeX file resides, since they may well contain spaces: this is simply 
a mis-feature of LaTeX that LyX works around. It's just that the workaround is 
not exposed in any way other than via the inset/include mechanism. It is also 
impossible to know in general where the .lyx file resides: to refer to it from 
the LyX's export directory you'd need a full path, and that may well be 
anywhere on a user's system. Hardcoding the path, even if it contained no 
spaces, still leaves you with broken output as soon as you move the .lyx file 
anywhere, or send it to someone, etc.

I'm thinking of a following feature that would fix it:

A list of extra files in the document settings dialog, that LyX moves over to 
the export directory along with other files it knows about (the exported LaTeX 
output, [converted] graphics, etc). There would be two entries per file: the 
full path, and the output (exported) file name. By default, the output file 
name would simply be the path-less name of the source file. In case of 
conflicts, numeric suffixes could be automatically appended. A checkbox would 
enable a custom output file name in cases where it'd help.

Would this be something that could be accepted as a patch this late in the 2.0 
cycle? I think I could give it a shot.

Cheers, Kuba

Re: How to access graphics files exported from LyX from LaTeX insets?

2011-02-18 Thread Kuba Ober
On Feb 17, 2011, at 8:58 PM, Richard Heck wrote:

 On 02/17/2011 07:05 PM, Kuba Ober wrote:
 Now I'm trying to add graphics to the page header in the document preamble, 
 and I'd
 like to be able somehow to refer to the graphics file exported by LyX. What 
 I need
 is a way of knowing that file foo.eps got exported as baz_bar_foo.eps to the 
 temp
 directory.
 
 This also applies to not being able to, say, have an \includegraphics{foo} 
 in a LaTeX inset: LyX only processes graphics insets when exporting files, 
 it does not detect manually inserted \includegraphics.
 
 A solution to my problem would be either:
 1. how to predict (perhaps LyX could insert a macro for each exported 
 file?)
 exported graphics file's name.
 
 There's a specific routine in the LyX source that produces this mangled 
 filename. You can have a look at it if you want to see how it works.
 
 2. how to force LyX to automagically process \includegraphics{} in LaTeX 
 insets,
 document preamble, etc.
 
 It's kind of LyX's policy that you are on your own as far as ERT, etc, is 
 concerned. Parsing this stuff would be very difficult.
 
 That said, if the graphic is in some location LaTeX knows about---e.g., the 
 same directory as the LaTeX file, or somewhere else that LaTeX can find 
 it---then LaTeX will find it just as if you were running LaTeX manually on 
 the file. So you don't need to refer to LyX's exported file but can just 
 refer to your original.

The problem is that the LaTeX file is in a transient, temporary location that 
LyX creates when exporting (say to dvi). There is no way for me to put anything 
there.

This problem seems to apply not only to graphics, but to any file that's 
included/referenced in ERT, document preamble, etc.

So, the general problem is thus: LyX prevents me from referencing any files 
that it doesn't know about in the LaTeX output.

This completely breaks things that are easy when you use plain LaTeX: say that 
you want to include graphics in the page header/footer. There's no way to do it 
directly in LyX (or is there?), so you have to put the header
definition in ERT or in the preamble. But the files that I have in the 
directory where the .lyx document resides are inaccessible to LaTeX unless LyX 
knows about them and copies them into the temp directory!

In general case, you cannot refer to files outside of the directory where the 
exported LaTeX file resides, since they may well contain spaces: this is simply 
a mis-feature of LaTeX that LyX works around. It's just that the workaround is 
not exposed in any way other than via the inset/include mechanism. It is also 
impossible to know in general where the .lyx file resides: to refer to it from 
the LyX's export directory you'd need a full path, and that may well be 
anywhere on a user's system. Hardcoding the path, even if it contained no 
spaces, still leaves you with broken output as soon as you move the .lyx file 
anywhere, or send it to someone, etc.

I'm thinking of a following feature that would fix it:

A list of extra files in the document settings dialog, that LyX moves over to 
the export directory along with other files it knows about (the exported LaTeX 
output, [converted] graphics, etc). There would be two entries per file: the 
full path, and the output (exported) file name. By default, the output file 
name would simply be the path-less name of the source file. In case of 
conflicts, numeric suffixes could be automatically appended. A checkbox would 
enable a custom output file name in cases where it'd help.

Would this be something that could be accepted as a patch this late in the 2.0 
cycle? I think I could give it a shot.

Cheers, Kuba

Re: How to access graphics files exported from LyX from LaTeX insets?

2011-02-18 Thread Kuba Ober
On Feb 17, 2011, at 8:58 PM, Richard Heck wrote:

> On 02/17/2011 07:05 PM, Kuba Ober wrote:
>> Now I'm trying to add graphics to the page header in the document preamble, 
>> and I'd
>> like to be able somehow to refer to the graphics file exported by LyX. What 
>> I need
>> is a way of knowing that file foo.eps got exported as baz_bar_foo.eps to the 
>> temp
>> directory.
>> 
>> This also applies to not being able to, say, have an \includegraphics{foo} 
>> in a LaTeX inset: LyX only processes graphics insets when exporting files, 
>> it does not detect manually inserted \includegraphics.
>> 
>> A solution to my problem would be either:
>> 1. how to "predict" (perhaps LyX could insert a macro for each exported 
>> file?)
>> exported graphics file's name.
>> 
> There's a specific routine in the LyX source that produces this "mangled" 
> filename. You can have a look at it if you want to see how it works.
> 
>> 2. how to force LyX to automagically process \includegraphics{} in LaTeX 
>> insets,
>> document preamble, etc.
>> 
> It's kind of LyX's policy that you are on your own as far as ERT, etc, is 
> concerned. Parsing this stuff would be very difficult.
> 
> That said, if the graphic is in some location LaTeX knows about---e.g., the 
> same directory as the LaTeX file, or somewhere else that LaTeX can find 
> it---then LaTeX will find it just as if you were running LaTeX manually on 
> the file. So you don't need to refer to LyX's exported file but can just 
> refer to your original.

The problem is that the LaTeX file is in a transient, temporary location that 
LyX creates when exporting (say to dvi). There is no way for me to put anything 
there.

This problem seems to apply not only to graphics, but to any file that's 
included/referenced in ERT, document preamble, etc.

So, the general problem is thus: LyX prevents me from referencing any files 
that it doesn't know about in the LaTeX output.

This completely breaks things that are easy when you use plain LaTeX: say that 
you want to include graphics in the page header/footer. There's no way to do it 
directly in LyX (or is there?), so you have to put the header
definition in ERT or in the preamble. But the files that I have in the 
directory where the .lyx document resides are inaccessible to LaTeX unless LyX 
knows about them and copies them into the temp directory!

In general case, you cannot refer to files outside of the directory where the 
exported LaTeX file resides, since they may well contain spaces: this is simply 
a mis-feature of LaTeX that LyX works around. It's just that the workaround is 
not exposed in any way other than via the inset/include mechanism. It is also 
impossible to know in general where the .lyx file resides: to refer to it from 
the LyX's export directory you'd need a full path, and that may well be 
anywhere on a user's system. Hardcoding the path, even if it contained no 
spaces, still leaves you with broken output as soon as you move the .lyx file 
anywhere, or send it to someone, etc.

I'm thinking of a following feature that would fix it:

A list of "extra" files in the document settings dialog, that LyX moves over to 
the export directory along with other files it knows about (the exported LaTeX 
output, [converted] graphics, etc). There would be two entries per file: the 
full path, and the output (exported) file name. By default, the output file 
name would simply be the path-less name of the source file. In case of 
conflicts, numeric suffixes could be automatically appended. A checkbox would 
enable a custom output file name in cases where it'd help.

Would this be something that could be accepted as a patch this late in the 2.0 
cycle? I think I could give it a shot.

Cheers, Kuba

How to access graphics files exported from LyX from LaTeX insets?

2011-02-17 Thread Kuba Ober
When adding graphics to a LyX document, LyX seems to automagically export the 
files
to a temporary directory, together with the generated .tex file. This solves the
problem of having spaces in graphics file paths -- the whole path gets 
separators
such as '/' and ' ' replaced with '_'. This is the desired behavior.

Now I'm trying to add graphics to the page header in the document preamble, and 
I'd
like to be able somehow to refer to the graphics file exported by LyX. What I 
need
is a way of knowing that file foo.eps got exported as baz_bar_foo.eps to the 
temp
directory.

This also applies to not being able to, say, have an \includegraphics{foo} in a 
LaTeX
inset: LyX only processes graphics insets when exporting files, it does not 
detect
manually inserted \includegraphics.

A solution to my problem would be either:
1. how to predict (perhaps LyX could insert a macro for each exported file?)
exported graphics file's name.
2. how to force LyX to automagically process \includegraphics{} in LaTeX insets,
document preamble, etc.

It took me a while to understand where the problem was, since I could have two
identical \includegraphics{foo} in the LaTeX source preview within LyX: the one
coming from the graphics inset would correctly show the graphics, while the one
coming from a LaTeX inset would display nothing.

Perhaps this should be reported as a bug?

Cheers, Kuba

How to access graphics files exported from LyX from LaTeX insets?

2011-02-17 Thread Kuba Ober
When adding graphics to a LyX document, LyX seems to automagically export the 
files
to a temporary directory, together with the generated .tex file. This solves the
problem of having spaces in graphics file paths -- the whole path gets 
separators
such as '/' and ' ' replaced with '_'. This is the desired behavior.

Now I'm trying to add graphics to the page header in the document preamble, and 
I'd
like to be able somehow to refer to the graphics file exported by LyX. What I 
need
is a way of knowing that file foo.eps got exported as baz_bar_foo.eps to the 
temp
directory.

This also applies to not being able to, say, have an \includegraphics{foo} in a 
LaTeX
inset: LyX only processes graphics insets when exporting files, it does not 
detect
manually inserted \includegraphics.

A solution to my problem would be either:
1. how to predict (perhaps LyX could insert a macro for each exported file?)
exported graphics file's name.
2. how to force LyX to automagically process \includegraphics{} in LaTeX insets,
document preamble, etc.

It took me a while to understand where the problem was, since I could have two
identical \includegraphics{foo} in the LaTeX source preview within LyX: the one
coming from the graphics inset would correctly show the graphics, while the one
coming from a LaTeX inset would display nothing.

Perhaps this should be reported as a bug?

Cheers, Kuba

How to access graphics files exported from LyX from LaTeX insets?

2011-02-17 Thread Kuba Ober
When adding graphics to a LyX document, LyX seems to automagically export the 
files
to a temporary directory, together with the generated .tex file. This solves the
problem of having spaces in graphics file paths -- the whole path gets 
separators
such as '/' and ' ' replaced with '_'. This is the desired behavior.

Now I'm trying to add graphics to the page header in the document preamble, and 
I'd
like to be able somehow to refer to the graphics file exported by LyX. What I 
need
is a way of knowing that file foo.eps got exported as baz_bar_foo.eps to the 
temp
directory.

This also applies to not being able to, say, have an \includegraphics{foo} in a 
LaTeX
inset: LyX only processes graphics insets when exporting files, it does not 
detect
manually inserted \includegraphics.

A solution to my problem would be either:
1. how to "predict" (perhaps LyX could insert a macro for each exported file?)
exported graphics file's name.
2. how to force LyX to automagically process \includegraphics{} in LaTeX insets,
document preamble, etc.

It took me a while to understand where the problem was, since I could have two
identical \includegraphics{foo} in the LaTeX source preview within LyX: the one
coming from the graphics inset would correctly show the graphics, while the one
coming from a LaTeX inset would display nothing.

Perhaps this should be reported as a bug?

Cheers, Kuba