Graphics, Figures & Tablestkz-graph in a beamer presentation

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

tkz-graph in a beamer presentation

Post by CoolnessItself »

I'm trying to place the basic tkz-graph example located at http://altermundus.com/downloads/exampl ... h/gr_3.tex
in a \documentclass{beamer}

But I keep getting option clashes with xcolor. If I remove xcolor, I get
! Package xkeyval Error: `l' undefined in families `beamer@col'.



Suggestions?

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

tkz-graph in a beamer presentation

Post by gmedina »

Hi,

do not load the xcolor package as in the example. Delete the line

Code: Select all

\usepackage[usenames,dvipsnames]{xcolor}
and load the xcolor options as class options for beamer:

Code: Select all

\documentclass[xcolor={usenames,dvipsnames}]{beamer}
The following example should work OK (provided, of course, that the tkz-graph packages has been installed):

Code: Select all

\documentclass[xcolor={usenames,dvipsnames}]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
  \SetVertexNormal[Shape      = circle,
                   FillColor  = orange,
                   LineWidth  = 2pt]
  \SetUpEdge[lw         = 1.5pt,
             color      = black,
             labelcolor = white,
             labeltext  = red,
             labelstyle = {sloped,draw,text=blue}]
 \tikzstyle{EdgeStyle}=[bend left]
 \Vertex[x=0, y=0]{G}
 \Vertex[x=0, y=3]{A} 
 \Vertex[x=3, y=5]{P}
 \Vertex[x=4, y=2]{C}
 \Vertex[x=8, y=3]{Q}
 \Vertex[x=7, y=0]{E}
 \Vertex[x=3, y=-1]{R}
 \Edges(G,A,P,Q,E) \Edges(C,A,Q) \Edges(C,R,G) \Edges(P,E,A)
\end{tikzpicture}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

tkz-graph in a beamer presentation

Post by CoolnessItself »

Hi,
Thanks - it works!
Could you explain why it was needed in the options and not a usepackage?


Also, is it not possible to use columns with this? This is your example but with columns added:

Code: Select all

\documentclass[xcolor={usenames,dvipsnames}]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
  \SetVertexNormal[Shape      = circle,
                   FillColor  = orange,
                   LineWidth  = 2pt]
  \SetUpEdge[lw         = 1.5pt,
             color      = black,
             labelcolor = white,
             labeltext  = red,
             labelstyle = {sloped,draw,text=blue}]
\tikzstyle{EdgeStyle}=[bend left]
\Vertex[x=0, y=0]{G}
\Vertex[x=0, y=3]{A}
\Vertex[x=3, y=5]{P}
\Vertex[x=4, y=2]{C}
\Vertex[x=8, y=3]{Q}
\Vertex[x=7, y=0]{E}
\Vertex[x=3, y=-1]{R}
\Edges(G,A,P,Q,E) \Edges(C,A,Q) \Edges(C,R,G) \Edges(P,E,A)
\end{tikzpicture}

\begin{columns}
\begin{column}[l]{0.5\textwidth}
here's one
\end{column}
\begin{column}[r]{0.5\textwidth}
here's another
\end{column}
\end{columns}

\end{document}
! Package xkeyval Error: `l' undefined in families `beamer@col'.

Happens even if columns are on a separate frame.

And finally, is it possible to position the tikzpicture? textblock seems to fail on \draw
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

tkz-graph in a beamer presentation

Post by gmedina »

CoolnessItself wrote: ...Could you explain why it was needed in the options and not a usepackage?..
That's because the beamer class automatically loads the xcolor package, so you cannot pass options to xcolor in the usual way. See the beamer manual (Section 2.6 Compatibility with other Packages and Classes) for further information (by the way, there's a note there about the fourier package).

In fact, now that I review your code, in your example you don't need to pass any options to xcolor; you can simply use

Code: Select all

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}

\begin{document}

