2

I have never been able to figure out how to make tables do what I want in LaTeX. How do I make a two-column table with a border and a line down the middle separating the two columns?

  • Did you search here on tables? Or on wiki? en.wikibooks.org/wiki/LaTeX/Tables – Sigur Dec 23 '13 at 19:24
  • See the documentation for booktabs for the reasons that you should not want to do this anyway... – cfr Dec 24 '13 at 0:17
  • @cfr Why would you not want to do this? Also, where can I find the documentation? – okarin Dec 24 '13 at 0:18
4

This is simple enough. Modifying the examples from the wiki page a bit you get the following:

\documentclass{article}

\begin{document}

\begin{tabular}{| l | r |}
\hline
  1 & 2  \\
  3 & 4  \\
  5 & 6  \\
\hline
\end{tabular}

\end{document}

This should give you what you want. The vertical lines are created by inserting a | around (and between) the table spec arguments. The horizontal lines are created with \hline. If you wanted to, say, separate each row by a horizontal line, you would do it like this:

\documentclass{article}

\begin{document}

\begin{tabular}{| l | r |}
\hline
  1 & 2  \\
\hline
  3 & 4  \\
\hline
  5 & 6  \\
\hline
\end{tabular}

\end{document}

Hopefully this is enough to give you a sense of how simple tables work in LaTeX.

2

This is not an answer but it is too long for a comment. It is an answer to a follow-up question in the comments above.

okarin asked

Why would you not want to do this? Also, where can I find the documentation?

To answer the second question first: either read the documentation you have installed (e.g. texdoc booktabs) or see http://anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/latex/contrib/booktabs/booktabs.pdf (for English - other languages are also available).

To answer the first question, I cannot do better than quote from that documentation:

You will not go far wrong if you remember two simple guidelines at all times:

  1. Never, ever use vertical rules.
  2. Never use double rules.

These guidelines may seem extreme but I have never found a good argument in favour of breaking them. For example, if you feel that the information in the left half of a table is so different from that on the right that it needs to be separated by a vertical line, then you should use two tables instead. Not everyone follows the second guideline: I have worked for a publisher who insisted on a double light rule above a row of totals. But this would not have been my choice.

There are three further guidelines worth mentioning here as they are generally not known outside the circle of professional typesetters and subeditors:

  1. Put the units in the column heading (not in the body of the table).
  2. Always precede a decimal point by a digit; thus 0.1 not just .1.
  3. Do not use ‘ditto’ signs or any other such convention to repeat a previous value.

In many circumstances a blank will serve just as well. If it won’t, then repeat the value. Whether or not you wish to follow the minor niceties, if you use only the following commands in your formal tables your reader will be grateful. I stress that the guidelines are not just to keep the pedantic happy. The principal is that enforced structure of presentation enforces structured thought in the first instance.

I think the examples in the documentation illustrate the idea here well. It seemed weird to me at first but properly formatting tables according to the package guidelines really does produce more professional-looking results, and really does seem clearer and less distracting. Somehow the focus is on the presentation of the content rather than trying to understand the way it is presented, I think.

EDIT: Note that as I understand it, these guidelines concern material to be printed or to be read online in a print-like format. I take it they are not supposed to apply to material intended to be presented on screen via LCD projection (or an overhead projector or whatever). At least, that's how I interpret them. I do other things when using beamer to produce slides for use on screen.

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.