2

I'm using pdfLaTeX in MikTeX 2.9. I'm trying to create the hypercube in NamedGraphs.pdf (See 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}

The code above works. But if I include the tikzpicture in a frame (that is, if I remove the comment symbol for "\frame{" and "}"), I get the following error:

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

How do I fix this problem?

  • 2
    Replace \frame{ with \begin{frame}[fragile] and } with \end{frame} and your code should be compilable again. – leandriis Feb 28 '21 at 09:18
  • @leandriis Wow, it worked! Please write your comment as an answer so that I can upvote and accept it. Thanks! – user338955 Feb 28 '21 at 10:17

1 Answers1

1

In order to make your code compilable, you can use \begin{frame}[fragile] ... \end{frame} instead of \frame{ ... }. You might also want to add something along the lines of [scale=0.4] to your tikzpicture environment in order to make sure the image fits onto the slide:

enter image description here

\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}
leandriis
  • 62,593