6

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?

4
  • Try to (1) export your LyX document (including only the ERT table) to 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.
    – Daniel
    Feb 18, 2013 at 20:32
  • @alex Is it possible posting any snapshot?, please.
    – Mika Ike
    Apr 15, 2014 at 10:52
  • this is my least favorite thing about Lyx. I've come up with another (unsatisfactory) workaround: the table pastes just fine if there are two new-lines between every line (it collapses one of them). So when I really need to edit the table I copy-paste to a text editor, add a second newline, then paste to LyX. May 3, 2015 at 5:18
  • I personally am always copy-pasting R output to TeX, 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") May 3, 2015 at 21:27

2 Answers 2

6

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.

1
  • 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.
    – scottkosty
    Feb 19, 2013 at 1:43
4

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.

You must log in to answer this question.

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