Jürgen Spitzmüller wrote: > James C. Sutherland wrote: >> Can't LyX sort through this issue in the same manner as it does with >> graphics paths, i.e. by transforming relative paths to absolute paths >> when the LaTeX is exported to the temporary directory?
It can do so if you instruct it how it should be done (using the so-called
external templates). As others wrote it can not interpret ERT at all, and
any attempt to do that would cause serious problems.
>> So behind the scenes,
>> LyX could change:
>> \subimport{ relative path }
>> to
>> \import{ absolute path }
>> when it exports the temporary files...
>
> It is a strict policy that LyX does not touch ERT. So for this, native
> support for the import package would be required.
Not necessarily. External tenplates can be used as well. I attach a quick
draft of a template for the \import command, together with an example .lyx
file. If you want to use it, append the template to the file
external_templates in your LyX installation. A template for the \subimport
command can be constructed in the same way. The only thing you need to know
are all those variables like $$AbsPath etc. These are described in the last
chapter of the customization manual. With these variables you can construct
any relative or absolute path you need. The external template definitions
are a bit awkward, but it is a very powerful mechanism, and if you use an
existing template as a base it is not difficult to create new ones.
> You can file an enhacement request for this, describing what this package
> achieves and why you think it is worth supporting it.
This might be a good idea nevertheless (for consistency with \input and
\include). As I understand it, the package works around the uncommon
handling of relative file names in LaTeX and is worth it to be supported:
Relative paths in child documents are interpreted relative to the _master
document_ in LaTeX. This is different from all other programs I know
(including LyX), where relative paths in child documents are interpreted
relative to the _child document_.
GeorgPreambleDef Import
\usepackage{import}
PreambleDefEnd
Template Import
GuiName "Import: $$AbsOrRelPathParent$$Basename"
HelpText
An imported LaTeX file.
HelpTextEnd
InputFormat latex
FileFilter "*.tex"
AutomaticProduction true
Format LaTeX
Product
"\\import{$$AbsPath}{$$AbsOrRelPathMaster$$Basename$$Extension}"
UpdateFormat latex
UpdateResult "$$AbsPath$$Basename$$Extension"
Preamble Import
ReferencedFile latex "$$AbsPath$$Basename$$Extension"
ReferencedFile latex "$$AbsPath$$Basename.aux"
FormatEnd
Format PDFLaTeX
Product
"\\import{$$AbsPath}{$$AbsOrRelPathMaster$$Basename$$Extension}"
UpdateFormat latex
UpdateResult "$$AbsPath$$Basename$$Extension"
Preamble Import
ReferencedFile pdflatex "$$AbsPath$$Basename$$Extension"
ReferencedFile pdflatex "$$AbsPath$$Basename.aux"
FormatEnd
Format Ascii
Product "[Import: $$FName]"
FormatEnd
Format DocBook
Product "[Import: $$FName]"
FormatEnd
TemplateEnd
import.lyx
Description: application/lyx
