Making tables in LaTeX can be painful. All you need is a semi complex table with cells that have to span multiple rows/columns. What tools do you use to get around this complexity? Tabular? Tabularx? Are there others?
4 Answers
I really like booktabs, it creates great, high quality tables (when I say quality I mean that they are really easy to read and look very clean). I feel weird when seeing a table with a lot of cluttered \hline
s and \cline
s everywhere...
-
1+1 for booktabs- it is definitely the secret sauce that makes clean looking tables.– SharpieJul 27, 2010 at 2:42
-
2booktabs manual is a must-read, even if you don't use booktabs... Aug 4, 2010 at 18:12
-
booktabs
is highly recommended, but it doesn't make building "a semi complex table with cells that have to span multiple rows/columns" easier.– PhilippAug 14, 2010 at 19:41 -
1I must say that after using booktabs, I don't think I'll ever be able to revert to something else. The fact that it is compatible with tabularx is also pure awesomeness.– levesqueOct 13, 2010 at 15:42
External Tools
I find that a lot of the pain involved in creating LaTeX tables comes simply from laying them out- it's tough to make a table markup syntax that isn't tedious to type and modify. Because of this, I use other programs to help me deal with some of the work involved in creating tables:
If my LaTeX editor has a table wizard, I use it to create the table.
If my data is in a spreadsheet, I use a plugin to export it to LaTeX. For Excel, I use excel2latex and for OpenOffice I use calc2latex.
If my data is in R, I use the xtable package.
I find these tools take care of 80-95% of the work required to create a table- I then go through and refine some of the stylistic choices. The only problem with this approach is that the tools aren't of much use if a table requires a substantial update or re-write or needs to be generated automatically from an arbitrary dataset.
LaTeX Packages
Personally, I use the Memoir class for the majority of my documents. Memoir integrates the functionality of a ton of table packages such as booktabs and tabularx and integrates them in a sane way so your document doesn't end up with a list of \usepackage{}
s that is a mile long. See Chapter 11: Rows and Columns of the Memoir manual for a description of the support provided by the class for tabular material.
In addition to Memoir, I often augment it's capabilities with the following two packages:
The longtable package for laying out tables that flow across more than one page. Longtable's handling of table headers and footers is extremely nice for putting things like "Continued on the next page..." exactly where they are supposed to be.
The siunitx package- this package is all about typesetting units and numbers. The sinuitx package adds the
S
column descriptor which can be used to perform all kinds of advanced formatting for table columns that contain numbers such as:Alignment of separators such as commas and decimal points.
Automatic rounding, truncation or conversion to scientific notation.
One excellent package is the multicol package for spreading things across multiple columns or rows. I highly recommend it. tabularx is also very good. the cline package allows for partial lines to separate columns.
-
multicol
is not for tables. For setting things across multiple columns one uses\multicolumn
which doesn't need any package, to combine multiple rows one can use\multirow
, provided by themultirow
package.– SkillmonOct 13, 2018 at 19:00
Using AUCTeX in Emacs also allows for easy editing of tabular enviroments in LaTeX. Here's a brief illustration/explanation I worked up: http://babbagefiles.blogspot.com/2011/01/latex-table-manipulation-using.html
Preview: