12

Is there a plug in or something that can convert Ms Word or Ms Excel tables exactly as they are (with borders etc) to Latex? I have used http://www.ctan.org/pkg/excel2latex but it removes the lines in between cells.

I also tried to use http://www.tablesgenerator.com/# but it is time consuming and I have large and complicated tables

  • 3
    Define 'complicated'. If it's just large, that shouldn't be a problem -- but if the tables are actually complex (tables within tables (shudder), etc.), then you won't have much luck. – Sean Allred May 20 '15 at 15:43
  • 1
    @user930901 See this discussion for another option tex.stackexchange.com/questions/179208/how-to-use-calc2latex. This requires you have LibreOffice installed with the calc2latex addin enabled. Again is can handle simple tables with simple formatting. – R. Schumacher May 20 '15 at 16:37
  • by complicated I mean large and borders and lines separating each row and column and also some cells are merged – user1930901 May 20 '15 at 16:55
  • 1
    Sounds simple enough for excel2latex -- have you tried it? – Sean Allred May 20 '15 at 17:18
  • 1
    Excel2LaTeX used to override your rules if you enabled the booktabs option. As of v3.4.0 it doesn't do this anymore. So anyone reading this in the future should give it a shot! (Disclaimer: I currently maintain Excel2LaTeX.) – Chel Aug 1 '16 at 7:19
4

I have used the calc2latex macro in LibreOffice Calc to convert MS Excel files into LaTeX without issue. It handles borders and cell outlines fairly well.

This package, found at http://calc2latex.sourceforge.net/, is mentioned in a comment by @r-schumacher; however, it should be an official answer.

3

To say it short: No.

A little bit longer: If you want to have good looking tables you can find hints in several books over typography (for example the german book "Lesetypografie" or "Detailtypografie", I do not have english books, sorry) that for a good typography you should use empty place and no lines. Only to mark the header and the bottom of a table you can use lines (call package booktabs for this and please read the documentation of it).

To get good tables you need a good constuction of the table. I fear in the most cases you can only get this with good old handwork ...

@Sean Allred clarified in his comment: in the absolutely general case (i.e. arbitrarily complex), conversion is not possible. However, scripts exist which try to take the most simple of these cases and create an analog for them with LaTeX. It very much depends on how complicated you made your table with a format that nobody but Microsoft really understands.

  • 2
    +1, but I want to clarify a bit for OP: in the absolutely general case (i.e. arbitrarily complex), conversion is not possible. However, scripts exist which try to take the most simple of these cases and create an analog for them with LaTeX. It very much depends on how complicated you made your table with a format that nobody but Microsoft really understands. – Sean Allred May 20 '15 at 15:43
2

There's always excel2latex; I'm not sure how well it works, but it's on CTAN.

If this or some similar program doesn't work, and it is absolutely, positively not an option to recreate these tables in LaTeX, the best you'll probably be able to manage is convert them to an image and include them that way.

It seems that there are some convoluted ways to do this from within Excel (see, e.g., convert MS tables to images.

You can also simply take screenshots and get the images that way.

You can then include the resulting image in your LaTeX document in the usual way:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{table.jpg}
\end{document}

The problem with this approach is that your fonts, line thickness, and such may not match those in your tables. But that is a peril of using binary or non-transparent file formats.

1

On Mac OS X I suggest the following solution which can similarly work on other OS. The solution allows to work with light-vectorial images.

  1. Export your sheet as a .pdf file
  2. Open it with preview app end use the selection tool to select the interesting part of the table.
  3. Copy it (cmd+c) and open a new preview window (cmd+n)
  4. Save the selected table as my_table.pdf
  5. Import my_table.pdf by

    \documentclass{article} 
    \usepackage{graphicx}
    \begin{document}
    \includegraphics{my_table.pdf}
    \end{document}
    
  • But the fonts could be different from the rest of the LaTeX document... – CarLaTeX Apr 19 '17 at 8:49
  • You have to choose the font properly before to export. – Colo Apr 19 '17 at 8:51
  • @Colo That's not always as simple as it sounds. As it is currently written it is a very specific answer for a very general problem. Probably you should try to elaborate on some solutions to common issues with that solution. – TeXnician Apr 19 '17 at 9:10
1

There is a work around using Lyx. You can insert a table of the exact number of rows and columns. Copy the table in Excel, should work in Word too. Then in the top left hand corner cell go to Edit-Paste Special-Plain Text. You can then do tidy it up, merge cells etc. If you have the Latex source window visible you can copy and paste the Latex markup into your tex file.

0

Inspiring by @Colo.

If you export the table as PDF file, and - after - process it with Inskcape, you save it as PDF, Inskcape say you if you would like a single PDF or a PDF + LaTeX format, where all the fonts are replaced by LaTeX and... are the same of your document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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