All of this information is out there, but it took me more than a few hours to successfully manage this on my Mac, so here are the steps, using LyX and TeXShop.
- 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.
- 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)
- 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. (I messed this stage up in the original posting – thanks, as always to Paul Rubin for putting me on the straight and narrow here.)
- 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:
- Run the following sequence of commands in TeXShop:
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).
Hope this is helpful – if I have missed anything, let me know in the comments.