4

I need to do this picture...

enter image description here

That is my starting code. How can i draw the angles? and the dashed lines? thank you!

\documentclass[a4paper,12pt]{article}[12pt] 



\usepackage{xcolor}

\usepackage{tikz}



\linespread{1.5}                    %spessore interlinea (default=1, MM1 = s1.4)



\frenchspacing 

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}

\usepackage{multicol}



  \usepackage[a4paper,top=1.3cm,bottom=1.3cm,left=1.5cm,right=1.5cm]{geometry}

  \usepackage{enumerate}

   \usepackage{multicol}

   \usepackage{textgreek}



\begin{document}



\begin{enumerate}


\item 


\begin{minipage}[t][][b] {6cm}
\end{minipage}%
\begin{minipage}[t][][b] {9cm}
\begin{tikzpicture}[> = stealth]
\draw[gray,step=1cm] (0,0) grid +(15cm,15cm);
    \draw[ultra thick,red]  (4,5) -- node[above] {} +(2,2);
  \draw[ultra thick,red]  (4,5) -- node[above] {} +(-1,2);
  %\draw[ultra thick,red]  (4,5) -- node[above] {} +(0,-3);
%  \draw[ultra thick,black]  (4,5) -- node[above] {} +(+3,0);
%  \draw[ultra thick,black]  (4,5) -- node[above] {} +(-3,0);




     \draw[ultra thick,black]  (9,8) -- node[above] {} +(+3,0);
      \draw[ultra thick,black]  (9,8) -- node[above] {} +(0,6);
       \draw[ultra thick,black]  (9,8) -- node[above] {} +(3,6);
%        \draw[ultra thick,black]  (9,14) -- node[above] {} +(3,0);
%         \draw[ultra thick,black]  (12,14) -- node[above] {} +(0,-6);




\end{tikzpicture}
\end{minipage}


%\item Determina le componenti in direzione orizzontale e verticale del vettore $ \vec{r} $, sapendo che: 
%
%%$ \abs{\vec{r}}= {r}= $ 5 e $ \alpha= $ 60°. 
%
%
%\begin{minipage}[t][][b] {6cm}
%   \begin{itemize}
%\item $ \abs{\vec{r}}= {r}= $ 5;
%\item $ \alpha= $ 60°.
%    \end{itemize}
%\end{minipage}%
%\begin{minipage}[t][][b] {9cm}
%\begin{tikzpicture}[> = stealth]
%%\coordinate (a) at (1,4);
%%\coordinate (b) at (3,5);
%%\coordinate (c) at (5,4);
%\coordinate (d) at (1,1);
%\coordinate (e) at (2,2.866025);
%%
%%
%%
%%\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);
%%
%%\draw [fill=green!30] (a) -- ++(1cm,0) arc(0:{atan(1/2)}:1cm) node[pos=1.2,right, above] {$\alpha$} -- cycle;
%%
%
%\draw [fill=green!30] (d) -- ++(0.5cm,0) arc(0:{atan(0.57735)}:0.5cm) node[pos=1.5,right, above]  {\Large $\alpha$} -- cycle;
%
%
%
%%\draw[ultra thick,red, ->]  (a) -- node[above] {\Large $\vec{c}$} (b);
%%\draw[ultra thick,blue,->]  (a) -- node[below left] {\Large $\vec{d}$} (c);
%\draw[ultra thick,red, ->]  (d) -- node[above left] {\Large $\vec{r}$} (e);
%\end{tikzpicture}
%\end{minipage}





