Marc Mertens wrote:
Hello,
I'm considering to switch from texmacs to lyx but I don't want to loose
my old documents, to this end I tried to export my documents from texmacs to
latex format and use the import function of lyx to import it in .lyx format.
I I do this then I see that macros that are added by texmacs to the latex
file are not used in lyx, having as effect that texmacs theorem,
proposition , enumerations etc .. are not rendered correctly when I view them
in lyx. If I use 'latex' to generate a .dvi file from the exported .tex file
from texmacs then everything is rendered in the correct way.
Right. The conversion is done by a program tex2lyx that does not
recognize the environments you are using. The things it does recognize
are detailed in the manpage for the program.
Is there a way to import latex files containing macros in lyx (more
specifically latex generated by texmacs).
Yeah, improve tex2lyx. ;-)
Seriously, the only way to do this (other than manually) would be to
write some kind of program that does the conversion. This is not as hard
as it sounds, if you have any programming experience at all. The lyx
file format is pretty simple, really. In your case, it's a matter of
replacing bits that look like this:
\begin_inset ERT
status collapsed
\begin_layout Standard
\backslash
begin{theorem}
\end_layout
\end_inset
with bits that look like this:
\begin_layout Theorem
and so forth. You could do this with sed, perl, python, whatever. It's
messy and would take a bit, but once you had the filter written, it'd be
easy to reuse it. And other people might even benefit, if you posted it
on the wiki, and write it in a way that makes it extensible. (E.g.,
don't hardcode the "theorem"-->"Theorem" bit, but use some sort of
associative array.)
That said, you will then have another issue, namely, that LyX may not
know about some of the environments you are using. This will depend upon
what document class you are using. LyX's article class, for example,
does not know about theorem and proof environments. But you could just
create a myarticle.layout class and include amsmaths.inc. This will be
easier in 1.6, because of the introduction of layout modules. Even then,
you would need to write your own layout for the enumeratenumeric
environment, or else just change these to enumerate and fix the numeric
bit some other way.
Lots of us here have experience with this sort of thing. And are
prepared to help.
rh