这是我第一次将 tikz 与 beamer 一起使用,不知道为什么它根本不起作用。如果我将 article 作为文档类进行编译,tikz 代码可以完美运行。有人能帮我吗?我有以下代码。
\documentclass{beamer}
\mode<presentation>
{
\usetheme{default}
\usecolortheme{default}
\usefonttheme{default}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage{amsmath,amssymb,amsfonts,amscd}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{arrows,positioning}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage[utf8x]{inputenc}
\usepackage{multicol}
\usepackage{tikz}
\usepackage{multicol}
\usetikzlibrary{arrows}
\usetikzlibrary {positioning}
\begin{document}
\begin{frame}
\begin{figure}
\begin{tikzpicture}
\filldraw[fill=gray!40!white,draw=black] (-2,-2) rectangle (2,2);
\fill[black,rotate=45] (-0.125,-0.125) rectangle (0.125,0.125);
\draw[-to, line width=1pt] (0,-2.5) -- (0,2.5);
\draw[-to, line width=1pt] (-2.5,0) -- (2.5,0);
\draw[line width=1.1pt] (-2,-0.1) -- (-2,0.1);
\draw[line width=1.1pt] (2,-0.1) -- (2,0.1);
\draw[line width=1.1pt] (-0.1,-2) -- (0.1,-2);
\draw[line width=1.1pt] (-0.1,2) -- (0.1,2);
\node[black] at (0,2.7) {$y$};
\node[black] at (2.7,0) {$x$};
\node[black] at (-2.25,-0.2) {\small$-a$};
\node[black] at (2.15,-0.2) {\small$a$};
\node[black] at (-0.35,-2.25) {\small$-a$};
\node[black] at (-0.2,2.25) {\small$a$};
\node[black] at (1,1) {$V=0$};
\node[black] at (-2.5,-2.5) {$V_0$};
\node[black] at (-2.5,2.5) {$V_0$};
\node[black] at (2.5,-2.5) {$V_0$};
\node[black] at (2.5,2.5) {$V_0$};
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}