# LaTeX output for Graph Theory

250 views

### Taxman

Jul 10, 2009, 10:39:31 AM7/10/09
to sage-support
Hi, I was motivated to install Sage from the Graph Theory example on
http://mvngu.wordpress.com/2009/06/24/sage-4-0-2-released/ (the
but I still get the error Unknown environment "tikzpicture" on running
the example.

Doing some testing it was pointed out to me that \usepackage{tikz}
needs to be in the header of the tex file in order to avoid getting
this error when rendering the tex file manually. That appears to be
missing.

Where could I add that to get this example and other LateX Graph
Theory output to work?

Some details in case it is important, I'm running 4.02 on Ubuntu 9.04
because the binary packages used optimizations my processor doesn't
have and compiling from scratch failed.

Thanks

### javier

Jul 10, 2009, 11:06:32 AM7/10/09
to sage-support
Hi there,

you possibly just need to install the newest pgf tex package. You can

http://sourceforge.net/projects/pgf/

unpack the tgz file, copy the contents of the pgfXXXX inside a
location where your tex system can find it,
if you want a local installation just for one user, this is normally
~/.texmf-config/tex
but I don't use Ubuntu, so your location might be different. If you
want to be sure, just execute
kpsepath tex | tr : '\n'
and look at the output. Then go to the directory ~/texmf.config and
execute the command
mktexlsr .
(don't forget the dot at the end of the line!) to inform your tex
system that you have new packages there. You should be able to use the
tikz package now.

Cheers
Javier

On Jul 10, 3:39 pm, Taxman <taxman4...@gmail.com> wrote:
> Hi, I was motivated to install Sage from the Graph Theory example onhttp://mvngu.wordpress.com/2009/06/24/sage-4-0-2-released/(the
> but I still get the error Unknown environment "tikzpicture" on running
> the example.
>
> Doing some testing it was pointed out to me that \usepackage{tikz}
> needs to be in the header of the tex file in order to avoid getting
> this error when rendering the tex file manually. That appears to be
> missing.
>
> Where could I add that to get this example and other LateX Graph
> Theory output to work?
>
> Some details in case it is important, I'm running 4.02 on Ubuntu 9.04

### Taxman

Jul 10, 2009, 11:11:08 AM7/10/09
to sage-support
Oh, I forgot to mention, Ubuntu 9.04's pgf is at the latest version
2.0

I think my first message was really unclear. What I meant was, if I
include \usepackage{tikz} at the top of a tex file and render it
manually on the command line, then I don't get the Unknown environment
"tikzpicture" error, but if the file doesn't have \usepackage{tikz} in
the header it gives an error equivalent to Unknown environment
"tikzpicture".

Thanks though

### Dan Drake

Jul 10, 2009, 8:42:30 PM7/10/09
On Fri, 10 Jul 2009 at 08:11AM -0700, Taxman wrote:
> Oh, I forgot to mention, Ubuntu 9.04's pgf is at the latest version
> 2.0
>
> I think my first message was really unclear. What I meant was, if I
> include \usepackage{tikz} at the top of a tex file and render it
> manually on the command line, then I don't get the Unknown environment
> "tikzpicture" error, but if the file doesn't have \usepackage{tikz} in
> the header it gives an error equivalent to Unknown environment
> "tikzpicture".

That is exactly what you should expect, since the tikzpicture
environment is only defined when you are using the tikz package.

Perhaps we should update the documentation on the Sage graphs stuff to
make it (more?) clear that the output only makes sense in a document
that uses TikZ.

Dan

--
--- Dan Drake <dr...@kaist.edu>
----- KAIST Department of Mathematical Sciences
------- http://mathsci.kaist.ac.kr/~drake

signature.asc

### Taxman

Jul 11, 2009, 12:36:05 AM7/11/09
to sage-support
> That is exactly what you should expect, since the tikzpicture
> environment is only defined when you are using the tikz package.
>
> Perhaps we should update the documentation on the Sage graphs stuff to
> make it (more?) clear that the output only makes sense in a document
> that uses TikZ.

Right, I think I understand what you're saying. The problem is that I
got the
error when trying to run the example in Sage.

Now for some reason I didn't get the Unknown environment "tikzpicture"
in Sage, instead I got an error about not having tkz-arith.sty and
after
installing that and figuring out texhash, I got it working.

The only change I can think of is that I installed dvipng in the
meantime.
Maybe having dvipng is not better as
http://www.sagemath.org/doc/reference/sage/graphs/graph_latex.html
mentions, but actually required.
Message has been deleted

### Rob Beezer

Jul 12, 2009, 1:22:00 AM7/12/09
to sage-support
Taxman,

Thanks for the report. Current behavior is to support latex versions
of graphs by adding two "\usepackage" commands to the preamble. It is
possible tkz-arith.sty should also be added, and maybe something
bigger like tikz and pgf.

Also, the documentation could perhaps be improved by specifying just
what a tex environment needs to have so a standalone document will
compile when a sage latex-version graph is incorporated.

I don't think dvipng being present, or not, is relevant here, since
that merely affects if a PNG or PDF image gets created - it comes
after latex does its complaining.

Sample code below may help with understanding/debugging this
situation. This is now

http://trac.sagemath.org/sage_trac/ticket/6516

Rob

~~~~~~~~~~
sage: latex.extra_preamble()
''
sage: g=graphs.PetersenGraph()
sage: latex.extra_preamble()
'\\usepackage{tkz-graph}\\usepackage{tkz-berge}'
sage: latex
(g)

\begin{tikzpicture}
<snip lots of latex graph code>
\end{tikzpicture}

### Taxman

Jul 13, 2009, 3:28:14 PM7/13/09
to sage-support
Rob, indeed excellent ideas since tkz-arith.sty did seem to be needed
along with the two other packages, but only two \\usepackage commands.
My tex installation automatically had pgf and tikz, but those would
probably also be good things to include for clarity along with moving
the documentation about how to check if they are installed such as
check_tkz_graph() and have_tkz_graph() from
http://www.sagemath.org/doc/reference/sage/graphs/graph_latex.html to
perhaps the top explanatory part or another howto. Also I had no idea
where to put tkz-berge, tkz-gerge, etc. I just guessed, and it
happened to work after I figured out I needed texhash.

Also the standalone document suggestion is good too, perhaps all the
way up to a full minimal header or a full minimal document for those
that want to include a Sage generated graph into their documents with
the greatest of ease.

And if dvipng wasn't the change I certainly can't think of anything
else that caused the Unknown environment "tikzpicture" error to go
away.

### Rob Beezer

Jul 14, 2009, 2:13:29 AM7/14/09
to sage-support
Hi Taxman,

Thanks for the excellent suggestions - this is next in my queue. Yes,
some TeX guidance would be helpful, and I'm going to add some, but its
not going to become a full-blown tutorial on installing new TeX
packages. That's "out of scope." ;-)

texhash, mktexls-r, kpsewhich and some notion of which directory to
stuff the tkz-*.sty files will be there. A minimal template for a
standalone document is a great idea as well.

%latex_debug works great in a notebook cell, and I'll have to dig up
the analogue for the command line. I've found that very helpful when
working through these sorts of things.

Sorry you had a rough time of it, but your experience and guidance
will be useful. Thanks again for the suggestions.

Rob