Skip to content

Instantly share code, notes, and snippets.

@ushitora-anqou
Last active October 19, 2021 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ushitora-anqou/8fead2368df9d45f0409ebe6541b4559 to your computer and use it in GitHub Desktop.
Save ushitora-anqou/8fead2368df9d45f0409ebe6541b4559 to your computer and use it in GitHub Desktop.
LaTeX Beamer callouts
\documentclass[dvipdfmx]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts,tikzmark,calc}
% Usage: \COLabel{name#1}{text#2}
% e.g.: \COLabel{psi1}{$\psi_1$}
\newcommand{\COLabel}[2]{%
\tikz[%
remember picture,%
baseline=(#1.base),%
every node/.style={inner sep=0,outer sep=0}%
]{%
\node (#1){#2};%
}}
% Usage: \CO<page#1>{target name#2}{++(x,y)#3}[opt#4]{text#5}
% e.g.: \CO<2>{psi1}{++(-4,1.5)}[text width=3cm]{hogehoge fugafuga piyopiyo}
\NewDocumentCommand\CO{d<> m m O{} m}{%
\begin{tikzpicture}[remember picture, overlay]
\IfValueTF{#1}{\path<#1>}{\path} (#2.center) #3 node[%
anchor=center,%
rectangle callout,%
fill=red!50,%
callout absolute pointer={(#2.mid)},%
font=\bfseries\footnotesize,
rounded corners,
#4
]{#5};
\end{tikzpicture}}
\begin{document}
\begin{frame}\frametitle{}
\begin{center}
\COLabel{hogel}{}\COLabel{hoge}{ほげほげ}\COLabel{hoger}{}
\end{center}
\CO{hogel}{++(-1,-1)}{left}
\CO{hoge}{++(0,-1)}{middle}
\CO{hoger}{++(1,-1)}{right}
\end{frame}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment