4

Is there an easy latex class to create this figure?

Thanks!

10

Here is a TikZ method that uses the angles and quotes libraries to automatically draw the angle based on three coordinates, based off this answer.

enter image description here

\documentclass[tikz,border=3pt]{standalone}
\usetikzlibrary{quotes,angles}
\begin{document}
    \begin{tikzpicture}[line cap=rect]
        \coordinate (Origin) at (0,0);
        \draw [->,blue] (Origin)--++(30:2)  coordinate (VecV) node[midway,auto,swap] {$\vec{v}$};
        \draw [->,red]  (Origin)--++(110:2) coordinate (VecU) node[midway,auto] {$\vec{u}$};
        \draw pic["$\theta$", draw=orange, text=orange, <->, angle eccentricity=1.25, angle radius=1cm]
              {angle=VecV--Origin--VecU};
    \end{tikzpicture}
\end{document}

And an animated version just for fun...

enter image description here

\documentclass[tikz,border=3pt]{standalone}
\usetikzlibrary{quotes,angles}
\begin{document}
\foreach \X in {-180,-170,...,90,80,70,...,-180}{
    \begin{tikzpicture}[line cap=rect]
        \path[use as bounding box] (-2.2,-2.2) rectangle (2.2,2);
        \coordinate (Origin) at (0,0);
        \draw [->,blue] (Origin)--++(\X:2) coordinate (VecV);
        \path (Origin)--++(\X-15:1) coordinate (VecVLabel);
        \node [blue] at (VecVLabel) {$\vec{v}$};
        \draw [->,red]  (Origin)--++(110:2) coordinate (VecU) node[midway,auto] {$\vec{u}$};
        \draw pic["$\theta$", draw=orange, text=orange, <->, angle eccentricity=1.25, angle radius=1cm]           {angle=VecV--Origin--VecU};
    \end{tikzpicture}
    }
\end{document}
  • 1
    (+1) Nice! Better than mine. – Max Jul 19 '18 at 19:06
  • In the pic, how to make <-> draw Latex arrows at both ends? – Diaa Jul 19 '18 at 19:31
  • 1
    @Diaa write latex-latex instead of <-> , but remember to load the arrows.meta library, i.e. put \usetikzlibrary{arrows.meta} in your preamble. – Milo Jul 19 '18 at 19:34

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.