5

I am trying to understand what the following line implies for a tabular and did not find anything matching it: \begin{tabular}{|*{2}{@{}p{184pt}@{}|}}

  • What is the *{2} for?
  • What is the @{} for?
  • Welcome to TeX.SX! You should read a book on LaTeX tables ;-) Shortly said, it defines 2 table columns with parbox width of 184 pt, with vertical lines and no space between cell content and the vertical lines (i.e. \tabcolsep is effectively 0pt – user31729 Oct 15 '14 at 12:51
8
  • The *{2}{...} will replicate the content of the column specification {...} twice

    If there are, say 10 columns, it is quicker to write \begin{tabular}{*{10}{l}} instead of \begin{tabular}{llllllllll}. Both will provide a table with 10 left aligned column content.

  • @{} will remove the space between the vertical line | and the true cell content. Since there are two of such spaces, both @{} to the left and to right have to specified, if it should be removed. This is a better alternative to \setlength{\tabcolsep{0pt}, see also Unwanted padding in tabular columns when cells contain multiple rows.

    Normally \tabcolsep defaults to 6pt

  • Ok, thank you. How can I automatically center the content of the tabular cells with such a definition, please? – wipman Oct 15 '14 at 15:37
  • @wipman: Centering horizontally? \begin{tabular}{*{2}{c}} for example – user31729 Oct 15 '14 at 15:51
  • @wipman: Does my proposition answer your question? – user31729 Oct 17 '14 at 16:11
  • Yes, it does, but as soon as I try to change the dimensions of my tabular, the centering applies no more, and the headers keep their former position (the one set with: \begin{tabular}{*{2}{c}}). – wipman Oct 21 '14 at 14:42
  • @wipman: Please post an example into your question above, as it's hard to guess what might go wrong – user31729 Oct 21 '14 at 14:44

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.