TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Welcome to TeX.sx! – Kurt Oct 25 '12 at 23:41
Thank you very much! – Nicolás Carlo Oct 26 '12 at 0:04
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 '12 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. – Nicolás Carlo Oct 26 '12 at 14:37
up vote 3 down vote accepted

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

share|improve this answer
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. – Nicolás Carlo Oct 27 '12 at 1:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.