# How to draw a table with shared cells?

Starting from such a table:

\documentclass{article}
\begin{document}

\begin{table}
\begin{tabular}{|l|c|c|}
\hline
& Property 2 & Not property 2 \\
\hline
Property 1     & A          & B              \\
\hline
Not property 1 & C          & D              \\
\hline
\end{tabular}
\end{table}

\end{document}


Which gives this:

I would like to have a table where I have a multicell which covers A and B, so all the first row, and another multicell which covers A and C, so all the first column, like this:

The hard point here is that the cell A is shared between both X and Y, which is normal because it is a common property. So my problem is not about how to make multicolumn for the first nor multirow for the second, but how to make them overlap.

I though about making a Tikz figure instead in order to draw everything as I want, but considering that it is in essence a table, I wonder if it is possible to do it with the tabular environment, so I don't have to locate everything by hand in a figure.

• Not very clear what is wanted. Could you post a concrete example to play with? – Bernard Jun 5 '16 at 15:58
• Is there a TeX or LaTeX package or macro that uses +-----------+ to form tables? I was only aware of markdown or org.mode for that. Also, not to sure as to the objective of the question, maybe a MWE and a graphic mock-up of what is desired would clear things up. – A Feldman Jun 5 '16 at 16:54
• I have updated my post with concrete code and pictures. – Matthieu Vergne Jun 5 '16 at 19:06
• Do you really need this cell merged or is to suffice, that are lines between them are omitted? – Zarko Jun 5 '16 at 20:38
• It should be clear that there is an overlap. I could just remove the lines, but I would have one block of three cells, not two overlapping blocks. – Matthieu Vergne Jun 5 '16 at 23:09

I don't know whether I grasped your request, or what the table should mean.

Nevertheless I think this could be a possible solution, playing around with \cline and multicolumn

\documentclass{article}
\begin{document}

\begin{table}
\begin{tabular}{|l|c|c|}
\hline
& Property 2 & Not property 2 \\
\hline
Property 1     & \multicolumn{2}{|c|}{Y}              \\
\cline{1-1}\cline{3-3}
Not property 1 & X          & D              \\
\hline
\end{tabular}
\end{table}

\end{document}


• Unfortunately, no. Here you remove the lines, but we still miss the colored rectangles. The important point is the overlapping between the cells. Y should cover the whole line of property 1 and X the whole column of property 2. In a way or another, it should be clear that thre is an overlap between the two. – Matthieu Vergne Jun 14 '17 at 23:08
• @MatthieuVergne I did not understand that the rectangles were part of the solution. I'll elaborate later – Moriambar Jun 15 '17 at 5:45