[Tex/LaTex] Exporting from LyX to LaTeX including graphics

lyx

I have a LyX file which I'd like to convert into a LaTeX "archive" in the sense of a .zip file with the LaTeX and the graphics all in one package – is there a simple way to do this or do I simply have to edit the paths in the exported LaTeX by hand and bundle the whole thing together?

(These are .eps files that reside in various directories on my computer)

Best Answer

This is how I managed to do this - there may be more efficient ways, but this certainly worked...

  1. Go to File->Export->LyX Archive This generates a zipped tarball of your .lyx file and, crucially, all the other elements (such as graphics and bibliography) in a hierarchy of files.
  2. Unroll the tar ball (i.e. tar -xvzf yourarchive.tar.gz) in a suitable place. You now have all the files you need in a standalone hierarchy (best to place your tarball in its own directory before you do this as the subdirectories you create could go under your root directory etc)

  3. Convert the LyX file to raw LaTeX. At this point all you have a LyX archive and if you really need LaTeX you need to convert the LyX file. On a Mac the easiest way to do this is to point LyX.app at the .lyx file in your archive and open it, then run another export – this time to LaTeX (pdflatex). This will create a .tex file in your archive.

4.Make sure your bibliography is in the right place. Your bibliography needs to be in the same directory. So if your .tex file is in the bizarro directory, your bib file must be too. (I said before it should have the same name as your .tex file but that is not necessary.) Open your .tex file in TeXShop. You may need to do some editing, for instance if your .tex file refers to your bibliography under some path, so for the example above you need to make your bibliography reference look like this: \bibliography{bizarrothings}

  1. Run the following sequence of commands in TeXShop (ie to test this works):

Typeset LaTeX

Typeset BibTeX

Typeset LaTeX

Typeset LaTeX Hopefully you now have compiled a PDF file with all the correct references, which means if you package up your archive directory it will now contain the correct .tex file (it will also contain the PDF and .lyx file unless you delete them first).

Related Question