Steve Litt wrote: > On Wed, 8 Jul 2015 06:24:52 +0000 (UTC) > Ian <iank...@gmail.com> wrote: > >> Hi >> >> I want to automatically update latex code embedded in a LyX document >> that was produced as output from another program, in my case STATA. >> The Latex code contains table commands. >> >> The concept is similar to handling graphics in LyX: Insert >> Graphic >> >> (attach file). If I change the graphic file content, keeping the >> >> file name >> and location the same, the graphic image will automatically update in >> LyX. I want to do the same thing, but with a .tex file in which >> contains the Latex code for a table produced by STATA. The .tex file >> name and location remain constant, but the content changes. >> >> I am sure this is an easy thing, but I just can't seem to find it on >> the web forums.
This is possible: LyX has a mechanism called "external templates" which can be seen as a generalization of the graphics inset: With an external template, you can tell LyX what it needs to do to convert your STATA file into LaTeX, and you also tell it how this LaTeX is to be included in the LyX document. The only requirement for this to work is that your application (or any other tool) allows to convert to LaTeX from the command line. If you want to use this feature, you need to do two things: 1) Define a new external template for STATA as explained in chapter 6 "6 Including External Material" in the Customization Manual. This neds to be once, and if you need help don't hesitate to ask on the list. 2) Each time you want to include a STATA output, you use Insert -> File -> External Material. > I do that kind of stuff all the time. The trick is to put some kind of > an unmistakable token in your LyX doc. Then make a shellscript that > cats your LyX into a script (I'd probably use AWK, your mileage may > vary) to replace the token with the desired LaTeX, and then redirect > the script's output to another LyX file. LyX --export latex > tempfile.lyx;pdflatex tempfile.tex. This is certainly technically interesting, but I would not recommend such a procedure to the original poster, since the builtin mechanism does not need those helper scripts, and all the export/view buttons in LyX do just work. Georg