Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm learning how to use TikZ/PGF. I want to draw this picture :

enter image description here

Here's how I began :

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}  
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}

\begin{document}
    \begin{tikzpicture}
        \node (sun) at (0,0) [circle, fill=yellow, radius=0.3cm]{};
        \node (sunlabel) [above=0.08 of sun]{Sun};
        \node (root) at (0,0) [draw, circle, radius=3cm]{};
    \end{tikzpicture}
\end{document}

The problem is that the second circle is not drawn. I don't know what's the problem. This syntax work but I don't know how to give a name to the circles and how to fill a circle with a color.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}  
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}

\begin{document}
    \begin{tikzpicture}
        \draw (0,0) circle [radius=.3cm, fill=yellow];
        \draw (0,0) circle [radius=2cm];
         \path[
            %rotate=-15.2,
            postaction={
                decoration={
                    text along path,
                    text={%
                        OORT CLOUD
                    },
                    text align=center,
                    reverse path
                },
                decorate
            }
        ]
         (-27:2.2cm) arc (-27:210:2.2cm);
    \end{tikzpicture}
\end{document}
share|improve this question
1  
Z order does matter here. If the top circle is bigger than the bottom one, the bigger one will hide the bottom one when you add fill color to the bigger one and set its opacity to 1. –  Who is crazy first May 8 at 16:17
    
This isn't an answer to your question, but this may be of interest. –  Jubobs May 8 at 16:54
    
In your first code snippet, radius has no effect because it is not a valid option for \node. –  Jubobs May 8 at 17:12
    
Design of an asteroid belt in TikZ is another answer that may be of interest... –  Paul Gaborit May 8 at 21:41
    
I'm curious how long it takes until the first physically correct animated answer will be posted –  moose May 9 at 0:27

3 Answers 3

up vote 3 down vote accepted

You will need to put the accented characters in braces in the circle label because PGF will split the string into tokens and will therefore split the accents from the characters, which leads to weird errors.

I translated the labels to french to emphasize the behaviour (I don't speak french, so I hope I didn't make too many mistakes).

\documentclass[tikz]{standalone}
\usepackage[utf8]{inputenx}
\usetikzlibrary{decorations.text}
\begin{document}
\sffamily
\begin{tikzpicture}[
        white,
        ultra thick,
        planet/.style = {draw,fill,circle,inner sep=#1},
        circle label/.style = {
            postaction={
                decoration={
                    text along path,
                    text = {#1},
                    text align=center,
                    text color=white,
                    reverse path,
                },
            decorate,
        }
        }
    ]
    \filldraw[black] (-7,-7) rectangle (7,8);
    \node at (0,7.5) {\bfseries\Large Voisins les plus proches du soleil};
    \path[circle label={Nuage d'Oort}] (0,-1.2) arc (-90:360-90:1.2);
    \draw[dotted] (0,0) circle (1);
    \foreach \i in {2,4,6} {
        \path[circle label={\i\ Ann{é}e lumi{è}res}] (0,-\i-.2) arc (-90:360-90:\i+.2);
        \draw (0,0) circle (\i);
    }
    \node[yellow,planet=3pt,label={above:Soleil}] at (0,0) {};
    \node[red,planet=3pt,label={[text width=1.5cm,align=right]0:Proxima Centauri déc.\ 1917}] at (44:4.3) {};
    \node[yellow,planet=4pt,label={[text width=2.5cm,align=center]90:Alpha Centauri déc.\ 1917}] at (50:4.3) {};
    \node[red!50!black,planet=2pt,label={[text width=2.5cm,align=center]0:WISE 1049-5319 déc.\ 2013}] at (54:6.3) {};
    \node[red!50!black,planet=2pt] at (57:6.3) {};
    \node[red,planet=3pt,label={[text width=3cm,align=center]95:L'étoile de Bernard déc.\ 1916}] at (125:6) {};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Ok thanks. I know the solution to get the light years sloped to the circle –  user230137 May 8 at 17:32
    
look at my updated question. Do you know how to not draw all the circle like in picture? –  user230137 May 8 at 17:35
    
I can't replace LIGHT YEARS with Année lumières. The special characters are the problem. Do you know how to solve the problem? –  user230137 May 8 at 20:10
    
@user230137: I think you should try loading \usepackage[<encoding>]{inputenc} where <encoding> should be very likely utf8. –  Claudio Fiandrino May 9 at 7:01
    
@ClaudioFiandrino NO I found a solution. Special characters should written like this {éà}. –  user230137 May 9 at 8:09

If you use the syntax:

\draw [fill=yellow] (0,0) circle (0.3cm) node (sun) {};

then things work as expected:

enter image description here

Notes:

  • I added a draw=none for the sun as you probably don't want a border around it.
  • I left you original lines as comments so you can see the differences.

Code:

\documentclass[border=2pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}  
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}

\begin{document}
    \begin{tikzpicture}
        %\node (sun) at (0,0) [circle, fill=yellow, radius=0.3cm] {};
        \draw [fill=yellow, draw=none] (0,0) circle (0.3cm)
            node (sun) {};
        \node (sunlabel) [above=0.08 of sun]{Sun};
        %\node (root) at (0,0) [draw=red, circle, radius=3cm] {};
        \draw [draw=red, ultra thick] (0,0) circle (3.0cm)
            node (planet) {};
    \end{tikzpicture}
\end{document}
share|improve this answer

Fewer keystrokes with PSTricks.

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(-2,-2)(2,2)
    \pscircle*[linecolor=orange]{5pt}
    \pscircle{2}
\end{pspicture}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.