14

I usually do all of my tables using Google Docs spreadsheet. This is a good and quick way to organize information and create quick tables.

Now I am writing a document in Latex and I would like to port the tables.

I tried downloading the sheet as a CSV file and then using the csvsimple package to convert it into latex, but this has several faults (does not copy cell borders, does not respect page width and height, etc), and in the end with all the configurations it is almost just as complex as creating the tables myself.

I recognize some of the problems are inherent to the CSV file format (no package can guess information that the CSV file does not contain), so I was wondering: Is any other way of quickly porting my Google Doc tables to latex?

Here is a link with a simple set of three tables and a graph that I would like to port to latex:

enter image description here

9
  • 1
    A bit clunky, but I suppose you could download the sheet as an .ods file, open it in LibreOffice, and use calc2latex to generate a LaTeX table. Mar 16, 2014 at 18:22
  • Extra information: Google Docs has an HTML export option. (That's its native-ish format, after all.) Could this be used with pandoc? (Need to run…) Mar 16, 2014 at 18:22
  • Did you take a look at pgfplotstable? That provides options to convert plaintext data files to tables. Cell borders are not exported to csv, but usually a good table needs no borders ;) If you want more detailed advice please post some sample data and a picture of what you want it to look like.
    – hugovdberg
    Mar 16, 2014 at 18:43
  • @TorbjørnT.: Clunky in deed. It does not keep the table inside the pages limits and the generated code is very basic at best. Mar 16, 2014 at 18:48
  • 2
    Open with gnumeric. The problem is that then generated source code is too complex for my taste. I prefer export the table as a LaTeX fragment and lost all the format. It is better start with a clean aaa & bbb & ccc \\ ... and lost all the vertical lines (evil) and horizontal lines as well. Add a table environment, one \toprule, one \bottomrule one \midrule of the booktabs package is no too complex and this way I obtain a clean source code and a pretty table.
    – Fran
    Mar 16, 2014 at 20:57

4 Answers 4

16

This is exactly the same problem I and my classmates were having when writing our lab reports on Experimental Physics. Since we work in groups it's great to have data on the cloud. The problem was converting sometimes dozens of tables to Latex...

So, I and a classmate of mine came up with LatexKit, a google sheets add-on that creates and exports to your Google Drive a text file containing the tabular environment of a given table.

For your case, this won't handle page width or height, nor copy the exact borders you have configured (although there is a way to overcome this, keep reading), but it can help you get started with little trouble and systematically for multiple tables.

This add-on is developed using Google apps script so, unfortunately, the lack of some features is not easily overcomeable.

It does, however, help a lot when converting tables from Google Sheets to Latex

It has some additional features that could help you or someone else in the future.

Current Features:

  • Handles multirow and multicolumn environment using the multirow package

  • Handles uncertainties notation $\pm$ (especially useful to us at experimental physics)

  • Although it does not replicate your table's borders it has some templates for border configuration (like hlines everywhere or vertical lines everywhere)
  • Allows you to configure and export multiple tables at a time using the Named Range feature.

Features that can or will be implemented (given the time and will of the community):

  • Configure the table to have the same alignments as in your Spreadsheet
  • Handle different font styles like bold, italic, etc...
  • And a lot more, you just have to pitch us the idea! Reach us either trough facebook or e-mail: latexkit.dev@gmail.com

Here's LatexKit in action

This is the table on the spreadsheet:

This is the exact code produced by LatexKit using the template 'grid':

\begin{tabular}{|c|c|}
 \hline
Time (h) & Temperature (C)   \\ \hline
12       & 19.5 $\pm$ 0.4    \\ \hline
13       & 20.3 $\pm$ 0.6    \\ \hline
14       & 21.8 $\pm$ 0.7    \\ \hline
15       & 20.9 $\pm$ 0.6    \\ \hline
16       & 19.7 $\pm$ 0.4    \\ \hline
\end{tabular}

This is the result when compiled in Latex:

enter image description here

This is really a project to the community so we would gladly take your advice to improve!

3
  • 1
    Thanks for the extension, but why it has so broad permissions? See, edit, create, and delete all of your Google Drive files
    – diralik
    Jun 22, 2019 at 12:16
  • @diraria, from what I gathered, the permissions are requested automatically by Google. It needs those permissions because of some of our features that involve the creation of .tex files to your google drive. However, the extension does not interact with any of the user's files apart from the ones it creates. We know this is not optimal but it's something we haven't been able to tackle yet
    – Daniel H.
    Jun 23, 2019 at 21:46
  • Extension seems to be promising. But asking for too many permissions that I can't risk. Thus I downloaded the data as a CSV file and used tablesgenerator.com/latex_tables to generate the Latex. Jan 3, 2020 at 21:50
2

You can use Spread-LaTeX, a simple add-on which was designed for converting a Google spreadsheet table to a LaTeX table or a LaTeX table to a Google Spreadsheet table.

4
  • Users seem not to be able to install this add-on at the time of writing this comment. Nov 28, 2019 at 11:23
  • Is there any error? I don't receive any error for this add-on error.
    – yihang.zhu
    Nov 29, 2019 at 12:23
  • ERROR: Sign in with Google temporarily disabled for this app This app has not been verified yet by Google in order to use Google Sign In.
    – arilwan
    Feb 15, 2020 at 11:58
  • 1
    The app has been verified. Hope you enjoy.
    – yihang.zhu
    Mar 11, 2020 at 16:20
0

You can use the google docs extension LatexKit

1
  • 4
    Rather than just providing a link, can you give an example of this in action. Mar 26, 2017 at 17:07
0

Perhaps the most non-invasive way would be to download the table as a CSV and then use a trusted tool for conversion of CSV into a LaTeX table.
I haven't personally used this, but you can try csv2latex.

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.