![如何在 Beamer 中插入图像代码](https://linux22.com/image/461114/%E5%A6%82%E4%BD%95%E5%9C%A8%20Beamer%20%E4%B8%AD%E6%8F%92%E5%85%A5%E5%9B%BE%E5%83%8F%E4%BB%A3%E7%A0%81.png)
我有一张包含以下代码的图片。但是当我尝试将该代码插入 Overleaf 中的 beamer 时,它根本无法编译。我认为缺少了一些命令。
有人能帮帮我吗?序言中应该添加什么?
\begin{figure}[htbp]
\centering
\usetikzlibrary{arrows}
\definecolor{qqqqff}{rgb}{0.,0.,1.}
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1.}
%\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
%\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1.}
\begin{tikzpicture}[scale=0.65][line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
%\clip(-3.52,-8.34) rectangle (26.66,8.32);
\fill[line width=2.pt,color=qqqqff,fill=qqqqff,fill opacity=0.0] (7.42,2.) -- (5.62,-0.6) -- (8.94,-0.68) -- cycle;
\fill[line width=2.pt,color=qqqqff,fill=qqqqff,fill opacity=0.0] (13.02,-0.68) -- (18.34,-0.78) -- (15.,1.6) -- cycle;
\draw [line width=1.pt,color=qqqqff] (7.42,2.)-- (5.62,-0.6);
\draw [line width=1.pt,color=qqqqff] (5.62,-0.6)-- (8.94,-0.68);
\draw [line width=1.pt,color=qqqqff] (8.94,-0.68)-- (7.42,2.);
\draw [line width=1.pt,,color=qqqqff] (7.58,4.18)-- (7.42,2.);
\draw [line width=1.pt,color=qqqqff] (13.02,-0.68)-- (18.34,-0.78);
\draw [line width=1.pt,color=qqqqff] (18.34,-0.78)-- (15.,1.6);
\draw [line width=1.pt,color=qqqqff] (15.,1.6)-- (13.02,-0.68);
\draw [line width=1.pt,,color=qqqqff] (15.,1.6)-- (16.5,4.2);
\begin{scriptsize}
\draw [fill=ududff] (7.42,2.) circle (3.5pt);
\draw[color=qqqqff] (6.2,1) node {\scalebox{1.5}{$\alpha$}};
\draw[color=qqqqff] (8.3,1) node {\scalebox{1.5}{$\gamma$}};
\draw[color=qqqqff] (7.2,-1.2) node {\scalebox{1.5}{$\beta$}};
\draw[color=qqqqff] (7.2,3.2) node {\scalebox{1.5}{$\delta$}};
\draw[color=qqqqff] (13.5,0.7) node {\scalebox{1.5}{$r\alpha$}};
\draw[color=qqqqff] (15.5,-1.2) node {\scalebox{1.5}{$r\beta$}};
\draw[color=qqqqff] (17,0.7) node {\scalebox{1.5}{$r\gamma$}};
\draw[color=qqqqff] (15.4,3.2) node {\scalebox{1.5}{$r\delta$}};
\draw[color=black] (8.1,2) node {\scalebox{1.5}{$x_3$}};
\draw [fill=ududff] (5.62,-0.6) circle (3.5pt);
\draw[color=black] (5.2,-1) node {\scalebox{1.5}{$x_1$}};
\draw [fill=ududff] (8.94,-0.68) circle (3.5pt);
\draw[color=black] (9.5,-0.88) node {\scalebox{1.5}{$x_2$}};
\draw [fill=ududff] (7.58,4.18) circle (3.5pt);
\draw[color=black] (8.3,4.2) node {\scalebox{1.5}{$x_4$}};
\draw [fill=ududff] (13.02,-0.68) circle (3.5pt);
\draw[color=black] (12.6,-1) node {\scalebox{1.5}{$y_1$}};
\draw [fill=ududff] (18.34,-0.78) circle (3.5pt);
\draw[color=black] (19,-1) node {\scalebox{1.5}{$y_2$}};
\draw [fill=ududff] (15.,1.6) circle (3.5pt);
\draw[color=black] (14.4,1.7) node {\scalebox{1.5}{$y_3$}};
\draw [fill=ududff] (16.5,4.2) circle (3.5pt);
\draw[color=black] (17.1,4.2) node {\scalebox{1.5}{$y_4$}};
\end{scriptsize}
\end{tikzpicture}
\label{trianglewithanedgeanditsdilatedcopy}
\caption{The graph $G$ and its dilated copy $rG$.}
\label{xxx}
\end{figure}
\end{frame}
答案1
使您的代码可编译的最少代码是:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
% Paste your code here
\end{document}
此外,关于显示的代码:
图形环境对于 来说是一个奇怪的地方
\usetikzlibrary{arrows}
。最好将其放在序言中,因为这样库可供所有文档使用。注意你的代码有一个帧结束,而没有我上面添加的帧开始。如果管理代码块而不注意不破坏任何环境,那将是自找麻烦。
图形选项 (
[htbp]
) 没有意义。实际上,figure
环境在 Beamer 中不是浮点数。完全
\centering
不需要。如果您只\begin{figure} x \end{figure}
在 Beamer 演示文稿中添加,则“x”无论如何都会居中。