1

I am trying to annotate a single entry in a table on a slide. My problem is that the word "tag" appears at a correct y location, but its x location is dead center of the slide. I tried xshift = ??? lots of values, but it simply wouldn't budge. I adapted the code for arrow from an answer by @Gonzalo Medina, but I have clearly made some fundamental errors in the integration, due to which I don't quite get what I want. To clarify again, I'd like more control on the word "tag", so that it positions nicely closer (in x axis) to the word "diverse", as that's what it's annotating. Additionally, I'd like it if I can enclose "tag" in a little tcolorbox. Thank you!

I want to add that I originally had a more minimal version of this code (with only the packages I need for this slide) that worked as desired; however, when integrated with the rest of my presentation (which has all the packages in the code below), I get this bug of wrong position. So it's some package interaction bug.

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{rose} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
} 
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
%\usepackage[TS1,T1]{fontenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
%\usepackage[dvipsnames]{xcolor}

%% packages I am adding
%\usepackage{colortbl}
\usepackage[customcolors,beamer]{hf-tikz} %for beautiful inline highlighted math. Thanks Claudio! 

\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{tikzmark, calc,decorations.pathmorphing,decorations.pathreplacing, patterns}
\usetikzlibrary{arrows.meta, positioning, quotes}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usepackage{amsmath}
\usetikzlibrary{fit,tikzmark}
\usepackage{skull}

\usepackage{nccmath} %for \medmath command to fit long eqns in tcolorbox
\usepackage[skins]{tcolorbox}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{mathtools}


%\tikzstyle{every picture}+=[remember picture, overlay]

\usetikzlibrary{overlay-beamer-styles} 
\usepackage[absolute,overlay]{textpos}
\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\newcommand\fiteq[1]{%
  \sbox{\mybox}{$\displaystyle#1$}%
  \ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
  \else\usebox{\mybox}\fi%
}

%% start1
\begin{document}

\begin{frame}{Title}
\tikzset{rowhl/.style={
    set fill color = white, 
    set border color = red, 
    above left offset={-0.01,0.37},
    below right offset={0.1,-0.09},
    },}

\begin{table}[htbp]
    \centering
    \resizebox{\linewidth}{!}{% Resize table to fit within \linewidth horizontally
    \begin{tabular}{c c c c c c}
    \toprule
    \multicolumn{2}{c}{\textbf{Cost}} &
\multicolumn{1}{c}{\textbf{Team}} & \multicolumn{3}{c}{\textbf{Features}} \\
\cmidrule(lr){1-2}\cmidrule(lr){4-6} 
\thead{\begin{tabular}{@{}c@{}}initial \\ cost \end{tabular}} & \thead{\begin{tabular}{@{}c@{}}secondary \\ cost \end{tabular}} &  & \multicolumn{1}{c}{scale}
    & \multicolumn{1}{c}{impact}
    & \multicolumn{1}{c}{\thead{\begin{tabular}{@{}c@{}}diverse\tikzmark{B}\\ selection \end{tabular}}}\\
\midrule
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $y1$ & $y2$ & name 1 + name 2 & \checkmark & \checkmark & \checkmark\\
    \tikzmarkin<2->[rowhl]{aa} $z1$ &  $z2$ & name 1 + name 2  +name 3 + name 4 & \checkmark & \checkmark & \checkmark \tikzmarkend{aa} \\
        $v1$  & $v2$ & name 5 + name 8 + name 9 &  & \checkmark & \checkmark \\
        $w1$  & $w2$ & name 1 + name 3 + name 5 & \checkmark & \checkmark &  \\
             $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
    \bottomrule
    \end{tabular}}
\begin{tikzpicture}[remember picture,overlay]
  \node [right=5cm,above=6cm,minimum width=0pt] at (pic cs:b) (B) {tag};
  \draw [<-,out=5,in=180] ([xshift=140pt, yshift=115pt]{pic cs:b}) to (B);
\end{tikzpicture}
    \caption{teams and costs}
    \label{MyTable}
    \vspace{-4mm}
\end{table} 
%%%%%%%%
\end{frame}
\end{document}
2

There are two problems.

  1. You rescale the table "from outside". This destroys the node location mechanism of tikz/tikzmark. In general, when you use something like \resizebox or \scalebox on a tikzpicture with remember picture, the remembered coordinate positions will be off. The only way this can conceivably work is to make the overlay picture part of the \resizebox. Even then one can construct cases in which this fails, but here this is a possibility.
  2. I also cannot see a tikz mark of name b. But you probably want a \tikzmarknode anyway.

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{rose} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
} 
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
%\usepackage[TS1,T1]{fontenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
%\usepackage[dvipsnames]{xcolor}

%% packages I am adding
%\usepackage{colortbl}
\usepackage[customcolors,beamer]{hf-tikz} %for beautiful inline highlighted math. Thanks Claudio! 

\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{tikzmark, calc,decorations.pathmorphing,decorations.pathreplacing, patterns}
\usetikzlibrary{arrows.meta, positioning, quotes}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usepackage{amsmath}
\usetikzlibrary{fit,tikzmark}
\usepackage{skull}

\usepackage{nccmath} %for \medmath command to fit long eqns in tcolorbox
% \usepackage[skins]{tcolorbox}
% \tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
\usepackage{array, booktabs, longtable}
%\usepackage{graphicx} % gets loaded by beamer and tikz
%\usepackage{caption}
\usepackage{mathtools}


%\tikzstyle{every picture}+=[remember picture, overlay]

\usetikzlibrary{overlay-beamer-styles} 
\usepackage[absolute,overlay]{textpos}
\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\newcommand\fiteq[1]{%
  \sbox{\mybox}{$\displaystyle#1$}%
  \ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
  \else\usebox{\mybox}\fi%
}

%% start1
\begin{document}

\begin{frame}{Title}
\tikzset{rowhl/.style={
    set fill color = white, 
    set border color = red, 
    above left offset={-0.01,0.37},
    below right offset={0.1,-0.09},
    },}

\begin{table}[htbp]
    \centering
    \resizebox{\linewidth}{!}{% Resize table to fit within \linewidth horizontally
    \begin{tabular}{c c c c c c}
    \toprule
    \multicolumn{2}{c}{\textbf{Cost}} &
\multicolumn{1}{c}{\textbf{Team}} & \multicolumn{3}{c}{\textbf{Features}} \\
\cmidrule(lr){1-2}\cmidrule(lr){4-6} 
\thead{\begin{tabular}{@{}c@{}}initial \\ cost \end{tabular}} & \thead{\begin{tabular}{@{}c@{}}secondary \\ cost \end{tabular}} &  & \multicolumn{1}{c}{scale}
    & \multicolumn{1}{c}{impact}
    & \multicolumn{1}{c}{\thead{\begin{tabular}{@{}c@{}}\tikzmarknode{b}{diverse}\\ selection \end{tabular}}}\\
\midrule
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $y1$ & $y2$ & name 1 + name 2 & \checkmark & \checkmark & \checkmark\\
    \tikzmarkin<2->[rowhl]{aa} $z1$ &  $z2$ & name 1 + name 2  +name 3 + name 4 & \checkmark & \checkmark & \checkmark \tikzmarkend{aa} \\
        $v1$  & $v2$ & name 5 + name 8 + name 9 &  & \checkmark & \checkmark \\
        $w1$  & $w2$ & name 1 + name 3 + name 5 & \checkmark & \checkmark &  \\
             $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
    \bottomrule
    \end{tabular}
\begin{tikzpicture}[remember picture,overlay]
  \node [right=0.5cm,above=2cm,minimum width=0pt]  (B) at (b)  {tag};
  \draw [stealth-,out=5,in=180] (b) to (B);
\end{tikzpicture}}
    \caption{teams and costs}
    \label{MyTable}
    \vspace{-4mm}
\end{table} 
%%%%%%%%
\end{frame}
\end{document}

enter image description here

| improve this answer | |
  • Thank you, Schrodinger's cat! I found another fix as well. Thank you for teaching me about the subtlety of using resizebox with rememeber picture. Very simple fix, just changing the positioning of }! Is there a difference between tikzmark and tikzmarknode? – lazulikid May 30 at 19:36
  • 2
    @lazulikid I had already upvoted your post. ;-) Yes, there is a huge difference. \tikzmark{<id>} only sets a coordinate mark. \tikzmarknode{<id>}{<content>} makes <content> a node (with all sorts of nice checks which mode you are in), so you have access to all the anchors of the node (as opposed to coordinate). – user194703 May 30 at 19:39
  • Thank you! I have one final meta question. How does one get to display the output here in an answer, like you have done above? (As in, show the slide with the animation of the encircled row. – lazulikid May 30 at 19:46
  • 2
    @lazulikid I am using convert as shown at the end of this answer. For this animation I was using density 300 and delay 144. – user194703 May 30 at 19:49
  • 2
    @lazulikid Use \node [minimum width=0pt] (B) at ([xshift=1.5cm,yshift=2cm]b) {tag}; If you change the value of xshift, you can move the node to the left or right. – user194703 Jun 1 at 6:47
1

I really like Schrodinger's cat's answer, but I found another solution simultaneously (for the first time!) that I am proud of, and hence I'll post mine here as well.

I changed the way I was defining position, by using below left in relation to current page.north east. Code below.

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{rose} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
} 
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
%\usepackage[TS1,T1]{fontenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
%\usepackage[dvipsnames]{xcolor}

%% packages I am adding
%\usepackage{colortbl}
\usepackage[customcolors,beamer]{hf-tikz} %for beautiful inline highlighted math. Thanks Claudio! 

\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{tikzmark, calc,decorations.pathmorphing,decorations.pathreplacing, patterns}
\usetikzlibrary{arrows.meta, positioning, quotes}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usepackage{amsmath}
\usetikzlibrary{fit,tikzmark}
\usepackage{skull}

\usepackage{nccmath} %for \medmath command to fit long eqns in tcolorbox
\usepackage[skins]{tcolorbox}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{mathtools}


%\tikzstyle{every picture}+=[remember picture, overlay]

\usetikzlibrary{overlay-beamer-styles} 
\usepackage[absolute,overlay]{textpos}
\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\newcommand\fiteq[1]{%
  \sbox{\mybox}{$\displaystyle#1$}%
  \ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
  \else\usebox{\mybox}\fi%
}

%% start1
\begin{document}

\begin{frame}{Title}
\tikzset{rowhl/.style={
    set fill color = white, 
    set border color = red, 
    above left offset={-0.01,0.37},
    below right offset={0.1,-0.09},
    },}

\begin{table}[htbp]
    \centering
    \resizebox{\linewidth}{!}{% Resize table to fit within \linewidth horizontally
    \begin{tabular}{c c c c c c}
    \toprule
    \multicolumn{2}{c}{\textbf{Cost}} &
\multicolumn{1}{c}{\textbf{Team}} & \multicolumn{3}{c}{\textbf{Features}} \\
\cmidrule(lr){1-2}\cmidrule(lr){4-6} 
\thead{\begin{tabular}{@{}c@{}}initial \\ cost \end{tabular}} & \thead{\begin{tabular}{@{}c@{}}secondary \\ cost \end{tabular}} &  & \multicolumn{1}{c}{scale}
    & \multicolumn{1}{c}{impact}
    & \multicolumn{1}{c}{\thead{\begin{tabular}{@{}c@{}}diverse\tikzmark{B}\\ selection \end{tabular}}}\\
\midrule
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $y1$ & $y2$ & name 1 + name 2 & \checkmark & \checkmark & \checkmark\\
    \tikzmarkin<2->[rowhl]{aa} $z1$ &  $z2$ & name 1 + name 2  +name 3 + name 4 & \checkmark & \checkmark & \checkmark \tikzmarkend{aa} \\
        $v1$  & $v2$ & name 5 + name 8 + name 9 &  & \checkmark & \checkmark \\
        $w1$  & $w2$ & name 1 + name 3 + name 5 & \checkmark & \checkmark &  \\
             $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
     $x1$ & $x2$ & name 1 + name 2 + name 3 &  & \checkmark &  \\
    \bottomrule
    \end{tabular}}
\begin{tikzpicture}[remember picture,overlay, 
    tabletag/.style = {
                rounded corners, 
            draw = blue,
            thick,
            fill= white,
            inner ysep=2pt,
            inner xsep=1pt,
            align = center
            }] 
  \node  at (pic cs:b) (B) [below left= 1 cm and 2 cm of current page.north east, style = tabletag] {tag};
  \draw [<-,out=5,in=0] ([xshift=140pt, yshift=115pt]{pic cs:b}) to (B.east);
\end{tikzpicture}
    \caption{teams and costs}
    \label{MyTable}
    \vspace{-4mm}
\end{table} 
%%%%%%%%
\end{frame}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.