Friday, February 26, 2010

This blog moves

This blog will continue here, for reasons explained there.

Saturday, September 05, 2009

A 3d graph

... after the example in the tikz gallery.

[x = {(\xone cm,\yone cm)},
y = {(\xtwo cm,\ytwo cm)},
z = {(0cm,1cm)}]
\begin{scope}[canvas is xy plane at z=-5]
\begin{scope}[canvas is xy plane at z=0]
\begin{scope}[canvas is xy plane at z=5]

Friday, August 28, 2009

A circulant tournament

This is the circulant C_9(1,2,3,4)

\SetUpEdge[style={->,>=angle 45,bend right=10},color=red]

Tuesday, August 18, 2009

Several options for the \Vertex macro

UPDATE: This example no longer works with the latest versions of tkz-graph and tkz-berge. For an updated version see this post at my new blog.

{\tikzstyle{every node} = [node distance=1.5cm]
{\tikzstyle{every node} = [node distance=1.5cm]
style={line width=2pt,
inner sep=0pt,
minimum size=12pt}]{Q,R,S}}
\foreach \x/\y in {E/F,G/H,I/J,K/L,M/N,O/P}
\Edge[style={bend left}](G)(N)
\Edge[style={bend right}](A)(T)

Monday, August 03, 2009

Several options for the \Edge macro

{\tikzstyle{every node} = [node distance=1.5cm]
{\tikzstyle{every node} = [node distance=1.5cm]
\foreach \x/\y in {E/F,G/H,I/J,K/L,M/N,O/P}
\Edge[label=OS,labelstyle={below=1pt,inner sep=0pt}](O)(S)
\Edge[style={bend right}](A)(T)

Simulating KTikZ with Emacs

I stumbled upon a piece of software called KtikZ. The screenshot in that page, together with the fact that Doc-View mode is included in the new Emacs 23, inspired me to try that idea with tikz2pdf. With help from folks from, I came up with the following function:

(defun split-for-tikz2pdf ()
(TeX-run-style-hooks "tikz")
(TeX-run-style-hooks "tkz-berge")
(split-window-horizontally 60)
(other-window 1)
(split-window-vertically 15)
(find-file "tikz2pdf_temp.pdf")
(auto-revert-mode 1)
(other-window 1)
(let ((file-path (buffer-file-name)))
(when file-path
(comint-send-string (get-buffer-process (current-buffer))
(format "tikz2pdf -v %S \n" file-path))))

which gives something like this, when applied at a buffer with a .tex file:

Unfortunately, the buffer for the .pdf file is not in Doc-View mode after executing the function. One has to go to that window and do M-x doc-view-mode. After that, sometimes the picture is not generated correctly and one has to reload manually with g. Other useful Doc-View key bindings are + and -.

You might want to use my simple AucTeX style files tikz.el and tkz-berge.el.

Thursday, February 21, 2008

Using tikz2pdf

When drawing graphs by trial and error, the script tikz2pdf by Hans Meine can be very useful.

I have the following in ~/.tikz2pdf.tex:







Then, I edit a file, say foo.tikz, with


and run

tikz2pdf -v foo.tikz

I can open then the generated tikz2pdf_temp.pdf with, say Sumatra,which is a viewer that, unlike Acrobat, does not complain if an opened file is modified. Next time I modify foo.tikz and save it, pdflatex is automatically run and I can press r in Sumatra to update the picture.

Thursday, May 10, 2007

New LaTeX package for graphs

Alain Matthes has produced a package (tkz-berge.sty) which should become THE way to draw graphs in LaTeX. It is built on top of Tikz, and so can be easily integrated with beamer presentations. The package can be dowloaded from here, and the documentation (in French, but very nicely formatted and with lot of examples) can be obtained from here. Alain's packages are all here.

I plan to redraw all my examples using tkz-berge's syntax, but for the time being, I will show code for the dodecahedron above:




\tikzstyle{NormalVertexStyle}=[shape = circle,%
shading = ball,%
ball color = white,%
very thin,
inner sep=3pt,%
\tikzstyle{EdgeStyle}= [thick,%
double= orange,%
double distance = 1pt]

\tikzstyle{every node} = [node distance=1.5cm]
\EA{A}(C) \NO{C}(B) \SO{C}(D)
\tikzstyle{every node} = [node distance=1.2cm]
\EA{B}(F) \NO{F}(E) \SO{F}(G)
\EA{D}(I) \NO{I}(H) \SO{I}(J)
\EA{F}(L) \NO{L}(K) \SO{L}(M)
\EA{I}(O) \NO{O}(N) \SO{O}(P)
\tikzstyle{every node} = [node distance=1.5cm]
\SO{Q}(R) \SO{R}(S) \EA{R}(T)
\Edge(A)(B) \Edge(A)(C) \Edge(A)(D)
\Edge(B)(E) \Edge(B)(G)
\Edge(C)(F) \Edge(C)(I)
\Edge(D)(H) \Edge(D)(J)
\Edge(E)(K) \Edge(E)(F) \Edge(F)(M)
\Edge(G)(L) \Edge(G)(H) \Edge(H)(O)
\Edge(I)(N) \Edge(I)(J) \Edge(J)(P)
\Edge(K)(Q) \Edge(K)(L)
\Edge(M)(Q) \Edge(M)(N)
\Edge(T)(Q) \Edge(L)(R)
\Edge(O)(R) \Edge(O)(P)
\Edge(T)(R) \Edge(N)(S)
\Edge(P)(S) \Edge(T)(S)