I'm using LyX for technical documentation and want to automate the process of creating PDF files.
Within LyX, I can simply click the button "View PDF (XeTeX)", and LyX performs the whole build process for me: it creates a .tex file, does some bibliography magic, and uses XeTeX to create the final PDF file.
What I'm looking for is a way to call LyX from the command line and get the same result. So far, I've only managed to generate a plain .tex file (using --export-to xetex
). However, when I run xelatex on the generated file, it keeps showing errors that don't occur when building using LyX. Is there a way to get LyX to do the work?
My system: Windows 7 64bit, LyX 2.1.0
Best Answer
The command sequence for exporting
.lyx
files to pdf/dvi (etc) from command prompt iswhere
FORMAT
is the short identifier of the format you want to export, e.g., "dvi" for DVI files or "pdf2" to export PDF via pdflatex. You may see theFile Formats
pane in LyX's preferences dialog for a list of the available formats.For example, to convert
.lyx
file to pdf usingxelatex
, the command will beOn the other hand, you may prefer to use a
.bat
file so that you can put the.bat
file in the same directory as your.lyx
file and simply double click on it.Save the above as
lyxbatch.bat
(say), in the same folder as your.lyx
file. Double clicking on this file will export all.lyx
files in the current folder topdf
files usingxelatex. You have to have
lyx.exe` added to your system path.Untested as I don't have lyx installed in this computer. If there are any hassles please let me know.