I have latex code:


\xdefinecolor{darkgreen}{RGB}{175, 193, 36}

    \foreach \y in {86,38,15}{
        \coordinate (a) at (0,0);
        \coordinate (b) at (0:1);
        \foreach \x in {1,...,\y}{%
            \coordinate (c) at ($ (b)!1cm!270:(a) $);
                \draw[fill=\couleur!\thecntShader] (a)--(b)--(c)--cycle;
            \node[fill=white,draw,circle,inner sep=1pt] at (c)
            \coordinate (b) at (c);
    \node[fill=white,draw,circle,inner sep=1pt] at (0:1) {$\sqrt{1}$};


it turns out the following picture: enter image description here

I don't know the line \coordinate (c) at ($ (b)!1cm!270:(a) $); mean. And I am confused about why to use \pgfdeclarelayer{foreground} and \pgfsetlayers{background,main,foreground}. I just see the code use background layer in \begin{pgfonlayer}{background}.


1 Answer 1


P.151 in the manual:

⟨coordinate⟩!⟨dimension⟩!⟨angle⟩:⟨second coordinate⟩ When you write ⟨a⟩!⟨dimension⟩!⟨b⟩, this means the following: Use the point that is distanced ⟨dimension⟩ from ⟨a⟩ on the straight line from ⟨a⟩ to ⟨b⟩

As before, if you use a ⟨angle⟩, the ⟨second coordinate⟩ is rotated by this much around the ⟨coordinate⟩ before it is used.

Examples can be seen on page 151 in the manual.

\coordinate (c) at ($ (b)!1cm!270:(a) $);

means stand at (b) look in the direction of (a), turn 270 degrees and walk 1 cm. At this position place coordinate (c).

Yes the code would work without the foreground layer, but why not keep it as a standard way of having useful layers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .