# table and box over certain cells

I was trying a way to make a box for a certain part of my table like the following

Is there a way to create the red box?

My code so far for the table:
\begin{tabular}{cccc}
\toprule
& $x$     & $y$     &  \\
\midrule
Β     & 10    & 90    &  \\
\textcolor{blue}{B'}      & \textcolor{blue}{12}    & \textcolor{blue}{y=?}   & 2 \\
Γ     & 20    & 70    &  \\
\bottomrule
\end{tabular}%

• \tikzmark is the way to go, Jun 2 '16 at 19:23

A simple solution with pstricks: I define a pair of empty nodes at two opposite corners and join them with a \psframe command:

    \documentclass[x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}

\begin{document}
\begin{postscript}
\begin{tabular}{cccc}
\toprule
& $x$ & $y$\pnode[1.5em,1.8ex]{n2} & \\
\cmidrule[\lightrulewidth](lr){1-4}
B & 10 & 90 & \\
\pnode[-1ex, -0.8ex]{n1}\textcolor{blue}{B'} & \textcolor{blue}{12} &     \textcolor{blue}{y = ?} & 2 \\
Γ & 20 & 70 & \\
\bottomrule
\end{tabular}%
\psframe[linecolor=IndianRed3, linejoin=1](n1)(n2)
\end{postscript}

\end{document}


• If I have to compile my whole document with pdfLaTeX this code seems to fail. Is there any trick to fix it?
– Y_gr
Jun 3 '16 at 8:19
• @giannis: Yes. I forgot to mention it. You have to launch pdflatex with the --enable-write18 switch if you're under MiKTeX, or -shell-escape it you're under TeX Live or MacTeX. Alternatively, you can compile with xelatex`. Jun 3 '16 at 9:00