I would like to add a rectangular box to my table to highlight some rows. I'm trying to use tikz
with the second lot of code from Harish Kumar's answer to a similar question. However, unlike the earlier question, I'm using beamer
and the box appears in the wrong place after compiling several times. I'm attaching a picture with the desired result and what I obtain instead.
This is my code:
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tabularx,booktabs,dcolumn}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,fit}
\pdfmapfile{+sansmathaccent.map}
\newcolumntype{d}{D..{-1}}
\newcounter{nodecount}
\newcommand\tabnode[1]{\addtocounter{nodecount}{1} \tikz \node (\arabic{nodecount}) {#1};}
% Some options common to all the nodes and paths
\tikzstyle{every picture}+=[remember picture,baseline]
\tikzstyle{every node}+=[inner sep=0pt,anchor=base,
minimum width=1.8cm,align=center,text depth=.25ex,outer sep=1.5pt]
\tikzstyle{every path}+=[thick, rounded corners]
\begin{document}
\begin{frame}
\frametitle{Title of my slide}
\begin{table}
\resizebox{\textwidth}{!}{
\begin{tabular}{c*{7}{d}}
\midrule
\multicolumn{1}{c}{$CCCCC$}
& \multicolumn{1}{c}{$CCCC$}
& \multicolumn{1}{c}{$CCCC$}
& \multicolumn{1}{c}{$CCC$}
& \multicolumn{1}{c}{$CCCCCCC$}
& \multicolumn{1}{c}{$CCCCC$}
& \multicolumn{1}{c}{$CCCCC$}
& \multicolumn{1}{c}{$CCCCCCC$}
\\
\midrule
\multicolumn{8}{c}{\textbf{Panel A: AAA}} \\
\midrule
\tabnode{0} & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & \tabnode{0.00} \\
\tabnode{} & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & \tabnode{0.00} \\
& & & & & & & \\
0 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
& (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
& & & & & & & \\
0 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
& (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
\multicolumn{8}{c}{\textbf{Panel B: BBB}} \\
\midrule
0 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
& (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
& & & & & & & \\
0 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
& (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
& & & & & & & \\
0 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
& (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
\midrule
\end{tabular}
}
\begin{tikzpicture}[overlay]
\node[draw=red,rounded corners = 1ex,fit=(1)(4),inner sep = 1pt] {};
\end{tikzpicture}
\end{table}
\end{frame}
\end{document}
\tabnode
.\tabnode
. It is just another approach. But it seems like you are trying the fist solution. Does your MWE match your current progress and your purpose?dcolumn
?