I would like to input the body of a lyx file into a tex file.

Currently I convert the .lyx file (say child.lyx) to child.tex in Lyx with File > Export > Latex, and use \input{child.tex} in the main .tex document, also using the standalone package to only copy the body, which works.

Somehow, if I have my main document in LyX and use \input{} in Lyx (Insert > File > Child Document ...), it works as well, but directly using \input{child.lyx} in LaTeX doesn't work.

Is there a way to avoid the conversion step, so that I could simply write in child.lyx and compile main.tex file, without having to convert the lyx file first each time?


1 Answer 1


LyX is mainly a front-end to LaTeX format (and other formats, but this is another history) and it seems able to convert the main and child LyX files to a PDF directly, but in the background, making the PDFs is the exclusive business of LaTeX.

LaTeX is not at all a front-end of LyX, it have no idea about any other format, so simply it cannot manage \input{child.lyx}.

In the screen you can see Input: child.lyx but if you open un the menu the Code Preview Pane you will see that the latex version will be \input{child.tex}. LyX will take care of export the child files behind the scenes when needed, but for LaTeX, the LyX files are a parallel universe.

Note that in LaTeX he extension .tex is assumed when \input or \include have an argument without extension tha is not found (e.g.: \input{foo} search first for file foo.tex and if this file does not exist, will search only foo). For some unknown reason, LyX omit the extension only for \include, so Include: child.lyx will be exported as \include{child} instead of \include{child.tex} but in any case Latex will search for child.tex.


You must log in to answer this question.

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