TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to write pure latex to a separate file and then include that in the LyX document. What are the pros and cons of doing that? As far as I understand there are problems with preamble. Basically what I would like to do is this - write a table to separate latex file and then include that in the document (I would be great if document header and footer came from LyX document.

share|improve this question
up vote 6 down vote accepted

Go to Insert > File > Child Document. See the section "7.2 Child Documents" in the Help > Embedded Objects manual. It explains how to insert .lyx files, .tex files, and .txt files (verbatim).

share|improve this answer
Thanks, this helped me. As a sidenote to anybody who ever is puzzled about the same thing, .tex file should not include his own preable, but only the content. – user1335014 Feb 13 '13 at 15:32

You can use \input{foo.tex} or \include{foo.tex} to insert files containing only body text. But these two commands are different. Look for the difference.

share|improve this answer
Where is the relation to LyX? – Daniel Feb 13 '13 at 13:39
@Daniel, does not LyX accept command line? – Sigur Feb 14 '13 at 13:36
While it would be possible to write \input{...} or \include{...} commands into an ERT box, they would usually fail (if relative paths are used, which is good practice), as LyX generates and compiles everything inside a temporary folder. Hence, the mechanism built into LyX, described by scottkosty, is preferable. However, the point is that the answer, as given, is not really helpful anyway: It does not address the OPs issue and instead of writing "Look for the differences" it would be better to describe them briefly. – Daniel Feb 14 '13 at 14:24
@Daniel, OK. I'll delete the usefulness answer. – Sigur Feb 14 '13 at 15:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.