[Tex/LaTex] How to import a text file into Lyx keeping its formatting

importlyxtables

I apologize in advance if this question has been asked before.

I am trying to import a text file, that contains my MySQL output, into the LyX document I'm working on. The text file contains tables created by MySQL.

This is what part of the file looks like (it's 146 pages long so I won't paste the whole thing):

+-------------------+----------+
| Name              | Area     |
+-------------------+----------+
| Africa            | 30254700 |
| America           | 39872000 |
| Asia              | 45095300 |
| Australia/Oceania |  8503470 |
| Europe            |  9562490 |
+-------------------+----------+

This is the smallest table, of course, there are far bigger tables. I don't want to have to do write it all down by hand, if I can avoid it.

I have tried converting the file to JPEGs and import them but that messes up formatting. I have also tried to copy and paste but that changes the formatting and gets rid of extra spaces.

I'd really appreciate any help that you guys can give me here.

I am a noob at LyX so I'd also appreciate simple instructions.

Best Answer

You can try using a listing. First, choose Insert --> Program listing, which will give you a box. With the cursor inside this box, choose Insert --> File --> Plain text, and select the text file.

You can change the settings (fonts etc.) for one such box by right clicking inside it and clicking Settings, or globally by going to Document --> Settings --> Listings. You can get a list of all available parameters in LyX by writing a question mark (as mentioned in the settings dialog), or refer to the listings manual, where they'll also be explained.

With default settings:

enter image description here

Related Question