TeX - LaTeX Asked on January 3, 2021
I have a beamer slide where I want to show the meaning of a variable by adding a box with an arrow to the variable. Here is my failed attempt:
documentclass{beamer}
usetheme{default}
beamertemplatenavigationsymbolsempty
usepackage[skins]{tcolorbox}
usepackage{tikz}
usetikzlibrary{arrows,shapes}
newtcolorbox{myexample}[0]{%
text width=2cm, text height=0.1cm, enhanced,colback=green,colframe=black, coltitle=black,boxrule=0.8mm, tikz={rotate=90,transform shape}
}
begin{document}
begin{frame}
Therefore
only<1>{
$Pr(A, B)$
}
only<2>{
$Pr(tikz{
node[fill=blue!20,,ellipse, anchor=base] (t1)
{A, B};
})$
}
$=0$
only<2>{
begin{myexample}
${scriptstyle 0,1,2,3,4,4,5,6,7,8,9}$
end{myexample}
}
end{frame}
end{document}
How can I:
text height = 0.1cm
can’t be right either but it was the only way I could make the box smaller and it still isn’t quite small enough.Sorry for the large number of quesions.
Ultimately I would like to use it in this beamer slide:
documentclass{beamer}
usetheme{default}
beamertemplatenavigationsymbolsempty
setbeamertemplate{frametitle}[default][center]
usepackage[skins]{tcolorbox}
newtcolorbox{myexample}[2][]{%
text width=textwidth-1cm, text height=2.5cm, enhanced,colback=white,colframe=black, coltitle=black,
sharp corners,boxrule=0.8mm,
attach boxed title to top left={yshift=-0.3baselineskip-0.4pt,xshift=2mm},
boxed title style={tile,size=minimal,left=0.5mm,right=0.5mm,
colback=white,before upper=strut},
title=#2,#1
}
begin{document}
begin{frame}{}
begin{myexample}[text height=3cm]{}
Suppose you pick a uniformly random integer from ${1, dots, 100}$. If $A$ is the event that the last digit is a $3$ then $Pr(A) = 1/10$. If $B$ is the event that the number is prime then $Pr(B) = 1/4$.
[
Pr(A mid B) = frac{Pr(A, B)}{Pr(B)} = frac{7/100}{1/4} = frac{28}{100}
]
end{myexample}
end{frame}
end{document}
With tikz
and tikzmark
library:
documentclass{beamer}
usetheme{default}
beamertemplatenavigationsymbolsempty
usepackage{tikz}
usetikzlibrary{arrows.meta,
shapes,
tikzmark}
begin{document}
begin{frame}
tikzset{baseline,
E/.style={ellipse, fill=gray!30, inner sep=2pt, anchor=base},
N/.style={draw=green!60!black, very thick, rounded corners, fill=green!30,
font=scriptsize, rotate=90, anchor=east}
}
rule[-2ex]{0pt}{5ex} % <--- approximation of the equation height
Therefore
only<1>{
$Pr(A, B)$
}% <---
only<2>{
$Pr(tikz[baseline]node[E] {subnode{a}{A, B}};) =0$
% <---
begin{tikzpicture}[remember picture, overlay]
node (b) [N]
at (current page.center)
{0,1,2,3,4,4,5,6,7,8,9};
draw[-Stealth, shorten <=1mm, shorten >=1mm]
(a) to [bend right] (b.north);
end{tikzpicture}
}
end{frame}
end{document}
Note: For above result you need to compile MWE (at least) twice.
Edit: A wee bit improved code. Now the vertical position of equation is the same on the both slides.
Correct answer by Zarko on January 3, 2021
One simple approach to get what you may want with tikZ:
begin{frame}
begin{tikzpicture}
only<1,2>{%
node [minimum height=20pt] (T1) at (0,0) {Therefore $Pr($};
node [minimum height=20pt] (T2) at (1.6,0) {$A, B$};
node [minimum height=20pt] (T3) at (2.5,0) {$)= 0$};
}
only<2>{%
node [%
fill=green,
draw,
rounded corners=5pt,
rotate=90,
anchor=east,
text height=11pt
]
(X) at (0.25,-0.75) {0,1,2,3,4,5,6,7,8,9};
draw [->, thick, blue] (X.south) to [in=-90, out=0] (T2.south);
node [%
minimum height=20pt,
ellipse,
x radius=0.5,
y radius=1,
fill=blue!20!white,
inner sep=0
]
(T2) at (1.6,0) {$A, B$};
}
end{tikzpicture}
end{frame}
Answered by Harald Lichtenstein on January 3, 2021
Simply with pst-node
:
documentclass[svgnames]{beamer}
usetheme{default}
beamertemplatenavigationsymbolsempty
usepackage{pst-node}
begin{document}
begin{frame}
Therefore
only<1>{
$Pr(A, B)$
}
only<2>{
$Prbigl(!ovalnode[linestyle=none, fillstyle=solid, fillcolor=blue!20,] {E}{A, B}!bigr)$
}
$=0$
only<2>{%
rotatebox[origin=lB]{90}{
$scriptstyle pnode{A}0,1,2,3,4,rnode{R}{4},5,6,7,8,9pnode{B}ncbox[fillstyle=solid, fillcolor=SeaGreen!65, linearc=0.1, boxsize=1.5ex, nodesep=2pt]{A}{B}
rput[l](A){scriptstyle 0, 1,2,3,4,4,5,6,7,8,9}$
}
}
nccurve[arrows=->, arrowinset=0.12, nodesepA=1.5ex, angleB=-150]{R}{E}
end{frame}
end{document}
Answered by Bernard on January 3, 2021
Like this ?
I commented the code with %<--
to explain the changes.
documentclass{beamer}
usetheme{default}
beamertemplatenavigationsymbolsempty
usepackage[skins]{tcolorbox}
usepackage{tikz}
usetikzlibrary{arrows,shapes,positioning}
newtcolorbox{myexample}[0]{%
width=4.5cm,%<-- width of the tcbox
halign=center,%<-- align of text
text height=0.1cm,enhanced,colback=green,colframe=black,
% coltitle=black, <-- useless option
boxrule=0.8mm, tikz={rotate=90,transform shape}}
begin{document}
begin{frame}
begin{overlayarea}{0.9textwidth}{0.4textheight}% <- reserved area of the tikzpicture
Therefore;begin{tikzpicture}[baseline]
node [anchor=base] (t1){ $Pr(A,B)=0$};%<- the node is around math text
fill<2>[blue!40,fill opacity=.5%<-- the ellipse is build over the node with fill opacity=.5
] ([shift={(-4pt,.7pt)}]t1)% <- shift to center the ellipse on the node
circle[x radius=4mm,y radius=2.2mm];
node<2>[below right= 5 mm and 5mm of t1] %<-- with positioning library second node is relative of first node
(t2){
begin{myexample}
${scriptstyle 0,1,2,3,4,4,5,6,7,8,9}$
end{myexample}
} edge[->,out=180,in=-70,very thick] (t1.south);%<-- arrow from tcbox to text
end{tikzpicture}
end{overlayarea}
end{frame}
end{document}
Answered by AndréC on January 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP