我想要这个TikZ
小圆圈内的图像.jpg
或.png
从我的工作目录附加的图像文件将位于此处。
我还希望TikZ
动画首先child
显示第一个,然后是第二个,然后是第三个,最后是第四个。
这是我尝试过的:
\documentclass[compress]{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\begin{frame}
\frametitle{Test with Infographics}
\end{tikzpicture}
\end{tikzpicture}
\end{frame}
\end{document}
答案1
下面是一个简单的草图。它使用style
命名figNode/.style
在节点内插入图像,这样您就可以控制外边框如何与图形交互,它还使用一些foreach
循环来编写一些更紧凑的语法。其他元素只是放置在某个地方以类似于您的原始概念。
它还需要一些改进:
- 阴影,
- 更好的定位,
- 更换中心半圆与四个元素块之间的连接,以及
- 带有元素的矩形形式。
以下 MWE 只是一个起点。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc}
\tikzset{
figNode/.style={
path picture={
\node at (path picture bounding box.center) {#1};}}
}
\begin{document}
\begin{tikzpicture}[very thick]
\node (a) at (60:10){};
\node (b) at (20:10){};
\node (c) at (-20:10){};
\node (d) at (-60:10){};
\foreach \r/\c in {90/blue,45/green,0/red,-45/yellow}{
\fill[\c!50] (0,0) -- (\r:4) arc (\r:\r-45:4) -- cycle;
};
\foreach \r/\c/\p in {67.5/blue/a,22.5/green/b,-22.5/red/c,-67.5/yellow/d}{
\draw[\c] (\r:4) -- (\p);
\fill[gray!50] (\r:4) circle (0.5);
\fill[\c] (\r:4) circle (0.25);
};
\draw[fill=white] (0,0) circle (3) node[align=center]{Business \\ infographic};
\draw[rounded corners=25pt, fill=gray!50] (3.5,7) rectangle ++(7,3.5);
\draw[fill=blue!50, figNode={\includegraphics[width=0.2\textwidth]{example-image-a}}]
(a) circle (1);
\node[right=2 of a, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=blue!50,
minimum height=2cm, minimum width=3cm] {Elemento 01};
\draw[rounded corners=25pt, fill=gray!50] (7.8,1.6) rectangle ++(7,3.5);
\draw[fill=green!50, figNode={\includegraphics[width=0.2\textwidth]{example-image-b}}]
(b) circle (1);
\node[right=2 of b, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=green!50,
minimum height=2cm, minimum width=3cm] {Elemento 02};
\draw[rounded corners=25pt, fill=gray!50] (8,-5) rectangle ++(7,3.5);
\draw[fill=red!50, figNode={\includegraphics[width=0.2\textwidth]{example-image-c}}]
(c) circle (1);
\node[right=2 of c, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=red!50,
minimum height=2cm, minimum width=3cm] {Elemento 03};
\draw[rounded corners=25pt, fill=gray!50] (3.2,-10.4) rectangle ++(7,3.5);
\draw[fill=yellow!50, figNode={\includegraphics[width=0.2\textwidth]{example-image-duck}}]
(d) circle (1);
\node[right=2 of d, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=yellow!50,
minimum height=2cm, minimum width=3cm] {Elemento 04};
\end{tikzpicture}
\end{document}
更新和动画
前段时间我问了一个问题在 TikZ 中一步步制作状态空间图动画的最佳方法。
现在我可以为原始问题提供新的解决方案。我现在可以展示如何创建嵌入 PDF 的动画。
该命令\uncover
由@AlexG 提供,是该技术发挥作用的关键。
接下来是 MWE 和 gif
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage[autoplay,controls,loop]{animate}
\usetikzlibrary{positioning,shapes.misc}
\tikzset{
figNode/.style={
path picture={
\node at (path picture bounding box.center) {#1};}}
}
% ==== Command used to uncover frames to provide an animated result
\newcommand\uncover[3]{\ifnum#1<#2\phantom{#3}\else#3\fi}
% ====
\begin{document}
\begin{animateinline}[controls,loop,poster=last,begin={
\begin{tikzpicture}[scale=1,very thick]
\useasboundingbox (-3.5,-10.5) rectangle (16,10.5);
},
end={\end{tikzpicture}}
]{2}
\multiframe{14}{i=0+1}{
\node (a) at (60:10){};
\node (b) at (20:10){};
\node (c) at (-20:10){};
\node (d) at (-60:10){};
\foreach \r/\c/\q in {90/blue/2,45/green/5,0/red/8,-45/yellow/11}{
\uncover{\i}{\q}{
\fill[\c!50] (0,0) -- (\r:4) arc (\r:\r-45:4) -- cycle;
}
};
\foreach \r/\c/\p/\q in {67.5/blue/a/3,22.5/green/b/6,-22.5/red/c/9,-67.5/yellow/d/12}{
\uncover{\i}{\q}{
\draw[\c] (\r:4) -- (\p);
\fill[gray!50] (\r:4) circle (0.5);
\fill[\c] (\r:4) circle (0.25);
}
};
\uncover{\i}{1}{\draw[fill=white] (0,0) circle (3) node[align=center]{Business \\ infographic};}
\uncover{\i}{4}{
\draw[rounded corners=25pt, fill=gray!50] (3.5,7) rectangle ++(7,3.5);
\draw[fill=blue!50, figNode={\includegraphics[width=0.1\textwidth]{example-image-a}}] (a) circle (1);
\node[right=2 of a, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=blue!50,
minimum height=2cm, minimum width=3cm] {Elemento 01};
}
\uncover{\i}{7}{
\draw[rounded corners=25pt, fill=gray!50] (7.8,1.6) rectangle ++(7,3.5);
\draw[fill=green!50, figNode={\includegraphics[width=0.1\textwidth]{example-image-b}}] (b) circle (1);
\node[right=2 of b, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=green!50,
minimum height=2cm, minimum width=3cm] {Elemento 02};
}
\uncover{\i}{10}{
\draw[rounded corners=25pt, fill=gray!50] (8,-5) rectangle ++(7,3.5);
\draw[fill=red!50, figNode={\includegraphics[width=0.1\textwidth]{example-image-c}}] (c) circle (1);
\node[right=2 of c, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=red!50,
minimum height=2cm, minimum width=3cm] {Elemento 03};
}
\uncover{\i}{13}{
\draw[rounded corners=25pt, fill=gray!50] (3.2,-10.4) rectangle ++(7,3.5);
\draw[fill=yellow!50, figNode={\includegraphics[width=0.1\textwidth]{example-image-duck}}] (d) circle (1);
\node[right=2 of d, rounded rectangle=25pt, rounded rectangle west arc=none, draw, fill=yellow!50,
minimum height=2cm, minimum width=3cm] {Elemento 04};
}
}
\end{animateinline}
\end{document}