%
%
%
%
%
%
%
%
%
%
%\item Determina le componenti in direzione orizzontale e verticale del vettore $ \vec{r} $, sapendo che: 
%
%%$ \abs{\vec{r}}= {r}= $ 5 e $ \alpha= $ 60°. 
%
%
%\begin{minipage}[t][][b] {6cm}
%   \begin{itemize}
%\item $ \abs{\vec{r}}= {r}= $ 5;
%\item $ \alpha= $ 60°.
%    \end{itemize}
%\end{minipage}%
%\begin{minipage}[t][][b] {9cm}
%\begin{tikzpicture}[> = stealth]
%%\coordinate (a) at (1,4);
%%\coordinate (b) at (3,5);
%%\coordinate (c) at (5,4);
%\coordinate (d) at (1,1);
%\coordinate (e) at (2,2.866025);
%%
%%
%%
%%\draw[gray,step=1cm] (0,0) grid +(9cm,6cm);
%%
%%\draw [fill=green!30] (a) -- ++(1cm,0) arc(0:{atan(1/2)}:1cm) node[pos=1.2,right, above] {$\alpha$} -- cycle;
%%
%
%\draw [fill=green!30] (d) -- ++(0.5cm,0) arc(0:{atan(0.57735)}:0.5cm) node[pos=1.5,right, above]  {\Large $\alpha$} -- cycle;
%
%
%
%%\draw[ultra thick,red, ->]  (a) -- node[above] {\Large $\vec{c}$} (b);
%%\draw[ultra thick,blue,->]  (a) -- node[below left] {\Large $\vec{d}$} (c);
%\draw[ultra thick,red,]  (d) -- node[above left] {\Large {r}} (e);
%\end{tikzpicture}
%\end{minipage}
%
%
%
%
%
%
%
%
%
%
%
%
%% Table generated by Excel2LaTeX from sheet 'Foglio1'
%\begin{table}[htbp]
%  \centering
%  %\caption{Add caption}
%    \begin{tabular}{rcccccc}
%    \toprule
%    \textbf{Esercizio} & \textbf{1} & \textbf{2} & \textbf{3} & \textbf{4}  & \textbf{TOT} \\
%    \midrule
%    \textbf{Punti} & 
%    \dots\dots/1.25 & 
%    \dots\dots/0.75 & 
%    \dots\dots/0.75 & 
%    \dots\dots/1.25 & 
%    \dots\dots/4.0 \\
%    \bottomrule
%    \end{tabular}%
%  %\label{tab:addlabel}%
%  \caption*{Punteggio minimo: 2/10 \qquad Punteggio per la sufficienza:  2.6/ 4.0}
%\end{table}%
1
  • 1
    epsfig is obsolete and ought not be used. Don't load packages twice. Once is enough or more than enough, in some cases.
    – cfr
    Jan 8, 2016 at 2:26

2 Answers 2

3

Here's an alternative solution with the package tkz-euclide, just for completeness.

Output

images

Code

\documentclass[a4paper]{article}
\usepackage{lipsum} % for the example, safe to remove
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\lipsum[1] % replaces text

\begin{figure}[!htb]
\centering
\begin{minipage}{.45\textwidth}
\centering
    \begin{tikzpicture}
    \tkzDefPoint(-2,0){L}
    \tkzDefPoint(-1,2){A}
    \tkzDefPoint(0,0){O}
    \tkzDefPoint(0,3){U}
    \tkzDefPoint(1,2){B}
    \tkzDefPoint(2,0){R}
    \tkzDefPoint(2,3){Y} 

    \tkzMarkAngle[draw=red!40, fill=red!40](R,O,L)
        \tkzLabelAngle[pos=1.2, color=red!40](A,O,L){$\alpha$}
        \tkzLabelAngle[pos=1.2, color=red!40](R,O,B){$\alpha$}
    \tkzMarkAngle[draw=blue!60, fill=blue!60](B,O,A)
        \tkzLabelAngle[pos=1.2, color=blue!60](U,O,A){$\beta$}
        \tkzLabelAngle[pos=1.2, color=blue!60](U,O,B){$\beta$}

    \tkzDrawSegments[thin, loosely dashed](L,R O,U A,B)
    \tkzDrawSegments[ultra thick](A,O O,B)

    \end{tikzpicture}
    \caption{image 1}
\end{minipage}
\begin{minipage}{.45\textwidth}
\centering
    \begin{tikzpicture}

    \tkzMarkAngle[draw=red!40, fill=red!40](Y,O,U)
        \tkzLabelAngle[pos=1.2, color=red!40](Y,O,U){$\gamma$}
    \tkzMarkAngle[draw=blue!60, fill=blue!60](R,O,Y)
        \tkzLabelAngle[pos=1.2, color=blue!60](R,O,Y){$\alpha$}

    \tkzDrawSegments(R,O O,U)
    \tkzDrawSegments[loosely dashed](U,Y Y,R)
    \tkzDrawSegment[ultra thick, arrows=->](O,Y)

    \end{tikzpicture}
    \caption{image 2}
\end{minipage}
\end{figure}

\lipsum[2] % replaces text
\end{document}
1
  • Very interesting! I will try to compile this code as soon as possibile. At the moment I am drawing the vectors and the angles with geogebra and I'm copying the code on texlive! ;)
    – ryuk
    Nov 30, 2015 at 19:41
5

Unfortunately your MWE can not be compiled ... so I from it made own:

Edit: to generate more compact presentation of angle and show the possible control of angle label positions by angle eccentricity, I slightly change original answer (delete all not used package, move both picture in line):

\documentclass[a4paper,12pt]{article}
    \usepackage{xcolor}
    \usepackage{tikz}
\usetikzlibrary{angles,calc,intersections,quotes}
    \usepackage[a4paper,top=1.3cm,bottom=1.3cm,left=1.5cm,right=1.5cm]{geometry}

    \begin{document}
    \begin{tikzpicture}[
              > = stealth,
   angle radius = 12mm,
my angle/.style = {draw, fill=#1,
                   angle eccentricity=1.2} % angle label position!
                       ]
\draw[gray,step=1cm] (0,0) grid +(15cm,7cm);
\coordinate (A0) at ( 9,1);
    \node   (Ay) at ( 9,7) [above] {$y$};
    \node   (Ax) at (12,1) [right] {$x$};
\coordinate (A)  at (12,7);

\path   (A0) edge[thick,->]     (Ax)
        (A0) edge[thick,->]     (Ay)
        (A0) edge[ultra thick]  (A)
pic [my angle=blue!30, "$\beta$"] {angle = Ax--A0--A}
pic [my angle=red!30, "$\gamma$"] {angle = A--A0--Ay};
\draw[dashed] (Ay.south) -| (Ax.west);
%
\coordinate (B0) at (4,4);
    \node   (By) at (4,6) [above] {$y$};
\coordinate (Bx1)at (2,4);
    \node   (Bx2)at (6,4) [right] {$x$};
\coordinate (B1) at (2,6);
\coordinate (B2) at (6,6);

\path   (Bx1) edge[thick,->]     (Bx2)
        (B0)  edge[thick,->]     (By)
        (B0)  edge[ultra thick]  (B1)
        (B0)  edge[ultra thick]  (B2)
pic [my angle=red!30, "$\alpha$"]    {angle = Bx2--B0--B2}
pic [my angle=blue!30, "$\beta$"]    {angle = B2--B0--By}
pic [my angle=blue!30, "$\beta$"]    {angle = By--B0--B1}
pic [my angle=red!30, "$\alpha$"]    {angle = B1--B0--Bx1};
    \end{tikzpicture}
    \end{document}

I hope, that I didn't omit in it something, what is essential to you. Enumeration, mini pages etc you can easily add. Also for changing of picture position you need only to adequately change/recalculate coordinates of pictures.

As you can see, for angles I use small pictures pic. For their use I add two packages: angles and quotes.

enter image description here

5
  • Thank you very much! I don't know why but there is an error. I can't find file `tikzlibraryangles.code.tex' ...kzlibrary{angles,calc,intersections,quotes} @Zarko
    – ryuk
    Nov 29, 2015 at 10:12
  • 1
    @ryuk As I told you earlier, those libraries were introduced in version 3 of TikZ, and if you're still on version 2 you would get that error. Nov 29, 2015 at 12:31
  • unfortunately I can't download it now.
    – ryuk
    Nov 29, 2015 at 14:22
  • @ryuk, just do as soon as possible. TikZ version 2 or 2.1 is really outdated. Benefits of version 3.0.1a is worth to effort for download.
    – Zarko
    Nov 29, 2015 at 14:27
  • 1
    @ryuk, I add small but significantly changes to my answer: the angle labels are now out of locus. In time of writing (unfortunately) I forgot on possibilities of angle eccentricity=... and use default values, which put labels (as many liked) inside of angle locus.
    – Zarko
    Jan 9, 2016 at 1:00

You must log in to answer this question.

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