Graphics, Figures & TablesTikz picture options

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
tpokala
Posts: 21
Joined: Wed Nov 10, 2010 6:13 pm

Tikz picture options

Post by tpokala »

Hi, I have

Code: Select all

\begin{tikzpicture}[scale=2]
\tikzstyle{every node}=[draw,shape=circle];
\path (0:0cm) node (v0) {$a$};
\path (0:1cm) node (v1) {$b$};
\path (72:1cm) node (v2) {$c$};
\path (2*72:1cm) node (v3) {$d$};
\path (3*72:1cm) node (v4) {$e$};
\path (4*72:1cm) node (v5) {$f$};
\draw (v0) -- (v1)
(v3) -- (v2)
(v0) -- (v2)
(v0) -- (v3)
(v0) -- (v4)
(v0) -- (v5);
\end{tikzpicture}
but I would like to make spahes in different colors, how can I do that?

How can I add caption for this image to get it in list of images?
Last edited by tpokala on Wed Jan 12, 2011 4:55 pm, edited 1 time in total.

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

torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Tikz picture options

Post by torbjorn t. »

You can make a node or path a color by adding the name of the color as an option for the path.

As for your final question, simply put the tikzpicture environment within a figure environment, and add the caption as usual.

Code: Select all

\documentclass[a4paper]{article}
\usepackage{tikz}

\begin{document}

\listoffigures

\begin{figure}[hbt]
  \centering
  \begin{tikzpicture}[scale=2]
    \tikzstyle{every node}=[draw,shape=circle];
    \path [green] (0:0cm) node (v0) {$a$};
    \path [blue] (0:1cm) node (v1) {$b$};
    \path [red] (72:1cm) node (v2) {$c$};
    \path [yellow] (2*72:1cm) node (v3) {$d$};
    \path [red!50!yellow] (3*72:1cm) node (v4) {$e$};
    \path [black!30] (4*72:1cm) node (v5) {$f$};
    \draw (v0) -- (v1)
      (v3) -- (v2)
      (v0) -- (v2)
      (v0) -- (v3)
      (v0) -- (v4)
      (v0) -- (v5);
  \end{tikzpicture}
  \caption{A caption}
  \label{fig:figure}
\end{figure}

\end{document}
Edit: Small change to example.
tpokala
Posts: 21
Joined: Wed Nov 10, 2010 6:13 pm

Re: Tikz picture options

Post by tpokala »

Great, is there any option to fill vertex by color?
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Tikz picture options

Post by torbjorn t. »

fill=<color>

I really recommend the PGF manual[1], it is very extensive. By going through the tutorials in the first chapters, you'll learn a lot.



[1] Enter texdoc pgfmanual in a command line, or find it on CTAN: http://www.ctan.org/tex-archive/graphic ... manual.pdf
tpokala
Posts: 21
Joined: Wed Nov 10, 2010 6:13 pm

Re: Tikz picture options

Post by tpokala »

Ok, thank for help.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Tikz picture options

Post by localghost »

Now that the problem is solved, please be so kind and mark the topic (and not the last post) accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.


Thorsten
Post Reply