I know there are a few posts about this but i dont think they are sufficient.

I wrote a paper in lyx and need to submit the contents of it to a journal (a common need). So the figures (png's, pdf's, eps's, etc) are scattered all over my filesystem. I need a way to translate what i have to what the publisher needs. This means consolidating all the necessary files, and exporting them to a new directory along with the tex source code, and bibtex file.

I have tried the lyx export-> archive, but this does not export all of my figures. Also in the exported lyx file, all the images point to the original files, NOT the exported ones.

I have tried export->latex(plain) but it sends the output all over my filesystem, where they come from.

in summary, I want an export to publisher option. since this is a very common application I am sure it exists and i just missing it.


  • Are you looking for advice on how to organize your files? – Noble P. Abraham Sep 17 '12 at 14:44
  • What OS are you using? From asking for a "publisher" like solution I guess it's Windows where file links wouldn't work (not tested but that may be a solution in Linux). – vaettchen Sep 17 '12 at 16:08
  • 1
    I would think the only way this can be done is by writing a script that parses your .tex file (as exported by LyX), replacing all the scattered references to relative ones and also correcting the contents within the .tex file. Just a suggestion for the script-minded. – Werner Sep 17 '12 at 16:36

Please provide your LyX version and OS for posts about LyX.

You found LyX's attempted solution: export -> LyX archive. You say that some of your images are included and some are not. This suggests a bug. I am guessing that it is this one: http://www.lyx.org/trac/ticket/8164

The last commit for 2.0.4 was on June 25th so this should be in LyX 2.0.4. If this does not solve your problem (e.g. if you are already using 2.0.4), please post a bug report on www.lyx.org/trac.

Here is the patch below. You only have to apply it to the lyxpak.py file so no recompiling is necessary. You can download the file from here: http://git.lyx.org/?p=lyx.git;a=blob_plain;f=lib/scripts/lyxpak.py;hb=5909fc467a2e1106b57561fb811c8d2f4198db63

Or you can apply the diff of the commit pasted below:

commit 5909fc467a2e1106b57561fb811c8d2f4198db63
Author: Enrico Forestieri 
Date:   Sun May 20 16:32:47 2012 +0200

    Fix bug #8164: lyxpak.py fails to include filenames with spaces

    People love embedding spaces in filenames, so account for that.

    (cherry picked from commit fbcf2486d84b4ea543560cb7f583bc38e6cf67f5)

diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py
index 37829e0..d341977 100755
--- a/lib/scripts/lyxpak.py
+++ b/lib/scripts/lyxpak.py
@@ -23,15 +23,15 @@ from getopt import getopt

 # Pre-compiled regular expressions.
 re_lyxfile = re.compile("\.lyx$")
-re_input = re.compile(r'^(.*)\\(input|include){(\s*)(\S+)(\s*)}.*$')
-re_ertinput = re.compile(r'^(input|include)({)(\s*)(\S+)(\s*)}.*$')
-re_package = re.compile(r'^(.*)\\(usepackage){(\s*)(\S+)(\s*)}.*$')
-re_class = re.compile(r'^(\\)(textclass)(\s+)(\S+)$')
-re_norecur = re.compile(r'^(.*)\\(verbatiminput|lstinputlisting|includegraphics\[*.*\]*){(\s*)(\S+)(\s*)}.*$')
-re_ertnorecur = re.compile(r'^(verbatiminput|lstinputlisting|includegraphics\[*.*\]*)({)(\s*)(\S+)(\s*)}.*$')
-re_filename = re.compile(r'^(\s*)(filename)(\s+)(\S+)$')
-re_options = re.compile(r'^(\s*)options(\s+)(\S+)$')
-re_bibfiles = re.compile(r'^(\s*)bibfiles(\s+)(\S+)$')
+re_input = re.compile(r'^(.*)\\(input|include){(\s*)(.+)(\s*)}.*$')
+re_ertinput = re.compile(r'^(input|include)({)(\s*)(.+)(\s*)}.*$')
+re_package = re.compile(r'^(.*)\\(usepackage){(\s*)(.+)(\s*)}.*$')
+re_class = re.compile(r'^(\\)(textclass)(\s+)(.+)\s*$')
+re_norecur = re.compile(r'^(.*)\\(verbatiminput|lstinputlisting|includegraphics\[*.*\]*){(\s*)(.+)(\s*)}.*$')
+re_ertnorecur = re.compile(r'^(verbatiminput|lstinputlisting|includegraphics\[*.*\]*)({)(\s*)(.+)(\s*)}.*$')
+re_filename = re.compile(r'^(\s*)(filename)(\s+)(.+)\s*$')
+re_options = re.compile(r'^(\s*)options(\s+)(.+)\s*$')
+re_bibfiles = re.compile(r'^(\s*)bibfiles(\s+)(.+)\s*$')

 def usage(prog_name):

| improve this answer | |
  • 1
    your diagnosis is correct. I am using lyx 2.0.2, packed on ubuntu 12.04. i have applied the patch as you suggest and lyxpak now includes all files into the archive. however, the file-paths in the archived lyx file are absolute not relative, so as it is, the archive is of little use. anyway, this functionality is sufficient for my needs. ideally, the lyxpak would alter the paths to be relative to archive root, and perhaps provide an option to flatten out the filesytem. but this is more of a feature request. thank you for the help! – user18823 Sep 20 '12 at 16:35
  • @user18823 I agree, that would be a useful feature. – scottkosty Sep 20 '12 at 18:04
  • 1
    i have created a feature request ticket. lyx.org/trac/ticket/8348 – user18823 Sep 20 '12 at 18:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.