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 have this code :

\documentclass[tikz}]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning,fit,calc,decorations,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] (-15,-3) rectangle (15,15);
    \node[rectangle, ] at (0, 13) {\color{white} \fontsize{25}{58}\selectfont LES {\'E}TOILES LES PLUS PROCHES DU SOLEIL};
    \path[circle label={Nuage d'Oort}] (0,-1.2) arc (-90:360-90:1.3);
    \draw[dotted] (0,0) circle (1.18596338615);

        \foreach \i in {3,6,9} {
            \path[circle label={\i\ ANN{\'E}S LUMI{\`E}RES}] (0,-\i-.2) arc (-90:360-90:\i+.2);
    }
    \draw (0,0) circle (3);
    \draw ([shift=(-30:6cm)]0,0) arc (-30:210:6cm);
    \draw ([shift=(-19.47:9cm)]0,0) arc (-19.47:199.47:9cm);

    \node[yellow,planet=3pt,label={Soleil}] at (0,0) {};

    \node(proxima)[red,planet=3pt] at (44:6.363) {};
     \node[text width=2.8cm,align=center, right = 0.05 of proxima] {Proxima Centauri.\newline(distance 1917)};

    \node[yellow,planet=4pt,label={[text width=2.5cm,align=center]Alpha Centauri.\ (distanse 1917)}] at (50:6.54735) {};

    \node[red!50!black,planet=2pt] at (54:9.75) {};

    \node[red!50!black,planet=2pt, label={[text width=2.7cm,align=center]WISE 1049-5319.\ (distanse 2013)}] at (57:9.75) {};

    \node(bernard)[red,planet=3pt] at (130:8.94435) {};
    \node[text width=2.8cm,align=center, left = 0.05 of bernard] {{É}toile de Barnard.\ (distanse 1916)};

    \node(wise)[red,planet=3pt] at (110:10.7625) {};
    \node[text width=2.8cm,align=center, right = 0.05 of wise] {WISE 0855–0714.\newline(distanse 2014)};

\end{tikzpicture}
\end{document}

And I get this :

enter image description here

The problem is the white space below my figure. I thought that standalone include only the figure. How to remove this white space?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Your problem lies in these lines.

\foreach \i in {3,6,9} {
    \path[circle label={\i\ ANN{\'E}S LUMI{\`E}RES}] (0,-\i-.2) arc (-90:360-90:\i+.2);
}

Because of this, the bounding box gets extended below.

enter image description here

Change those lines to

    \foreach \i in {3,6,9} {
        \path[circle label={\i\ ANN{\'E}S LUMI{\`E}RES}] (\i+0.2,0) arc (0:180:\i+.2);
}

enter image description here

Full code:

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usetikzlibrary{shapes.geometric,positioning,fit,calc,decorations,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] (-15,-3) rectangle (15,15);
    \node[rectangle,text=white,font=\fontsize{25}{58}\selectfont ] at (0, 13) {LES {\'E}TOILES LES PLUS PROCHES DU SOLEIL};
    \path[circle label={Nuage d'Oort}] (0,-1.2) arc (-90:360-90:1.3);
    \draw[dotted] (0,0) circle (1.18596338615);

        \foreach \i in {3,6,9} {
            \path[circle label={\i\ ANN{\'E}S LUMI{\`E}RES}] (\i+0.2,0) arc (0:180:\i+.2);
    }
    \draw (0,0) circle (3);
    \draw ([shift=(-30:6cm)]0,0) arc (-30:210:6cm);
    \draw ([shift=(-19.47:9cm)]0,0) arc (-19.47:199.47:9cm);

    \node[yellow,planet=3pt,label={Soleil}] at (0,0) {};

    \node(proxima)[red,planet=3pt] at (44:6.363) {};
     \node[text width=2.8cm,align=center, right = 0.05 of proxima] {Proxima Centauri.\newline(distance 1917)};

    \node[yellow,planet=4pt,label={[text width=2.5cm,align=center]Alpha Centauri.\ (distanse 1917)}] at (50:6.54735) {};

    \node[red!50!black,planet=2pt] at (54:9.75) {};

    \node[red!50!black,planet=2pt, label={[text width=2.7cm,align=center]WISE 1049-5319.\ (distanse 2013)}] at (57:9.75) {};

    \node(bernard)[red,planet=3pt] at (130:8.94435) {};
    \node[text width=2.8cm,align=center, left = 0.05 of bernard] {{É}toile de Barnard.\ (distanse 1916)};

    \node(wise)[red,planet=3pt] at (110:10.7625) {};
    \node[text width=2.8cm,align=center, right = 0.05 of wise] {WISE 0855–0714.\newline(distanse 2014)};
%\draw[thick,red] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}
share|improve this answer

You can clip to the rectangle you use as background:

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning,fit,calc,decorations,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,
        }
        }
    ]
    \clip (-15,-3) rectangle (15,15);
    \filldraw[black] (-15,-3) rectangle (15,15);
    \node[rectangle, ] at (0, 13) {\color{white} \fontsize{25}{58}\selectfont LES {\'E}TOILES LES PLUS PROCHES DU SOLEIL};
    \path[circle label={Nuage d'Oort}] (0,-1.2) arc (-90:360-90:1.3);
    \draw[dotted] (0,0) circle (1.18596338615);

        \foreach \i in {3,6,9} {
            \path[circle label={\i\ ANN{\'E}S LUMI{\`E}RES}] (0,-\i-.2) arc (-90:360-90:\i+.2);
    }
    \draw (0,0) circle (3);
    \draw ([shift=(-30:6cm)]0,0) arc (-30:210:6cm);
    \draw ([shift=(-19.47:9cm)]0,0) arc (-19.47:199.47:9cm);

    \node[yellow,planet=3pt,label={Soleil}] at (0,0) {};

    \node(proxima)[red,planet=3pt] at (44:6.363) {};
     \node[text width=2.8cm,align=center, right = 0.05 of proxima] {Proxima Centauri.\newline(distance 1917)};

    \node[yellow,planet=4pt,label={[text width=2.5cm,align=center]Alpha Centauri.\ (distanse 1917)}] at (50:6.54735) {};

    \node[red!50!black,planet=2pt] at (54:9.75) {};

    \node[red!50!black,planet=2pt, label={[text width=2.7cm,align=center]WISE 1049-5319.\ (distanse 2013)}] at (57:9.75) {};

    \node(bernard)[red,planet=3pt] at (130:8.94435) {};
    \node[text width=2.8cm,align=center, left = 0.05 of bernard] {{É}toile de Barnard.\ (distanse 1916)};

    \node(wise)[red,planet=3pt] at (110:10.7625) {};
    \node[text width=2.8cm,align=center, right = 0.05 of wise] {WISE 0855–0714.\newline(distanse 2014)};

\end{tikzpicture}
\end{document}

Clipped

share|improve this answer
    
Why I sould add this? Why standalone doesn't crop my figure correctly? –  user230137 May 8 at 22:41
    
You gave me an idea how to replace the arcs with circle and add only one instruction to the foreach loop. Thanks –  user230137 May 8 at 22:46
    
@user230137 I don't know why. I just know it doesn't and this works around it. It happened to me the other day and this is how I ended up solving it. It seems that standalone crops to include all defined/used points. I created the issue by using controls which lay outside the drawn parts of the picture to define the shape of curved lines. standalone included the space where those control points were even though they were only control points and did not actually lie on any path - not even one I didn't draw. As to why, I'm not sure. I answered how to eliminate the space but not why. Sorry. –  cfr May 8 at 22:53
    
@user230137 (3 comments up) standalone doesn't crop your figure. It crops the page to fit your figure. Of course in order to do this, it needs to know how big your figure is, and the way it knows that is from the bounding box. standalone knows nothing about how the bounding box of the figure is determined, so it is not "smart" (or rather "psychic") enough to tell that part of that bounding box doesn't actually have anything drawn in it. That's TikZ's job. –  David Z May 9 at 9:35
    
@DavidZ Do you know why control points which aren't actually on a path cause the bounding box to be extended? (I realise that's not standalone's doing - thanks for clarifying that - but I'm curious as to why tikz includes them.) I can see why stuff on a path gets included in the OP's example but it seems odder that mere control points do. –  cfr May 9 at 12:07

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.