What is the difference between a tabular and an array environment? When should be used the former and when the latter?

  • 5
    array is for math mode and cell contents will be typeset in math mode (` textstyleby default) and tabular` is for text mode. – Bernard Oct 6 '14 at 20:15
  • 3
    @Bernard since that's the only difference I guess you should make it an answer:-) – David Carlisle Oct 6 '14 at 20:16
  • 1
    One is normally used in text, the other in equations. – John Kormylo Oct 6 '14 at 20:16
  • 1
    I agree that should be an answer. Thank you! – Adam Oct 6 '14 at 20:17
  • @DavidCarlisle - There's another important difference between array and tabular: the name (and default value) of the parameter that governs the intercolumn whitespace (\tabcolsep and \arraycolsep). – Mico Oct 6 '14 at 20:33

The array environment is for math mode and cell contents will be typeset in math mode (textstyleby default) and tabular is for text mode.

While array requires being in math mode, the tabular environment can be used in math mode, and its contents will be typeset in text mode. Inside an array, the p, m or b specifiers also switch cell contents to text mode.

  • 2
    The exception is that p columns are in text mode also in an array. – egreg Oct 6 '14 at 20:35
  • @egreg: Yes, of course, but I focused on the main stream of the question. I'll add it, though, as it can be explained in a few words. – Bernard Oct 6 '14 at 21:14
  • Environments such as tabular, tabular*, tabularx, tabulary, and longtable -- hereafter, tabular-like environments -- should be used if much of the material they contain should be typeset in text mode. (Note that having numbers in a table does not automatically mean it's necessary to typeset the numbers in math mode.) The material formatted by the l, c, r, p, and m column types is expected to be in text mode.

    It is possible, of course, to have math-mode material in a tabular-like environment. You'll just need to encase the math material in $ switches like you would in ordinary mode. You could also use a specialized column type -- such as the D column type of the dcolumn package and the S column type of the siunitx package -- that treats its contents as being in math mode by default. (For D and S columns, you'll need to provide overrides for material that should not be be typeset in math mode.)

  • The array environment is meant to be used in a math environment, and LaTeX treats the contents of l, c, and r columns -- but not of p columns! -- as being in math mode unless you do something to override this setting. If most of the table's material is going to be in math mode, it's preferable to use an array instead of a tabular-like environment: if nothing else, you'll save yourself from having to type a lot of $ sumbols!

  • The amount of intercolumn whitespace in tabular-like environments is given by 2\tabcolsep. For array environments, the respective parameter is called \arraycolsep. The default values of \tabcolsep and \arraycolsep in the main LaTeX document classes are 6pt and 5pt, respectively.

  • There's a very important LaTeX package called array. Despite what its name might suggest, it provides all sorts of goodies for both array environments and tabular-like environments. Indeed, the tabularx package depends on and therefore automatically loads the array package.

  • 1
    Your answer is great and very detailed but I have chosen Bernard's answer as it was the first to answer my question. I really appreciate it and I have upvoted, thank you. – Adam Oct 6 '14 at 20:28

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.