11

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.

2 Answers 2

11

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).

4
  • 3
    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. Feb 13, 2013 at 15:32
  • This seems to work, but it doesn't get the encoding right. That is, I'm using a UTF-8 encoded LaTeX document containing the word "Fiabilité" but it shows in the PDF that's rendered as "Fiabilité". How can I tell LyX to respect the UTF-8 encoding of the child document? Jul 17, 2021 at 0:57
  • I finally solved the above accent-related problem by changing Document > Settings > Language > Enoding > Other > Unicode (utf8). I had to do this for all the other Child documents that were in LyX as well. All of them were previously set to French, but if I input a .tex document that uses utf8, all the related LyX documents have to have this encoding specifically. Jul 17, 2021 at 1:49
  • @Fuhrmanator That's great you figured it out, thanks for sharing the solution!
    – scottkosty
    Jul 17, 2021 at 2:49
0

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.

4
  • Where is the relation to LyX?
    – Daniel
    Feb 13, 2013 at 13:39
  • @Daniel, does not LyX accept command line?
    – Sigur
    Feb 14, 2013 at 13:36
  • 3
    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, 2013 at 14:24
  • @Daniel, OK. I'll delete the usefulness answer.
    – Sigur
    Feb 14, 2013 at 15:15

You must log in to answer this question.

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