6

I have this code:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz} 
\usetikzlibrary{matrix,decorations.pathreplacing}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}%[dot/.style={fill,circle,inner sep=1.5pt}]
\path
  (30:5) node [label=below right:$v_i\in M_2$,yshift={5pt}]{} coordinate (A)
  (30:7) coordinate (a)
  (-20:5) node [label=above right:$u_i\in M_1$,yshift={-10pt}]{} coordinate (B)
  (-20:7) coordinate (b)
  (0:0) node {} coordinate(P);

\path
  (0:0) node {}
coordinate(W)
  (90:4) node [label=left:$w_i$]{}
coordinate (Z)
  (90:6) coordinate (z);

\node (Q) at ($(P)!(A)!(B)$) {};
\node (R) at ($(P)!(B)!(A)$) {};

\draw[<->]  (P) -- (A);
\draw (P) -- (a);
\draw  (P) -- (b);
\draw[->] (P) -- (B);
\draw[->] (P) -- (Z);
\draw (P) -- (z);

\draw[purple!70!black,dashed] (A) -- (Q);
\draw[green!70!black] (B) -- (R);
\tkzMarkRightAngle(A,Q,P)
\tkzMarkRightAngle(B,R,P)

\tkzMarkAngle[size=0.75cm,color=cyan,label=$\theta$](B,P,A);
\end{tikzpicture} }
\end{document}

to get:

enter image description here

As you can see, the squares for right angles isn't appears good. There are something that I make bad? Any option or libraries is not necessary?

PD: I read A right-angle mark not displayed properly but the problem continues making %[dot/.style={fill,circle,inner sep=1.5pt}].

PD: I have another packages but it has nothing to do with this graphic.

PD: If some package is missing, sorry.

1 Answer 1

7

Don't use \nodes for Q and R; use \coordinates instead; a \node has an inner sep and outer sep which cause the problem.

enter image description here

The code:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz} 
\usetikzlibrary{matrix,decorations.pathreplacing}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}%[dot/.style={fill,circle,inner sep=1.5pt}]
\path
  (30:5) node [label=below right:$v_i\in M_2$,yshift={5pt}]{} coordinate (A)
  (30:7) coordinate (a)
  (-20:5) node [label=above right:$u_i\in M_1$,yshift={-10pt}]{} coordinate (B)
  (-20:7) coordinate (b)
  (0:0) node {} coordinate(P);

\path
  (0:0) node {}
coordinate(W)
  (90:4) node [label=left:$w_i$]{}
coordinate (Z)
  (90:6) coordinate (z);

\coordinate (Q) at ($(P)!(A)!(B)$);
\coordinate (R) at ($(P)!(B)!(A)$);

\draw[<->]  (P) -- (A);
\draw (P) -- (a);
\draw  (P) -- (b);
\draw[->] (P) -- (B);
\draw[->] (P) -- (Z);
\draw (P) -- (z);

\draw[purple!70!black,dashed] (A) -- (Q);
\draw[green!70!black] (B) -- (R);
\tkzMarkRightAngle(P,Q,A)
\tkzMarkRightAngle(P,R,B)

\tkzMarkAngle[size=0.75cm,color=cyan,label=$\theta$](B,P,A);
\end{tikzpicture}
\end{document}

As a side note, since you are loading tkz-euclide and using some of its features, you could use the package commands and features for most of the things you are doing directly with TikZ; for example, instead of

\coordinate (Q) at ($(P)!(A)!(B)$);
\coordinate (R) at ($(P)!(B)!(A)$);

you can use

\tkzDefPointBy[projection=onto P--B](A)
\tkzGetPoint{Q}
\tkzDefPointBy[projection=onto P--A](B)
\tkzGetPoint{R}
0

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.