lyx

Embed graphics into .lyx files instead of linking an external file?


Intuitively I would have put this question on superuser.com, but searching on stackexchange.com showed, that stackoverflow.com has become the go-to platform for asking about LyX usage.


LyX normally shares the usual LaTeX approach of keeping files separate inside a folder, containing only a reference to the (relative or absolute) path of the file, and inserting them into the output document at compile time only.

While this is desirable in many scenarios, it can also create usability issues, e.g. when copy/pasting content from an old document to a new document. By default both documents will now be pointing to the same file; If they are not in the same directory, the path will likely be pasted as an absolute path.

This has two undesirable side-effects:

  1. Files no longer used by any document are not cleaned up automatically, and
  2. Updating the graphic for the new document will also change the old document, if it is ever recompiled.

Manually copying files over before using them results in some friction in terms of usability.

Is there some way to instead embed/attach documents to the .lyx file itself, as would be the usual workflow with office suites?

Having such an option would also be better in terms of desktop integration, e.g. being able to open .lyx attachments directly from Emails without first unpacking them, or allowing more homogeneous "filing" of mixed-program documents, and more easily browsing across files in file managers, better integration with desktop search, ... e.g.

(Desired)                              (Current, with widespread
                                        directories-first sorting)

Documents/                             Documents/                                 Requires additional
  |-- 2020-05-03 Work Report May.docx    |-- 2020-05-28 Model Summary/        <-- navigation, cannot be
  |-- 2020-05-03 Work Report May.pdf     |-- 2020-05-03 Work Report May.docx      viewed directly.
  |-- 2020-05-28 Model Summary.lyx       |-- 2020-06-03 Work Report May.pdf
  |-- 2020-06-28 Model Summary.pdf       |-- 2020-06-13 Budget Report.ods
  |-- 2020-06-13 Budget Report.ods       '-- 2020-06-13 Budget Report.pdf
  '-- 2020-06-13 Budget Report.pdf
                                       Documents/2020-05-28 Model Summary/    <-- Choice between redundant use of
                                         |-- 2020-05-28 Model Summary.lyx         name (inconvenient, quickly
                                         |-- 2020-06-28 Model Summary.pdf         inconsistent) and generic names
                                         |-- overview.eps                         like document.lyx, which integrate
                                         |-- pasted-image-1.png                   badly with mailing documents and
                                         '-- pasted-image-2.png                   desktop search. Also, no cleanup 
                                                                                  of unused attachments.

Solution

  • There is currently no way to do that in LyX. I agree this would be nice. I thought there was an enhancement request already filed for this but I couldn't find it. Feel free to open another one at https://www.lyx.org/trac.

    The only current feature even loosely related to what you want is that you can go to File > Export > LyX Archive. This tries to put all of the dependencies (e.g., graphics) in one archive. I know this is not what you're looking for, but I mention it because you brought up the example of wanting to send one file as an email to someone.