\begin{frame}
\begin{tikzpicture}
  \SetVertexNormal[Shape      = circle,
                   FillColor  = orange,
                   LineWidth  = 2pt]
  \SetUpEdge[lw         = 1.5pt,
             color      = black,
             labelcolor = white,
             labeltext  = red,
             labelstyle = {sloped,draw,text=blue}]
\tikzstyle{EdgeStyle}=[bend left]
\Vertex[x=0, y=0]{G}
\Vertex[x=0, y=3]{A}
\Vertex[x=3, y=5]{P}
\Vertex[x=4, y=2]{C}
\Vertex[x=8, y=3]{Q}
\Vertex[x=7, y=0]{E}
\Vertex[x=3, y=-1]{R}
\Edges(G,A,P,Q,E) \Edges(C,A,Q) \Edges(C,R,G) \Edges(P,E,A)
\end{tikzpicture}
\end{frame}

\end{document}
CoolnessItself wrote: ...is it not possible to use columns with this? This is your example but with columns added:
Of course it is possible. Simply, don't use the [l] and [r] modifiers (they are not allowed). Refer to section 12.7 Splitting a Frame into Multiple Columns of the beamer manual to see the valid options for the columns environment.

CoolnessItself wrote: ...And finally, is it possible to position the tikzpicture?...
Hmmm... I see your point here; using the code that I just provided, the resulting graph falls off the frame and changing the y-coordinates doesn't seem to have any effect. I'll have to think about this a little more.

A quick fix to manually move the graph vertically would be to use a \vspace* command before the tikzpicture:

Code: Select all

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}

\begin{document}

\begin{frame}
\vspace*{-3cm}
\begin{tikzpicture}
\SetVertexNormal[Shape      = circle,
                   FillColor  = orange,
                   LineWidth  = 2pt]
  \SetUpEdge[lw         = 1.5pt,
             color      = black,
             labelcolor = white,
             labeltext  = red,
             labelstyle = {sloped,draw,text=blue}]
\tikzstyle{EdgeStyle}=[bend left]
\Vertex[x=0, y=11]{G}
\Vertex[x=0, y=14]{A}
\Vertex[x=3, y=16]{P}
\Vertex[x=4, y=13]{C}
\Vertex[x=8, y=14]{Q}
\Vertex[x=7, y=11]{E}
\Vertex[x=3, y=10]{R}
\Edges(G,A,P,Q,E) \Edges(C,A,Q) \Edges(C,R,G) \Edges(P,E,A)
\end{tikzpicture}
\end{frame}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

Re: tkz-graph in a beamer presentation

Post by CoolnessItself »

Thanks, your quick fix works. The whole thing is a little funky, however. I'm noticing a lot of subtleties that I have to correct for. If I uncover{} a graph, everything on the slide moves, but \only doesn't. If I add nodes to the tikzpicture, their position changes the position of the entire picture. If I have \textcolor{red}{foo} on a slide, then \uncover{} a graph, "foo" changes to orange. Just plain weird behavior.
retrogrouch
Posts: 4
Joined: Tue Feb 09, 2010 9:43 am

Re: tkz-graph in a beamer presentation

Post by retrogrouch »

Regarding the positioning of the figure and its moving off the frame. I usually fiddle with the scale option passed to tikzfigure thus:

\begin{tikzfigure}[scale=0.8]

Laurie
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tkz-graph in a beamer presentation

Post by localghost »

retrogrouch wrote:[...] I usually fiddle with the scale option passed to tikzfigure thus:

\begin{tikzfigure}[scale=0.8]

[...]
Just for the record. The environment is called tikzpicture.
retrogrouch
Posts: 4
Joined: Tue Feb 09, 2010 9:43 am

tkz-graph in a beamer presentation

Post by retrogrouch »

localghost wrote:
retrogrouch wrote:[...] I usually fiddle with the scale option passed to tikzfigure thus:

\begin{tikzfigure}[scale=0.8]

[...]
Just for the record. The environment is called tikzpicture.
Whoops, sorry about that!

Laurie
Post Reply