4

I have a few questions regarding the pic command from the tikz.angles library that I am trying to experiment (the documentation in the Tikz-pgf manual remain very obscur to me).

So here is one bit of code

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[usenames,svgnames]{xcolor}
\usepackage{tikz-cd}
\usetikzlibrary{shapes,arrows,intersections}
\usetikzlibrary{matrix,fit,calc,trees,positioning,arrows,chains,shapes.geometric,shapes,angles,quotes}

\begin{document}

\begin{tikzpicture}

\draw (0,0) node{$\bullet$} node[left]{$O$};
\draw (0,0) circle(2cm);

\draw[->] (0,0)--(2.5,0) coordinate (X) node[right]{$x$};
\draw[->] (0,0)--(0,2.5) coordinate (Y) node[right]{$y$};

\draw[->,Aquamarine!50!black] (0,0)--($(0,0)!2cm!(4,3)$) node[midway,above left, Aquamarine!50!black]{$r$};
\draw ($(0,0)!2cm!(4,3)$) coordinate (P) node{$\bullet$} node[above right](P){$P$};

\draw[->,thick, Orchid!50!black] ($(0,0)!2cm!(4,3)$) -- ([turn]90:1cm) node[above, Orchid!50!black]{$\overrightarrow{v_e}$};
  \draw    pic["$\alpha$", draw=red, ->, angle eccentricity=1.2, angle radius=1cm]
    {angle=X--O--P};

\end{tikzpicture}
\end{document}

that yields me this picture (please note the colours will likely change) :

enter image description here

There I have two questions

  1. Is there any way to use the pic command directly with coordinates without naming the points ? I tried various versions of \draw pic["$\alpha$", draw=red, ->, angle eccentricity=1.2, angle radius=1cm] {angle=(2.5,0)--(0,0)--($(0,0)!2cm!(4,3)$)} without any success
  2. How can I change the color of my alpha, I have not found any doc about that.

Then there is a scope issue. This figure is in fact part of this one : enter image description here obtained through this code :

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[usenames,svgnames]{xcolor}
\usepackage{tikz-cd}
\usetikzlibrary{shapes,arrows,intersections}
\usetikzlibrary{matrix,fit,calc,trees,positioning,arrows,chains,shapes.geometric,shapes,angles,quotes}

\begin{document}

\begin{tikzpicture}

\draw (0,0,0) coordinate (O) node[above left]{$O$};
\draw[->, thick] (0,0,0) -- (0,0,2) node[below left]{$y$};
\draw[->, thick] (0,0,0) -- (0,3,0) node[above]{$z$};
\draw[->, thick] (0,0,0) -- (2,0,0) node[right]{$x$};

\draw[->, red] (0,0,0) -- (0,1,0) node[left]{$\overrightarrow{u'_z}=\overrightarrow{u_z}$};

\draw[->, red] (0,0,0) -- (0,0,1) node[above left]{$\overrightarrow{u_y}$};
\draw[->, red] (0,0,0) -- (1,0,0) node[below]{$\overrightarrow{u_x}$};

\begin{scope}[rotate around y=30]
\draw[->, red] (0,0,0) -- (0,0,1) node[below]{$\overrightarrow{u'_y}$};
\draw[->, red] (0,0,0) -- (1,0,0) node[above]{$\overrightarrow{u'_x}$};
\end{scope}

\draw (1.5,2.5,0) node{$\bullet$} node[right]{$P$ (fixe dans $\mathcal{R}_R$)};


\begin{scope}[xshift=8cm,yshift=1.0cm]
\draw (0,0) node{$\bullet$} node[left]{$O$};
\draw (0,0) circle(2cm);

\draw[->] (0,0)--(2.5,0) coordinate (X) node[right]{$x$};
\draw[->] (0,0)--(0,2.5) coordinate (Y) node[right]{$y$};

\draw[->,Aquamarine!50!black] (0,0)--($(0,0)!2cm!(4,3)$) node[midway,above left, Aquamarine!50!black]{$r$};
\draw ($(0,0)!2cm!(4,3)$) coordinate (P) node{$\bullet$} node[above right](P){$P$};

\draw[->,thick, Orchid!50!black] ($(0,0)!2cm!(4,3)$) -- ([turn]90:1cm) node[above, Orchid!50!black]{$\overrightarrow{v_e}$};
  \draw    pic["$\alpha$", draw=red, ->, angle eccentricity=1.2, angle radius=1cm]
    {angle=X--O--P};
\end{scope}
\end{tikzpicture}
\end{document}

The translation just does not seem to apply to the pic command.

  1. Any reason for the scope not having any effect ?
4
  1. It seems to me that you must use coordinate names. My guess is that the internals use \pgfpointanchor or some such, which requires a named node. It's probably good form to name your coordinates anyway!
  2. To make the angle label (say) green, set the text property of the pic (or the entire path):

    \draw pic["$\alpha$", draw=red, text=green, ->, angle eccentricity=1.2, angle radius=1cm] {angle=X--O--P};
    
  3. The pic is drawn relative to the named coordinates you use, which do not translate with a scope. In this case, you have redefined (X) and (P) for the second half of the picture, but (O) is still the origin of the first picture. To get the result you want you can just redefine the coordinate (O) as well to be the (translated) origin. For this case though I'd actually suggest using two separate tikz pictures. Then you can arrange, align, and space them any way you want as you would with imported graphics or text).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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