Prabir Barooah wrote:

> Hi all,

Hi, Prabir.

> I'm a new user to lyx and totally love it. However, I'm having this
> peculiar problem with importing tex files to lyx - tables and cross
> references get totally messed up- when I try to import latex files
> to lyx, even when the latex file was generated by lyx itself
> (export->LaTeX). I encountered this problem while trying to work on
> my tex files in both lyx (in linux) and WinEdt( windows). I'm
> running lyx 1.3.1 under Linux (Redhat 9).
> 
>   Has anyone encountered anything like this? I have heard about
>   another tex importing tool - tex2lyx, should I try to install
>   it? any help here would be greatly appreciated.

The low down: LyX currently uses a perl script called reLyX to convert 
.tex files to .lyx. It is showing its age, but should work 'most of 
the time'. The next version of LyX will have a new converter, 
tex2lyx, that is much more robust because it has a real TeX parser 
rather than a bunch of regular expressions.

You can invoke reLyX from the comand line. (man reLyX).
$ reLyX your_file.tex
This will produce a LyX file your_file.lyx made up of a nasty mess of 
different LyX formats, so we then use a python script, lyx2lyx, to 
modify this file and create something in the current LyX format.
$ lyx2lyx your_file.lyx > your_file_13x.lyx

Doing this on your sample file produces the attached 
'prabir_relyx_lyx2lyx.lyx'. I see that the labels are indeed messed 
up.

If I were to do the same thing with your original file using tex2lyx, 
I would create a lyx file in the _current_ 14x-lyx format.
$ tex2lyx prabir.tex > prabir_tex2lyx.lyx
and must therefore 'go back' to the 13x-lyx format that your version 
of lyx understands. lyx2lyx does support this 'going back', but only 
the current cvs version of lyx2lyx, not the one you have. Anyway:
$ lyx2lyx -t 221 prabir_tex2lyx.lyx > prabir_tex2lyx_lyx2lyx.lyx
I attach this file too. As you can see, the conversion is perfect.

So, conclusion: lossless conversion lyx->tex->lyx is possible, but 
you'll have to make an effort.

First off, you'll have to grab the cvs sources. In the past I've 
suggested to people that they try and grab only the necessary bits, 
but that has turned out to be near-impossible to do, so I suggest you 
grab the whole repository.

$ mkdir lyx && cd lyx
$ cvs -d :pserver:[EMAIL PROTECTED]:/cvs/lyx login
The password is 'lyx' (no quotes).
$ cvs -d :pserver:[EMAIL PROTECTED]:/cvs/lyx co lyx-devel

This will download the repository into a directory lyx-devel.

$ cd lyx-devel

In future, you can keep your tree up-to-date with
$ cvs up
No need to tell cvs where to find the repository anymore as the 
information is stored. However, do yourself a favour and put this in 
a file '.cvsrc' in your home directory
$ cat .cvsrc
diff -upN
rdiff -upN
update -dP

To prepare the sources to be built:
$ ./autogen.sh
$ mkdir build && cd build
$ ../configure --with-version-suffix

That should be enough to get things ready. Try
$ ../configure --help
to see the wild range of options you can pass to configure. I suggest 
that you use '--with-version-suffix', which will eventually lead to a 
file 'tex2lyx-1.4.0cvs' being installed in /usr/local/bin and lyx2lyx 
being placed in directory /usr/local/share/lyx-1.4.0cvs/lyx2lyx/. 
That way, the two versions can co-exist.


In general now I would suggest that you just type 'make', but that 
will build the whole of lyx and you just want the converters. Doing 
this myself:
$ (cd boost && make)
$ (cd src/support && make)
$ (cd src/tex2lyx && make)

That should give you and executable src/tex2lyx/tex2lyx. lyx2lyx needs 
no compilation.

Finally, as root
$ (cd lib && make install)
$ (cd src/tex2lyx && make install)

Good luck!
-- 
Angus

Attachment: prabir_relyx_lyx2lyx.lyx
Description: application/lyx

Attachment: prabir_tex2lyx_lyx2lyx.lyx
Description: application/lyx

Reply via email to