LyXDocument exported from Lyx will not reimport

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

Document exported from Lyx will not reimport

Post by efroselli »

I'm producing technical documentation for a software company using Lyx. At the same time, I'm trying to learn how to use this product, with which I am a newbie.

Often, there are bugs in the Lyx output that I would like to try and correct in the source-code directly. For example, recently, there was a lot of bolded text (\textbf{}) throughout the document that I wanted to remove globally.

So I exported the entire book using File > Export > LaTeX (plain). I edited out all the permutations of bolding with Notepad++ and some regular expressions.

Then I opened the cleaned-up *.tex document in TeXworks. The PDF compiled perfectly.

But when I tried to return it to Lyx using File > Import > LaTeX (plain), I got an error and the file would not open.

Similarly, on other occasions, I have exported to TeXWorks a file that compiles perfectly to PDF within Lyx, only to find that it won't compile to PDF in TeXworks, and will no longer compile in Lyx either, once reimported, although no changes have been made to the source.

So there seem to be some irregularities that develop when exporting and reimporting between *.lyx and *.tex files. I've also had similar issues with export/import to and from plain text.

These problems arise because, on many occasions, I would like to be able to edit the source code from directly within Lyx, for example, to delete unwanted text formats, or to try out code snippets from forums like this one. But the source-code window in Lyx is read only.

Any suggestions? Thanks to all.

EFR

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Document exported from Lyx will not reimport

Post by scottkosty »

Hi efroselli
efroselli wrote: Often, there are bugs in the Lyx output that I would like to try and correct in the source-code directly. For example, recently, there was a lot of bolded text (\textbf{}) throughout the document that I wanted to remove globally.
If these are legitimate bugs and not just personal preferences, then you should post bug reports here to fix the problem at its source:
http://www.lyx.org/trac
efroselli wrote: But when I tried to return it to Lyx using File > Import > LaTeX (plain), I got an error and the file would not open.

Similarly, on other occasions, I have exported to TeXWorks a file that compiles perfectly to PDF within Lyx, only to find that it won't compile to PDF in TeXworks, and will no longer compile in Lyx either, once reimported, although no changes have been made to the source.

So there seem to be some irregularities that develop when exporting and reimporting between *.lyx and *.tex files. I've also had similar issues with export/import to and from plain text.
Yes, it's very difficult to import .tex. This is because LyX has it's own representation so it has to parse LaTeX which is a very tricky process. If you would like, you can post individual enhancement requests here:
http://www.lyx.org/trac
Specify tex2lyx as the component.

I understand that it seems strange that LyX can't import a file that it exported, there are good technical reasons why this can be extremely difficult.

tex2lyx has had some improvements recently. If you are using Ubuntu you can easily try these improvements by using the LyX PPA:
http://wiki.lyx.org/LyX/LyXOnUbuntu#toc3
efroselli wrote: These problems arise because, on many occasions, I would like to be able to edit the source code from directly within Lyx, for example, to delete unwanted text formats, or to try out code snippets from forums like this one. But the source-code window in Lyx is read only.
This is a common request but there are no plans to implement editing of the source directly. This is because really that's not the source; the source is in C++ objects and what you are seeing there is a preview of the *export*. Because LyX has difficulties reimporting .tex, as you've noticed, this would be very unstable.

Scott
efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

Re: Document exported from Lyx will not reimport

Post by efroselli »

Thank you very much for your answer; now I know it's not just me. I'll find a different way around the problem.
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Document exported from Lyx will not reimport

Post by scottkosty »

efroselli wrote:Thank you very much for your answer; now I know it's not just me. I'll find a different way around the problem.
Many have had success by editing the .lyx file manually, which is just a text file. Of course you should be careful here and make backups.
Post Reply