I need to circle multiple cells, on different rows/columns. This is a problem which has been solved.
However, I have a more particular case of the problem. I need to draw a circle that needs to illustrate that the elements of the last row are together with the ones of the first row, resulting in a matrix like in the example.
Here is the way I have implemented the table:
\begin{tabular}{c c|c|c|c|c|}
\multirow{7}{*}{\parbox{1.5cm}{$DataQ_2$}}
& \multicolumn{5}{c}{$Q_1Q_0$} \\
\cline{3-6}
\multicolumn{2}{c|}{} & 00 & 01 & 11 & 10 \\
\cline{2-6}
& \multicolumn{1}{|c|}{00} & X & 1 & 1 & 1 \\
\cline{2-6}
& \multicolumn{1}{|c|}{01} & 0 & 1 & 1 & 0 \\
\cline{2-6}
& \multicolumn{1}{|c|}{11} & 1 & 1 & 1 & 1 \\
\cline{2-6}
& \multicolumn{1}{|c|}{10} & X & 1 & 1 & 0 \\
\cline{2-6}
\end{tabular}
This is the way it looks:
This is how I want it to look(sorry for the shitty drawing quality… I hope it's obvious that I want though):
PS If you tell me a more elegant way to implement the table to look like this, it would be appreciated.
Best Answer
One option is to use the
tikzmark
library (from TikZ) to place some marks and then to use those marks to draw the frames; one possibility (adjust the settings according to your needs):The code:
If the boxes should have one end open:
Remarks:
Since some internal calculations are involved, the code needs two runs to stabilize.
Since the content of the table is mostly maths, I change to
array
instead oftabular
.I used
to have some more "air" around the cell content.
In the second example code I suppressed the \multirow and simply placed
\text{Data}Q_2
next to thearray
.