3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LaTeXのBeamerで吹き出しを出す

Last updated at Posted at 2021-10-19

LaTeXのBeamerでスライドに吹き出しを入れる方法。TikZのcalloutを使って吹き出しを作る。

20211019_180611.png

コード全体はGistに上げたものを参照のこと。

定義

プリアンブルに以下を書いておく。

\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}}

使う

吹き出しの先にしたいところに\COLabelで名前をつけておいて、実際の吹き出しは\COを使って作る。引数には吹き出しを出したい位置を書く。

\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}

参考にしたもの

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?