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.

  • 1
    Welcome to TeX.sx!
    – Mensch
    Oct 25, 2012 at 23:41
  • 1
    Do you want the tables to be imported in a nice formatted fashion (like regular tabulars in LaTeX), or a plain ASCII table that obeys the spaces? The former would have to be done outside of LaTeX/LyX, but the second inside.
    – Werner
    Oct 26, 2012 at 5:43
  • @Werner Like I said I'm a noob so I might have misunderstood what you mean but I'd just want to be able to take the above table from my text file and import it into LyX. So I think I just want an ASCII table that obeys the spaces already defined by the text file. Oct 26, 2012 at 14:37

1 Answer 1


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

  • I'll try it out and if it works, I'll accept the answer, if it works. Thank you for taking the time to answer. Oct 27, 2012 at 1:27

You must log in to answer this question.

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