I'm trying to annotate a table by highlighting and annotating the final column, yet once I use the\tabnode
together with coloring I get misalignment. Either the content of the cell marked with \tabnode
is misplaced outside of the table, or the cell is stretched in width (whereas all cells should be equal width). What is the right way to fix this? Here's a sample code I'm using:
\documentclass{beamer}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{tabularx}
\begin{document}
\begin{frame}{Title}
\newcounter{nodecount}
\newcommand\tabnode[1]{\addtocounter{nodecount}{1}\tikz\node(\arabic{nodecount}){#1};}
\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]
\newcolumntype{g}{>{\columncolor{red}}c}
\begin{table}[ht]
\centering
\begin{tabular}{|c|c|c|g|}\hline
bla & bla & bla & \tabnode{$b_1$}& \hline
bla & bla & bla & bla & \hline
bla & bla & bla & bla & \hline
bla & bla & bla & bla & \hline
bla & bla & bla & bla & \hline
bla & bla & bla & bla & \hline
\end{tabular}
\end{table}
\begin{tikzpicture}[overlay]
\node [right=2cm,above=2cm,minimum width=0pt] at (1) (A) {A};
\draw [<-,out=5,in=180] (1) to (A);
\end{tikzpicture}
\end{frame}
Best Answer
Your code has some mistakes that will produce errors (in particular, you declared four columns but were using five and you forgot the line changing commands): below I corrected them and fixed other aspects:
I'd like to propose you, however, another approach using the
tikzmark
library: the general idea is still the same; using \tikzmark you place a "mark", as in\tikzmark{a}
and then you can use this mark usingpic cs
. as in\draw (pic cs:a) -- ++(1,0);
. A complete example:It's not clear why are you loading the
hf-tikz
package, since it doesn't pay any rol in your MWE.