4

What commands should I run manually to repeat all the steps LyX makes to generate a final output (like pdflatex PDF) for a specific document? I need it for using in a report generator written in another language.

I've looked into "LaTeX Log", but is seems like having outputs of commands, not commands itself.

9
  • What commands LyX runs is complicated and depends on the document. Can you be more specific about what you're trying to do? From the other language, can you just call LyX from the command line? For example, lyx -e pdf2 yourfile.lyx will produce a PDF file with LyX. You can often run external commands from languages with a system command.
    – scottkosty
    Dec 3, 2013 at 8:00
  • @scottkosty I make a template in LyX and export it to .tex. Then I replace placeholders in .tex with certain TeX code and save the modified .tex file. Now, I want to run a command that would export this .tex to .pdf. And since the template was done in LyX, I see it natural to use the same set of commands as if I made .lyx → .pdf export. You advised using lyx, but can I run this: lyx -e pdf2 yourfile.tex? Dec 3, 2013 at 8:11
  • Thanks for the extra details. lyx -e pdf2 yourfile.tex will not work. You could input external material by using Insert > File > Child Document. Or if you want something more customizable Insert > File > External Material (see Help > Customization for more information on this). Or you could use Python to do substitutions: wiki.lyx.org/Examples/PLyXSystem or you could do the substitutions directly in the .lyx file (it has its own format but it's just text) and then use lyx -e pdf2 yourfile.lyx.
    – scottkosty
    Dec 3, 2013 at 8:48
  • @scottkosty The idea about editing .lyx directly is simple and effective. Great solution. I actually use R for substitutions. Dec 3, 2013 at 8:53
  • Interesting, do you use readLines and gsub ?
    – scottkosty
    Dec 3, 2013 at 9:00

1 Answer 1

7

Edit the LyX file directly. It is a text file. Then run

lyx -e pdf2 yourfile.lyx

to produce a PDF file using pdflatex.

3
  • But as I see now, my plan failed: I can't work with .lyx file as if it were .tex. I.e., .lyx file has \begin_layout Title instead of \begin{title} and so forth, so when I insert tex code in .lyx file, it returns an error on lyx -e pdf2 yourfile.lyx because only native LyX coding is supported. One option is to exclude all LyX coding (as if "Insert TeX" on the whole document), but then I lose all advantages of LyX as a TeX editor. Or another option is: Create a template in .lyx → Export to .tex → Replace placeholders → Save result as .lyx → Run lyx -e pdf2 yourfile.lyx. Dec 3, 2013 at 12:50
  • Can I convert .tex file to .pdf via lyx program? Something like lyx -e pdf2 texfile.tex? (It doesn't work.) Dec 3, 2013 at 13:07
  • 2
    @Anton LyX works on .lyx files. It is not a LaTeX editor. LaTeX is just one of the formats it can export to. It can also import .tex files (use the stand-alone program tex2lyx from the commandline) but I do not recommend the approach of export to .tex, edit and then import the .tex file because it can be very tricky to parse LaTeX so it's hard for LyX to import .tex files. If you want to input LaTeX code, use ERT. If you need to do this a lot, I would recommend a LaTeX editor instead of LyX.
    – scottkosty
    Dec 3, 2013 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .