未定义的控制序列 \thetkz

未定义的控制序列 \thetkz

我在 MikTeX 2.9 中使用 pdfLaTeX。我试图在 NamedGraphs.pdf 中创建超立方体(参见https://tex.stackexchange.com/a/129972/200958):

\documentclass{beamer}
\usepackage{tkz-berge}
\begin{document}
%\frame{
\begin{tikzpicture}
\grCycle[RA=8]{8}
\pgfmathparse{8*(1-4*sin(22.5)*sin(22.5))}
\let\tkzbradius\pgfmathresult
\grCirculant[prefix=b,RA=\tkzbradius]{8}{3}
\makeatletter
\foreach \vx in {0,...,7}{%
\pgfmathsetcounter{tkz@gr@n}{mod(\vx+1,8)}
\pgfmathsetcounter{tkz@gr@a}{mod(\vx+7,8)}
\pgfmathsetcounter{tkz@gr@b}{mod(\thetkz@gr@n+1,8)}
\Edge(a\thetkz@gr@n)(b\thetkz@gr@b)
\Edge(b\thetkz@gr@a)(a\vx)
}
\makeatother
\end{tikzpicture}
%}
\end{document}

上面的代码可以正常工作。但是,如果我将 tikzpicture 包含在框架中(即,如果我删除“\frame{”和“}”的注释符号),则会出现以下错误:

! Undefined control sequence.
<argument> mod(\thetkz 
                       @gr@n+1,8)
l.20 }

我该如何解决这个问题?

答案1

为了使你的代码可编译,你可以使用\begin{frame}[fragile] ... \end{frame}而不是。你可能还想在你的环境\frame{ ... }中添加一些类似的东西,以确保图像适合幻灯片:[scale=0.4]tikzpicture

在此处输入图片描述

\documentclass{beamer}
\usepackage{tkz-berge}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}[scale=0.4]
\grCycle[RA=8]{8}
\pgfmathparse{8*(1-4*sin(22.5)*sin(22.5))}
\let\tkzbradius\pgfmathresult
\grCirculant[prefix=b,RA=\tkzbradius]{8}{3}
\makeatletter
\foreach \vx in {0,...,7}{%
\pgfmathsetcounter{tkz@gr@n}{mod(\vx+1,8)}
\pgfmathsetcounter{tkz@gr@a}{mod(\vx+7,8)}
\pgfmathsetcounter{tkz@gr@b}{mod(\thetkz@gr@n+1,8)}
\Edge(a\thetkz@gr@n)(b\thetkz@gr@b)
\Edge(b\thetkz@gr@a)(a\vx)
}
\makeatother
\end{tikzpicture}
\end{frame}
\end{document}

相关内容