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

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

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

Postby DaneelOlivaw » Sun May 20, 2018 1:21 pm

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 14 times

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3906
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun May 20, 2018 1:53 pm

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

Postby DaneelOlivaw » Sun May 20, 2018 3:36 pm

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: 3906
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun May 20, 2018 3:39 pm

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

Postby DaneelOlivaw » Sun May 20, 2018 5:06 pm

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: 9201
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun May 20, 2018 5:18 pm

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:

  1. \documentclass[utf8,german,ignorenonframetext]{beamer}
  2. \usepackage{tikz}
  3. \newcommand{\D}{7} % number of dimensions (config option)
  4. \renewcommand{\U}{7} % number of scale units (config option)
  5. \newdimen\R % maximal diagram radius (config option)
  6. \R=3.5cm
  7. \newdimen\L % radius to put dimension labels (config option)
  8. \L=4cm
  9. \newcommand{\A}{360/\D} % calculated angle between dimension axes
  10. \begin{document}
  11. \begin{frame}[fragile]
  12. \begin{tikzpicture}[scale=1]
  13. \path (0:0cm) coordinate (O); % define coordinate for origin
  14. % draw the spiderweb
  15. \foreach \X in {1,...,\D}{
  16. \draw (\X*\A:0) -- (\X*\A:\R);
  17. }
  18. \foreach \Y in {0,...,\U}{
  19. \foreach \X in {1,...,\D}{
  20. \path (\X*\A:\Y*\R/\U) coordinate (D\X-\Y);
  21. \fill (D\X-\Y) circle (1pt);
  22. }
  23. \draw [opacity=0.3] (0:\Y*\R/\U) \foreach \X in {1,...,\D}{
  24. -- (\X*\A:\Y*\R/\U)
  25. } -- cycle;
  26. }
  27. \end{tikzpicture}
  28. \end{frame}
  29. \end{document}


Stefan
Site admin

DaneelOlivaw
Posts: 4
Joined: Sun May 20, 2018 12:57 pm

Postby DaneelOlivaw » Sun May 20, 2018 6:47 pm

Great,

thank you I will try it.

Regards

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

Postby Stefan Kottwitz » Sun May 20, 2018 6:52 pm

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
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests