Graphics, Figures & TablesDrawing a spider web (tikz example) in a frame of beamer class

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
DaneelOlivaw
Posts: 4
Joined: Sun May 20, 2018 12:57 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by DaneelOlivaw »

Hi,

I am just preparing a slide using beamer class. On this frame I want to draw a spider web.
I found a very useful example at http://www.texample.net/community/ . It works in beamer class as long as I do not put it into a frame. As long as the code is not surrounded by \begin{frame}...\end{frame} everything works well. But after surrounding the code by a frame I got "undefined symbol" error message.I tried to put the suggested variables into a global but either a \setlength within a frame is recognized as "undefined" or the symbol.
It looks like either I am missing something in my code or there is something missing at all.

Error message in the test was:

.\test.vrb:7: Undefined contrl sequence
<argument> \X *\A
:0
l.7 }
?

The atteched file is in the state "workin, frame commented out".

I appreciate any hints

Regards
Attachments
test.tex
(2.25 KiB) Downloaded 390 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by Johannes_B »

The standalone code will give you a cropped pdf. Just include that. It will also reduce compile time.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
DaneelOlivaw
Posts: 4
Joined: Sun May 20, 2018 12:57 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by DaneelOlivaw »

That's right, with class standalone everything works. But standalone does not support the beamer features.
The problem seems to be the frame-environment in the beamer class.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by Johannes_B »

Not what i meant. Finish the image, compile with the standalone class to get the image as a high quality vector pdf image.
Use that pdf-image in a frame for your presentation.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
DaneelOlivaw
Posts: 4
Joined: Sun May 20, 2018 12:57 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by DaneelOlivaw »

I've got your point. That's a very nice workaround. I do this with any other pictures but did not expect it here.
But I still think there is something in the frame environment which holds back the basic features. Any other drawings work well. I did many slides with rectangles lines and more. But I cannot define variables either in the environment (or I missed something) nor outside and use them within.

Please refer to the notes at the end of this post. I found out that it will work - somehow but useful

Even this does not work and that sounds strange.
%\RequirePackage{luatex85}
%\documentclass[border=0pt]{standalone}
\documentclass[utf8,german,ignorenonframetext]{beamer}

\usepackage{verbatim}
\usetheme{metropolis}
\usepackage{tikz}

\begin{document}ols as globals
\begin{frame}[fragile]
well done
\end{frame}
\newcommand{\welldone}{well done}
\begin{frame}[fragile]
\welldone %% undefined symbol
\end{frame}
\end{document}

After searching a bit around I found that \new* commands need to be WIHTIN the frame environment (https://tex.stackexchange.com/questions ... amer-frame).
Then the shown example above works nicely.

I tried a bit more and the latets is: it was not an undedfined symbol but something which lead to multiple definitions of a symbol. Dont now why in the test \UU and other gave the multiply defined symbol error.

At the end I did the following:
put the \new*-commands within the frame environment then use symbol names which are NEVER used somewhere else.

Thanks for assistance. It lead to a more deeply look in to the problem.

I still appreciate hints on the basic problems why the frame environment does not accept outer definitions of \new*-commands. Is there something in the documentation of beamer class which I probably read over?

Regards
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by Stefan Kottwitz »

Hi Daneel,

welcome to the forum!

The code example defined \AA but used \A. Here you can see that it works, defining the macros in the preamble:

Code: Select all

\documentclass[utf8,german,ignorenonframetext]{beamer}
\usepackage{tikz}
\newcommand{\D}{7} % number of dimensions (config option)
\renewcommand{\U}{7} % number of scale units (config option)
\newdimen\R % maximal diagram radius (config option)
\R=3.5cm 
\newdimen\L % radius to put dimension labels (config option)
\L=4cm
\newcommand{\A}{360/\D} % calculated angle between dimension axes  
\begin{document}
\begin{frame}[fragile]
	\begin{tikzpicture}[scale=1]
	  \path (0:0cm) coordinate (O); % define coordinate for origin
	  % draw the spiderweb
	  \foreach \X in {1,...,\D}{
		\draw (\X*\A:0) -- (\X*\A:\R);
	  }
	  \foreach \Y in {0,...,\U}{
		\foreach \X in {1,...,\D}{
		  \path (\X*\A:\Y*\R/\U) coordinate (D\X-\Y);
		  \fill (D\X-\Y) circle (1pt);
		}
		\draw [opacity=0.3] (0:\Y*\R/\U) \foreach \X in {1,...,\D}{
			-- (\X*\A:\Y*\R/\U)
		} -- cycle;
	  }
	\end{tikzpicture}
\end{frame}
\end{document}
Stefan
LaTeX.org admin
DaneelOlivaw
Posts: 4
Joined: Sun May 20, 2018 12:57 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by DaneelOlivaw »

Great,

thank you I will try it.

Regards
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Drawing a spider web (tikz example) in a frame of beamer class

Post by Stefan Kottwitz »

Btw. only with \U I had to use \renewcommand instead of \newcommand since \U is already defined. This, to use the original code, otherwise I would use a different macro name instead of redefining something that could be needed internally.

Stefan
LaTeX.org admin
Post Reply