Currentlly tex2lyx does not support all features used by lyx-exported .tex files. As a result, it's very difficult to work with people who do not use lyx, because it needs convert between .lyx and .tex back and forth.
This patch addresses these problems I ever met during the convertion between .lyx and .tex Specially the following features are added: 1. \caption{...} support. This feature is missing after the caption is converted to an inset. We have one bug for this: http://bugzilla.lyx.org/show_bug.cgi?id=3750 This patch uses the same trick of the patch uploaded in that bug. 2. \begin{spacing}{...}...\end{spacing} This environment is used by lyx to set custom line space. 3. \lyxline{...} This command is used by lyx to draw horz line. 4. Some preamble lines are generated by lyx automatically according to the features used by the document. These preamble lines should not be read back from tex2lyx. I added special marks in latex comment during export and detect them in tex2lyx so that we can ignore them. But I'm not sure I'm doing completely correct thing. Please double check this. 5. Some latex class may have multiple lyx layouts with different .sty packages included. So I added special marks of the used lyx layout in latex comment during export and detect them in tex2lyx. If we find one from the comment, we use that layout. Or else tex2lyx will search the layout as before. 6. lyx output comments in preamble are all marked with special marks so that tex2lyx can ignore them. With all above patches, now tex2lyx can read back lyx-exported .tex files much better. I believe there are still some features used by .lyx but still not supported by tex2lyx, but so far I havn't met them. If you find some, please tell me and I can add them. Or better, you make another patch to support them :-) In addition to above features, this patch adds support for the following latex features: (1) Support for {\em ...}. My supervisor uses it a lot, and maybe other people from LaTeX 2.09 use it frequently. (2) Support for \centerline{...}. Again my supervisor uses it a lot... (3) Support for \psfig and \epsfig. The two commands are equivelant to \includegraphics and can be translated to Graphics inset perfectly. So I just convert it to Graphics inset. No (e)psfig package support needed. And again my supervisor uses it a lot, so I have to implement it... Please test and give me comment. Thanks! Hangzai