[OS X TeX] How to copy and paste tables into LaTeX (from Excel or other programs)?

Christopher Allen Christopher.T.Allen.95 at Alum.Dartmouth.ORG
Mon Dec 5 13:43:30 EST 2005


> among the standard LaTeX operations creating tables is certainly  
> one of the most cumbersome one. I am looking for an easy solution  
> to copy data from an Excel table (or Igor, or Matlab) into a LaTeX  
> document.
>
> There are macros and the Matrix Panel in TeXShop to easily create a  
> simple table but how to get the data in it?
>
> My best solution so far was to create an Excel file having only one  
> table and then save it as a csv file. Open the csv file with a text  
> editor and do a find and replace of the comma with an ampersand.  
> Select and copy into the .tex file.
> This, naturally, could be done from any program that can export  
> something like a csv file.
>
> I would like to script that in a way that I ideally only have to  
> select tabular data in any kind of program (even from a website),  
> run the script on the contents of my clipboard, and paste the  
> result into the .tex file.
>
> Does something like this exist already?

I don't know if anything exists, but I find my way less cumbersome  
than yours. I just formatted each column in MSExcel with a custom  
format. That custom format contained the LaTeX symmbols I wanted.  
Then I copied and pasted the whole thing right into LaTeX. This only  
takes one formatting command per column plus the final copy and  
paste. Since that's it, I haven't bothered looking for anything else.

Example:

Excel:
5 2 1
4 3 2
3 4 3

On the first column choose Format:Cells:Number:Custom. Type #& .
Do the same with the second column. (You could just copy and  
paste:special:formats, too, especially if you have a lot of columns.)
With the third column type #"\\" . (The "s are important here.)

New Excel:
5&2&1\\
4&3&2\\
3&4&3\\

I hope you find that helpful.

Chris
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list