以下问题可能看起来很像是重复的,但不幸的是我自己无法弄清楚:
在以下 MWE 中,我尝试将自动机放在右上角。我非常怀疑插入节点并使用“记住”和“覆盖”是否可行,但不幸的是,我仍然缺少正确的组合来使其工作。
有谁能帮我解决这个问题?提前谢谢了!
梅威瑟:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,automata, positioning}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{setspace}
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\begin{document}
\begin{frame}[t]{Minimal consistent automata ($ |\Sigma| \geq 2 $)}
\begin{block}{}
The plan: \textbullet construction of a sample which provokes $ \geq 3 $ states
\end{block}
% \begin{tikzpicture}[remember picture,overlay]
% \node[opacity=1,xshift=5.5cm,yshift=3cm,at=(current page.center)] {
\begin{tikzpicture}
[scale = 0.4, transform shape,
-> , >= stealth,
shorten >=0pt ,
node distance =2.5 cm ,
initial text = ,
semithick ]
\node[state, initial] (q1) {$ \varepsilon $};
\node[state, accepting] (q2) [right = 2cm of q1]{$ 0 $};
\path[->]
(q1) edge [below] node {0} (q2)
(q1) edge [loop above] node {1} (q1)
(q2) edge [loop above] node {1} (q2)
(q2) edge [bend right = 15, above] node {0} (q1)
;
% };
\end{tikzpicture}
\end{frame}
\end{document}
答案1
将您的图形插入位于右上角的节点中。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,automata, positioning}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{setspace}
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\begin{document}
\begin{frame}[t]{Minimal consistent automata ($ |\Sigma| \geq 2 $)}
\begin{block}{}
The plan: \textbullet construction of a sample which provokes $ \geq 3 $ states
\end{block}
\begin{tikzpicture}[remember picture, overlay]
\node [anchor=north east, inner sep=0pt, xshift=-10pt,yshift=-5pt] at (current page.north east){%
\begin{tikzpicture}
[scale = 0.4, transform shape,
-> , >= stealth,
shorten >=0pt ,
node distance =2.5 cm ,
initial text = ,
semithick ]
\node[state, initial] (q1) {$ \varepsilon $};
\node[state, accepting] (q2) [right = 2cm of q1]{$ 0 $};
\path[->]
(q1) edge [below] node {0} (q2)
(q1) edge [loop above] node {1} (q1)
(q2) edge [loop above] node {1} (q2)
(q2) edge [bend right = 15, above] node {0} (q1);
\end{tikzpicture}
};
\end{tikzpicture}
\end{frame}
\end{document}
答案2
\documentclass{beamer}
\setbeamertemplate{itemize item}[ball]
\usepackage{tikz}
\usetikzlibrary{arrows.meta,automata,
positioning,
quotes}
\begin{document}
\begin{frame}[t]{Minimal consistent automata ($ |\Sigma| \geq 2 $)}
\begin{columns}
\begin{column}{.65\textwidth}
The plan:
\begin{itemize}
\item construction of a sample which provokes $ \geq 3 $ states
\end{itemize}
\end{column}
\begin{column}{.3\textwidth}
\centering
\begin{tikzpicture}[auto, scale = 0.5, transform shape,
node distance=22mm,
initial text = ,
semithick,
every edge/.style = {draw, -Stealth, shorten >=1pt}
]
\node[state, initial] (q1) {$ \varepsilon $};
\node[state, accepting,
right=of q1] (q2) {$0$};
%
\path (q1) edge[loop above, "1"] ()
edge["0"] (q2)
(q2) edge [loop above, "1"] ()
edge [bend right,"0" '] (q1);
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\end{document}
或者
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,automata,
positioning,
quotes}
\begin{document}
\begin{frame}[t]{Minimal consistent automata ($ |\Sigma| \geq 2 $)
\hfill\begin{tikzpicture}[baseline,
auto, scale = 0.4, transform shape,
node distance=22mm,
initial text = ,
semithick,
color=black,
every edge/.style = {draw, -Stealth, shorten >=1pt}
]
\node[state, initial] (q1) {$ \varepsilon $};
\node[state, accepting,
right=of q1] (q2) {$0$};
%
\path (q1) edge[loop above, "1"] ()
edge["0"] (q2)
(q2) edge [loop above, "1"] ()
edge [bend right,"0" '] (q1);
\end{tikzpicture}
}
The plan:
\begin{itemize}
\item construction of a sample which provokes $ \geq 3 $ states
\end{itemize}
\end{frame}
\end{document}
答案3
我不确定这是否正是您想要的,但您可以使用绝对定位,如TikZ/PGf 手册针对 v1.8,第 13.2.2 节,第 134 页。
我认为最简单的方法是先将节点 q2 相对于页面的右上角放置,因为它更靠近那个角落,然后将 q1 放在它的左边,而不是将 q2 放在 q1 的右边。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,automata, positioning}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{setspace}
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\begin{document}
\begin{frame}[t]{Minimal consistent automata ($ |\Sigma| \geq 2 $)}
\begin{block}{}
The plan: \textbullet\ construction of a sample which provokes $ \geq 3 $ states
\end{block}
\hfill\begin{tikzpicture}[remember picture, overlay,
scale = 0.4, transform shape,
-> , >= stealth,
shorten >=0pt ,
node distance =2.5 cm ,
initial text = ,
semithick ]
\node[state, accepting] (q2) [ below left = 3cm of current page.north east ] {$ 0 $};
\node[state, initial] (q1) [left = 2cm of q2] {$ \varepsilon $};
\path[->]
(q1) edge [below] node {0} (q2)
(q1) edge [loop above] node {1} (q1)
(q2) edge [loop above] node {1} (q2)
(q2) edge [bend right = 15, above] node {0} (q1)
;
% };
\end{tikzpicture}
\end{frame}
\end{document}
当然,您可以随意选择您想要的位置。