TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to make a table in LaTeX, where I box some of the cells within my table. And I would like to be able to nest boxes so that I can have a box in a box. Here I have an example of what I mean:

enter image description here

I have searched for this problem for some time, and I doesn't seem like I am capable of finding a solution to this problem, and I don't know how to attack the problem, since I'm pretty new to LaTeX.

share|improve this question

migrated from stackoverflow.com Oct 2 '12 at 17:04

This question came from our site for professional and enthusiast programmers.

up vote 5 down vote accepted

There are perhaps many ways of doing this, depending on how you may want to extend this. I've used an array since the arrangement in your question looks pretty tabular-like:

enter image description here

  \multicolumn{1}{l}{1.} & \quad & & \forall x\forall y : P(x,y) & \multicolumn{1}{c}{\quad} & \mbox{premise} \\ \cline{2-5}
  2. & & u_0 & \forall y : P(u_0,y) && \forall e \\ \cline{3-4}
  3. & & \multicolumn{1}{|c}{v_0} & P(u_0,v_0) & \multicolumn{1}{|c|}{} & \forall e \\ \cline{3-4}
  4. & & & \forall v : P(u_0,v) && \forall i \\ \cline{2-5}
  \multicolumn{1}{l}{5.} & & & \forall u\forall v : P(u,v) &\multicolumn{1}{c}{} & \forall i

Columns 2 and 5 are just place-holders, specified as centred; they only contain the entry \quad for spacing purposes.

tabular creation in LaTeX is tedious for large constructions. There are a couple of GUIs that could be of help:

  1. excel2latex

    enter image description here

    The default is to include \bigstruts, which requires the bigstrut package. Also, you may want to modify the default tabular output to array, and wrap it inside a display math environment \[...\].

  2. Gnumeric which allows exporting spreadsheet-like constructions to LaTeX.

  3. ...see more at Comprehensive list of tools that simplify the generation of LaTeX tables.

share|improve this answer
Thanks.. But this is going to explode, if you want more nesting, isn't it? If I want eg. 10 nested boxes, I will need about 20 placeholders, won't I? Is there a "better" way, so that I don't need empty cells? – Talouv Oct 3 '12 at 13:24
@user1712876: I've added some tabular creation aids. – Werner Oct 6 '12 at 4:01
@Werner There is calc2latex for OpenOffice/LibreOffice. – Qrrbrbirlbel Oct 6 '12 at 4:09
@Werner Isn't \text{} more appropriate than \mbox{}? – azetina Oct 7 '12 at 2:34
@azetina: In a mathematical context where you may switch between different styles (\displaystyle, \textstyle, \scriptstyle, ...), yes. However, in this instance, not so much. – Werner Oct 7 '12 at 2:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.