I create tables in a spreadsheet program, convert them to LaTeX code and then use an ERT to import into my LyX document. When I paste the LaTeX code the entire thing turns out very ugly looking. The table, however, works fine but its impossible to edit within LyX due to the ugly formatting when pasted. Is there a way to import a LaTeX file into a table float instead of inserting an ERT in LyX?
2 Answers
If the table (LaTeX code) is saved in a file table1.tex
it is possible to include it into the float (or elsewhere) in LyX by using "Insert > File > Child Document..." with "Include Type: Input".
For editing the table in file table1.tex
, you can right-click on the field "Input: table1.tex" and choose "Edit Included File...". A text editor should open up displaying table1.tex
.
-
If you like this way better, you might like using instant preview, which will show what the table will look like in LyX when it's rendered to PDF (if this doesn't make sense, try it to see): First make sure instant preview is turned on. Go to Tools > Display and "Instant Preview" should be "on". Then highlight the child document inset (the grey box with the tex "Include: yourfile.tex") and go to Insert > Preview. Feb 19, 2013 at 1:43
If it's a simple file (simple in terms of simple LaTeX. It can be as wide or as long as you want), you can use the tex2lyx
program. The easiest way to do this is to go to File > Import > LaTeX (plain). Then copy that table and paste it into your main document.
Latex (pdflatex)
and then (2) to import the resulting.tex
file back into LyX. If the table is not too complex and you are lucky, LyX will transform it into a LyX table that then may be Copy&Pasted to your original document and edited there with LyX's table editor.R
output toTeX
, so this solution may be too narrow, but building on my comment above, the following (inspired by this solution to different question) works:cat(capture.output(xtable(your_table)),sep="\n\n")