大家好。我使用 TexStudio 和 Texlive 以及 pdfLatex 编译器来完成这个项目。我希望通过 \pasue 将流程图分成 3 个部分,以便按某种顺序显示它们。
没有 \pause 的代码工作正常
\documentclass[t]{beamer}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{icomma}
\usepackage{array,tabularx,tabulary,booktabs}
\usepackage{tikz}
\begin{document}
\section{Test}
\subsection{Test pause}
\begin{frame}
\frametitle{\insertsection}
\framesubtitle{\insertsubsection}
\usetikzlibrary{shapes,shapes.multipart}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm
,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered,
draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered,
draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{tabular}{cl}
\begin{tabular}{c}
\scalebox{0.4}{
\begin{tikzpicture}[node distance=2cm, scale
=0.3]
\node (start) [startstop] {Начало};
\node (in1) [io, below of=start] {Ввод a,b};
\draw [arrow] (start) -- (in1);
\node (dec1) [decision, below of=in1, yshift
=-0.5cm] {a=b};
\node (dec2) [decision, below of=dec1, yshift
=-0.5cm] {a>b};
\node (pro2a) [process, left of=dec2, xshift
=-2cm, below of=dec2, yshift
=-0.5cm] {a:=a-b};
\node (pro2b) [process, right of=dec2, xshift
=2cm, below of=dec2, yshift
=-0.5cm] {b:=b-a};
\node (out1) [io, below of=dec2, yshift=-4cm] {Вывод a};
\node (stop) [startstop, below of=out1] {
Конец};
\draw [arrow] (in1) -- (dec1);
\path (in1) -- (dec1) coordinate[midway] (aux);;
\draw [arrow] (dec1) -- node[anchor=east] {
Нет} (dec2);
\draw [arrow] (dec2) -| node[anchor=south] {
Да} (pro2a);
\draw [arrow] (dec2) -| node[anchor=south] {
Нет} (pro2b);
\draw [arrow] (pro2b) |- ([xshift=-6.5cm, yshift=-1.5cm]pro2a.south) |- (aux);
\draw [arrow] (pro2a) |- ([xshift=-6.5cm, yshift=-1.5cm]pro2a.south) |- (aux);
\draw [arrow] (dec1.east) -| node[anchor=south] {
Да} ([xshift=6.5cm, yshift=-3.5cm]pro2b.south) -| (out1);
\draw [arrow] (out1) -- (stop);
\end{tikzpicture}
}
\end{tabular}
& \begin{tabular}{l}
\parbox{0.4\linewidth}{
\textbf{Flowchart of GCD} some text
}
\end{tabular} \\
\end{tabular}
\end{frame}
\end{document}
但是当我添加 \pause 时,\node (out1) [io, below of=dec2, yshift=-4cm] {Вывод a};
编译过程会因错误而退出。这是其中之一:软件包 pgfkeys 错误:我不知道您传递了“70”的键“/tikz/trapezium left angle”,我将忽略它。也许您拼错了。\end{frame}
答案1
看看这是否能帮助你:
\documentclass[t]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
positioning,
shapes.geometric}
\tikzset{FlowChart/.style={
base/.style = {draw, minimum width=18mm, minimum height=5mm,
align=center, font=\small},
startstop/.style = {base, rounded corners, fill=red!30},
process/.style = {base, fill=orange!30},
decision/.style = {base, diamond, aspect=2},
io/.style = {base, trapezium, trapezium stretches body,
trapezium left angle=70, trapezium right angle=110,
fill=blue!30,
text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
},
arr/.style = {semithick,-Triangle}
} }
\begin{document}
\section{Test}
\subsection{Test pause}
\begin{frame}[fragile]
\frametitle{\insertsection}
\framesubtitle{\insertsubsection}
\begin{tabular}{l p{0.3\linewidth}}
\begin{tikzpicture}[FlowChart, baseline=(current bounding box.center),
node distance = 5mm and 3mm,
start chain = going below,
chn/.style = {on chain, join=by arr},
lbl/.style = {font=\footnotesize}
]
\onslide+<1->
\node (start) [startstop,chn] {Start}; % Начало
\node (in1) [io,chn] {Input a,b}; % Ввод
\onslide+<2->
\node (dec1) [decision,chn] {$a=b$ ?};
\node (dec2) [decision,chn] {$a>b$ ?};
\path (dec1) -- node[lbl, right] {No} (dec2); % Нет
\onslide+<3->
\node (pro2a) [process, below left=of dec2] {$a\colon=a-b$};
\draw[arr] (dec2.west) node[lbl, above left] {Yes} -| (pro2a);% Дa
\onslide+<4->
\node (pro2b) [process, below right=of dec2] {$b\colon=b-a$};
\draw[arr] (dec2.east) node[lbl, above right] {No} -| (pro2b);% Нет
\onslide+<5->
\node (out1) [io, below=of dec2 |- pro2a.south] {Input a}; % Вывод
\node (stop) [startstop, below=of out1] {Stop}; % Конец
%
\coordinate[right=of pro2b] (aux);
\draw[arr] (dec1.east) node[lbl, above right] {Yes} % Дa
-| (aux) |- (out1);
\draw[arr] (out1) -- (stop);
\end{tikzpicture}
& \textbf{Flowchart of GCD} some text
\end{tabular}
\end{frame}
\end{document}
- 在上文中,使用 MWE
\onslide
代替\pause
。 - 对于样式,
Flowchart
使用定义样式tikzset
。 - 在绘制流程图时使用了 TikZ 库
chains
,可以简化图表代码 - 由于我没有俄语字体,所以我将俄语文本翻译成英语
- 第一张幻灯片:
- 最后一张幻灯片: