Beamer 中的图表

Beamer 中的图表

我正在使用 beamer,我需要创建一个带有图表的幻灯片。我尝试创建它,但我的代码有问题:

\begin{frame}
 \begin{block} {Undirected graph 
}  

A graph  G=(V,E)  with a set of vertex V=$\left \{ v_{1},v_{2}, ... ,v_{n} \right \}$ and a set of edge (arc) E=$\left \{ e_{1},e_{2}, ... ,e_{m} \right \}$ is called undirected graph or (digraph) if each edge e$_{k}$ is an unorder pair (v$_{i}$,v$_{j}$).
\newline
\begin{tikzpicture}
\matrix[column sep=3em, row sep=8ex, inner sep=0pt, minimum width=6pt] (M) {%
    \node[mypoint, label={[left,xshift=-4pt]v$_{1}$}] (V1){}; & & &\node[mypoint, label={right:v$_{2}$}] (V2) {};\\};
\draw(V2)--(V1);
\end{tikzpicture} 
 \end{block} 

\end{frame}

在此处输入图片描述

我们可以从图上看到顶点连接并不完美。

答案1

您需要使用 告诉 beamer 此框架包含易碎命令\begin{frame}[fragile]

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}[fragile]
    \begin{block}{Undirected graph}  
        A graph  $G=(V,E)$ with a set of vertex $V=\left \{ v_{1},v_{2}, ... ,v_{n} \right \}$ and a set of edge (arc) $E=\left \{ e_{1},e_{2}, ... ,e_{m} \right \}$ is called undirected graph or (digraph) if each edge e$_{k}$ is an unordered pair (v$_{i}$,v$_{j}$).

        \begin{tikzpicture}
            \matrix[column sep=3em, row sep=8ex, inner sep=0pt, minimum width=6pt] (M) {%
               \node[label={[left,xshift=-4pt]v$_{1}$}] (V1){}; & & &\node[label={right:v$_{2}$}] (V2) {};\\
            };
            \draw(V2)--(V1);
        \end{tikzpicture}
    \end{block} 
\end{frame}

\end{document}

在此处输入图片描述

相关内容