# Boxing some cells in tabular enviroment

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:

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.

-

## migrated from stackoverflow.comOct 2 '12 at 17:04

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

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:

\documentclass{article}
\begin{document}
$\begin{array}{l|cclc|l} \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 \end{array}$
\end{document}​


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

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 $...$.

-
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