I came across on online table editor today which looked very useful. It provides a basic interface where you may enter content for your table, and the appropriate code is generated, ready to be copied into your LaTeX document.
It’s a great tool to have, and I wish I had found it sooner. The best feature is that the generated LaTeX code is kept aligned, no matter the content. Clean code!
Of course, after entering content, you can always edit the styles, such as column justification or adding more
For much larger tables (over 100 rows), I still find it easier to adapt a copy of the raw data file into LaTeX code via the command line. Tools such as
sed are brilliant at parsing huge text files at great speed.
Say you had a data file of runtimes (
runtimes.dat) on an increasing number of threads. The data is arranged in columns. We keep the example short here, but you can apply the same commands to larger datasets.
First, we want to calculate the parallel speedup of the program. We can do this by issuing the following command in a terminal
We then get the following, found in
We can then proceed to convert this data into a LaTeX table. Let’s create a backup of the raw data file in case something goes wrong.
First we want to add ampersand symbols between each column of data. This is interpreted by LaTeX as the beginning of a new cell in the row.
We then append double-backslashes to the end of the line.
Now we have the following
We’ve done the hard part. Now we format the data into nice columns, and add the opening and closing LaTeX environment tags for creating a table.
sed command simply indents the data columns by four spaces, and is optional.
So there we have it! We have created a valid LaTeX table from the command line (
All that’s left (provided everystep was successful) is to manually add any table headings, tidy up and remove any temporary files from our directory.
As an added bonus, you can link in the table into your LaTeX document and not pollute the rest of your document. This is extremely useful if you have a table with many rows.