我正在使用 beamer 撰写论文答辩演示文稿。我的工作代码如下:
%----------------------------------------------------------------------------------------
% PACKAGES AND THEMES
%----------------------------------------------------------------------------------------
\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\usetheme{Simple}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet,tikz,tikz-cd,pgf,makecell,smartdiagram,lmodern,ragged2e,array,caption,graphicx,booktabs,tabularx,subfig,xcolor,csquotes,epigraph,amsmath}
\usetikzlibrary{arrows,backgrounds,fit,positioning,quotes,shapes}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\setlength\extrarowheight{2pt}
\captionsetup[figure]{labelformat=empty}
%\citationstyle{dcu}
%% Fix Vertical Alignment
\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}
% Add \hspace to arrow definition
\newcommand\bigleftArrow{\hspace{40pt}\color{green}\rotatebox[origin=c]{180}{\scalebox{2.4}[3.6]{\ding{225}}}}
\newcommand\bigrightArrow{\hspace{40pt}\color{green}\rotatebox[origin=c]{0}{\scalebox{2.4}[3.6]{\ding{225}}}}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usetikzlibrary{arrows, matrix, positioning, shapes, shapes.geometric, calc, intersections, decorations.pathreplacing,mindmap,trees}
\newcommand{\tikznode}[2]{\relax
\ifmmode%
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
\else
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
% The title
\title[short title]{Simple Beamer Theme}
\subtitle{Subtitle}
\author[Pin-Yen] {Pin-Yen Huang}
\institute[NTU] % Your institution may be shorthand to save space
{
% Your institution for the title page
Department of Computer Science and Information Engineering \\
National Taiwan University
\vskip 3pt
}
\date{\today} % Date, can be changed to a custom date
%----------------------------------------------------------------------------------------
% PRESENTATION SLIDES
%----------------------------------------------------------------------------------------
\begin{document}
\begin{frame}
\frametitle{Introduction}
\framesubtitle{Background and motivation}
\tikzstyle{block} = [rectangle, rounded corners, align=center, fill={rgb:orange,1;yellow,2;pink,5}, text width=2.2cm]
\tikzstyle{block1} = [draw, rectangle, rounded corners, align=center, fill=orange!40, text width=2.5cm]
\tikzstyle{block3} = [circle, draw, fill={rgb:orange,1;yellow,2;pink,5},
text width=1cm, text centered, inner sep=0pt, minimum size=0.2pt]
\begin{figure}[!h]
\centering
\resizebox{10cm}{6.5cm}{
\begin{tikzpicture}[thick]
%automaton
\node [block] (automaton) {\textbf{Automaton}};
\node [block1, below=of automaton, xshift=-0.5cm] (automaton2) {Automaton 2};
\node [block1, left=of automaton2, xshift=0.7cm] (automaton1) {Automaton 2};
\node [right=of automaton2, xshift=-0.9cm] (automaton3) {$\cdots$};
\node [block1, right=of automaton3, xshift=-0.9cm] (automaton4) {Automaton $n$};
%semigroup
\node [block, right=of automaton, yshift=0.5cm, xshift=5cm] (semigroup) {\textbf{Semigroup}};
\node[block1, below=of semigroup, xshift=-1.5cm] (semi1) {Group};
\node[block1, right=of semi1, xshift=-0.5cm] (semi2) {Monoid};
\node[block1, below=of semi1] (semi3) {Semigroup};
\node[block1, below=of semi2] (semi4) {Semigroup};
%primes
\node[block, below=of automaton, yshift=-3.5cm, xshift=4cm] (positive) {\textbf{Positive integers}};
\node[block3, below=of positive, xshift=0.5cm] (p3) {$p_3$};
\node[block3, left=of p3, xshift=0.5cm] (p2) {$p_2$};
\node[block3, left=of p2, xshift=0.5cm] (p1) {$p_1$};
\node[right=of p3, xshift=-0.7cm] (dots) {$\cdots$};
\node[block3, right=of dots, xshift=-0.7cm] (pn) {$p_n$};
%lines
\draw [line width=0.5pt] (automaton.south) -- (automaton1.north);
\draw [line width=0.5pt] (automaton.south) -- (automaton2.north);
\draw [line width=0.5pt] (automaton.south) -- (automaton4.north);
\draw [line width=0.5pt] (semigroup.south) -- (semi1.north);
\draw [line width=0.5pt] (semigroup.south) -- (semi2.north);
\draw [line width=0.5pt] (semi1.south) -- (semi3.north);
\draw [line width=0.5pt] (semi2.south) -- (semi4.north);
\draw [line width=0.5pt] (positive.south) -- (p1.north);
\draw [line width=0.5pt] (positive.south) -- (p2.north);
\draw [line width=0.5pt] (positive.south) -- (p3.north);
\draw [line width=0.5pt] (positive.south) -- (pn.north);
\end{tikzpicture}
}
\end{figure}
\end{frame}
\begin{frame}{References}
% Beamer does not support BibTeX so references must be inserted manually as below
\footnotesize{
\begin{thebibliography}{99}
\bibitem[Smith, 2012]{p1} John Smith (2012)
\newblock Title of the publication
\newblock \emph{Journal Name} 12(3), 45 -- 678.
\end{thebibliography}
}
\end{frame}
%------------------------------------------------
\begin{frame}
\Huge{\centerline{The End}}
\end{frame}
%----------------------------------------------------------------------------------------
\end{document}
生成如下图所示的图表:
我怎样才能为如下图形添加边框:
请帮忙。
答案1
这里有一些内容,使用calc
和fit
库。我删除了所有无用的东西,只保留了 tikzpicture,但它应该可以在您的 beamer 演示文稿中毫无问题地工作。
\documentclass[border=3.14mm]{standalone}
\usepackage{helvet,tikz}
\usetikzlibrary{calc,arrows,backgrounds,fit,positioning,quotes,shapes}
%----------------------------------------------------------------------------------------
% PRESENTATION SLIDES
%----------------------------------------------------------------------------------------
\begin{document}
\sffamily
\tikzstyle{block} = [rectangle, rounded corners, align=center, fill={rgb:orange,1;yellow,2;pink,5}, text width=2.2cm]
\tikzstyle{block1} = [draw, rectangle, rounded corners, align=center, fill=orange!40, text width=2.5cm]
\tikzstyle{block3} = [circle, draw, fill={rgb:orange,1;yellow,2;pink,5},
text width=1cm, text centered, inner sep=0pt, minimum size=0.2pt]
\resizebox{10cm}{6.5cm}{
\begin{tikzpicture}[thick]
%automaton
\node [block] (automaton) {\textbf{Automaton}};
\node [block1, below=of automaton, xshift=-0.5cm] (automaton2) {Automaton 2};
\node [block1, left=of automaton2, xshift=0.7cm] (automaton1) {Automaton 1};
\node [right=of automaton2, xshift=-0.9cm] (automaton3) {$\cdots$};
\node [block1, right=of automaton3, xshift=-0.9cm] (automaton4) {Automaton $n$};
%semigroup
\node [block, right=of automaton, yshift=0.5cm, xshift=5cm] (semigroup) {\textbf{Semigroup}};
\node[block1, below=of semigroup, xshift=-1.5cm] (semi1) {Group};
\node[block1, right=of semi1, xshift=-0.5cm] (semi2) {Monoid};
\node[block1, below=of semi1] (semi3) {Semigroup};
\node[block1, below=of semi2] (semi4) {Semigroup};
%primes
\node[block, below=of automaton, yshift=-3.5cm, xshift=4cm] (positive) {\textbf{Positive integers}};
\node[block3, below=of positive, xshift=0.5cm] (p3) {$p_3$};
\node[block3, left=of p3, xshift=0.5cm] (p2) {$p_2$};
\node[block3, left=of p2, xshift=0.5cm] (p1) {$p_1$};
\node[right=of p3, xshift=-0.7cm] (dots) {$\cdots$};
\node[block3, right=of dots, xshift=-0.7cm] (pn) {$p_n$};
%lines
\draw [line width=0.5pt] (automaton.south) -- (automaton1.north);
\draw [line width=0.5pt] (automaton.south) -- (automaton2.north);
\draw [line width=0.5pt] (automaton.south) -- (automaton4.north);
\draw [line width=0.5pt] (semigroup.south) -- (semi1.north);
\draw [line width=0.5pt] (semigroup.south) -- (semi2.north);
\draw [line width=0.5pt] (semi1.south) -- (semi3.north);
\draw [line width=0.5pt] (semi2.south) -- (semi4.north);
\draw [line width=0.5pt] (positive.south) -- (p1.north);
\draw [line width=0.5pt] (positive.south) -- (p2.north);
\draw [line width=0.5pt] (positive.south) -- (p3.north);
\draw [line width=0.5pt] (positive.south) -- (pn.north);
\node[fit=(automaton)(automaton1)(automaton4),inner sep=10pt](automat){};
\node[fit=(semigroup)(semi3)(semi4),inner sep=10pt](semi){};
\node[fit=(positive)(p1)(pn),inner sep=10pt](p){};
\draw[violet] (semi.north east) |- (p.south east) -| (automat.south west) |- (semi.north east)
($(semi.north west)!.5!(semi.north west-|automat.north east)$) |- ($(semi.south east)!.5!(semi.south east |- p.north east)$) -| (automat.north west);
\end{tikzpicture}
}
%----------------------------------------------------------------------------------------
\end{document}