Table markers with tikz in Beamer presentation
Author
IAJ
Last Updated
há 5 anos
License
Creative Commons CC BY 4.0
Abstract
This is a basic example of how to use tikz to add markers to a table that vary across the different sliedes of a frame.
This is a basic example of how to use tikz to add markers to a table that vary across the different sliedes of a frame.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,fit,tikzmark,calc}
\makeatletter
% Foliennummern einfügen (frames nummeriert, nicht slides)
% Insert page numbers (frames numbered, not slides)
\setbeamertemplate{footline}{%
\hfill
\insertframenumber{}/
\inserttotalframenumber
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
% Idee gefunden unter:
% Idea found at:
% https://tex.stackexchange.com/a/265821
% Markierungen hinzufügen
% Add markers
\addtobeamertemplate{background}{}{\tikzmarkhookinbeamerbackground}
\def\tikzmarkhookinbeamerbackground{}
\def\tikzbackgroundpath#1;{
\gdef\tikzmarkhookinbeamerbackground{
\gdef\tikzmarkhookinbeamerbackground{}
\tikz[remember picture,overlay]\path#1;
}
}
\tikzset{
every picture/.style={remember picture,baseline},
every node/.style={anchor=base,align=center,outer sep=1.5pt},
every path/.style={thick},
}
\begin{frame}
\frametitle{Table markers with tikz}
% Tabelle mit Positionen für Markierungen
% Table with positions for markers
\begin{table}[]
\begin{tabular}{c c c c}
A & B & C & D \\
\hline
\tikzmark{a11}16 & \tikzmark{a12}3 & \tikzmark{a13}2 & \tikzmark{a14}13 \\
\tikzmark{a21}5 & \tikzmark{a22}10 & \tikzmark{a23}11 & \tikzmark{a24}8 \\
\tikzmark{a31}9 & \tikzmark{a32}6 & \tikzmark{a33}7 & \tikzmark{a34}12 \\
\tikzmark{a41}4 & \tikzmark{a42}15 & \tikzmark{a43}14 & \tikzmark{a44}1
\end{tabular}
\end{table}
% Markierungen der einzelnen slides
% Markings on individual slides
\only<1>{
\tikzbackgroundpath
node at ([yshift=-60]current page.center){no markers here};
}
\only<5>{
\tikzbackgroundpath
node at ([yshift=-60]current page.center){no markers here};
}
% slide 2 oberes linkes Viertel
% slide 2 upper left quarter
\only<2>{
\tikzbackgroundpath
node[rounded corners,line width=1,draw,fill=yellow!20,fit={([yshift=6]pic cs:a11)([xshift=11]pic cs:a22)}]{}
node at ([yshift=-60]current page.center){upper left quarter};
}
% slide 3 erste Zeile, erste Spalte
% slide 3 first row, first column
\only<3>{
\tikzbackgroundpath
node[rounded corners,line width=1,draw,fill=green!20,fit={([yshift=6]pic cs:a11)([xshift=11]pic cs:a11)}]{}
node at ([yshift=-60]current page.center){first row, first column};
}
% slide 4 bunte Kreise hinter einzelnen Elementen
% slide 4 colored circles behind individual elements
\only<4>{
\tikzbackgroundpath
node[circle,
line width=1,
%draw,
fill=red!20,
fit={([yshift=4,xshift=5.5]pic cs:a11)},
minimum size=0.5cm]{}
node[circle,
line width=1,
%draw,
fill=blue!20,
fit={([yshift=4,xshift=6]pic cs:a22)},
minimum size=0.5cm]{}
node at ([yshift=-60]current page.center){colored circles behind individual elements};
}
% slide 6 unteres rechtes Viertel
% slide 6 lower right quarter
\only<6>{
\tikzbackgroundpath
node[rounded corners,line width=1,draw,fill=violet!20,fit={([yshift=6]pic cs:a33)([xshift=6]pic cs:a44)}]{}
node at ([yshift=-60]current page.center){lower right quarter};
}
\end{frame}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\end{document}