2

I am trying to label the angles of a triangle. I can't figure out why my code is kicking the name to the outside. My apologies for any formatting issues; this is my first post here.

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[dot/.style={fill,circle,inner sep=1.5pt}]
\path
(80:5) node [dot,label=above left:A]{} coordinate (A)
(20:9) node[dot, label=right:B]{} coordinate (B)
(0:0) node[dot,label=below left:C]{} coordinate(C);

\path coordinate (Q)at((C)!(A)!(B)) node at (Q)[]{} ;

\draw[-] (A)--(C);
\draw[-] (C)--(B);
\draw[-] (A)--(B);
\draw[purple!70!black] (A)--(Q);

\tkzMarkRightAngle(A,Q,C);

\draw[|<->|] ((P)!−7mm!90:(B))--node[fill=white,sloped] {x} ((B)!−7mm!−90:(P));
\draw[|<->|] ((Q)!−4.9mm!90:(A))--node[fill=white] {10} ((A)!−3mm!−90:(Q));

\tkzMarkAngle[size=0.75cm,color=black,label=α];
\tkzMarkAngle[size=1cm,color=black,label=β];
\tkzMarkRightAngle(B,A,C);
\end{tikzpicture}
\end{document}

I am trying to fit $\beta$ inside the triangle instead of its current location. enter image description here

  • 2
    Hello and welcome. There are many syntax errors in your code. Start by correcting them. Notably the use of \usetkzobj{all} which is deprecated and breaks the code since the new version of tkz-euclide. Then you use the calc library of TikZ without respecting its syntax (you forgot the $). – AndréC Oct 20 at 19:10
  • 1
    Yeah I'm having various errors when trying to compile your code. I wouldn't be surprised if the angle mark fixed itself after fixing these errors. – Alenanno Oct 20 at 19:14
  • @Ben did you require pure tkz-euclide or a mishmash with tikz thrown in – js bibra Oct 20 at 23:45
1

After some efforting on your code, following output can be obtained.

\documentclass[margin=3mm]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
%\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[dot/.style={fill,circle,inner sep=1.5pt},>=stealth]
\coordinate (C) at (0,0) ;
\coordinate (A) at (80:5);
\coordinate (B) at (20:9) ; 
\node [dot] at (C) {};
\node [dot] at (A) {};
\node [dot] at (B) {};
\draw[-] (A)node[above]{A}--(C)node[left]{C};
\draw[-] (C)--(B)node[right]{B};
\draw[-] (A)--(B);
\coordinate (Q) at($(C)!(A)!(B)$) ;
\tkzMarkRightAngle(A,Q,C);
\draw[purple!70!black] (A)--(Q);
\draw[|<->|] ($(Q)!-4.9mm!90:(A)$)--node[fill=white] {10} ($(A)!3mm!90:(Q)$);
\draw[|<->|] ($(C)!-7mm!90:(B)$)--node[fill=white,sloped] {$x$} ($(B)!7mm!90:(C)$);
\tkzMarkAngle[size=0.75,draw = black, fill = white, opacity=1](Q,C,A)
\tkzLabelAngle[pos=1,font=\scriptsize](Q,C,A){$\alpha$}
\tkzMarkAngle[size=0.75,draw = black, fill = white, opacity=1](A,B,Q)
\tkzLabelAngle[pos=1,font=\scriptsize](A,B,Q){$\beta$}
\tkzMarkRightAngle(B,A,C);

\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
  • Can you explain why the angle marker was appearing outside of the shape? That way also future visitors can benefit from this answer. :) – Alenanno Oct 20 at 20:30
  • One can control the position the angle marker with pos. For example, if you give the value of pos as 0.5, the marker goes inside. – ferahfeza Oct 20 at 21:24
  • @Alenanno Given the amount of errors in the code, I'm surprised the OP got any output at all, it failed completely here ... Given that, I'm not sure it's possible to figure out why the beta ended up where it did. (You could make the label go outside with e.g. pos=-1, but that didn't seem to be the case here.) – Torbjørn T. Oct 21 at 12:22
  • @TorbjørnT. "it failed completely here" Same eheh I only asked the reason about the marker position because 1) I was curious, 2) It was the whole point of the question. If the answer is not yet available, it's ok, but I had to ask :D – Alenanno Oct 21 at 12:31
1

Using only pure tkz-euclide

enter image description here

\documentclass{article} % or another class
\usepackage{xcolor} % before tikz or tkz-euclide if necessary

\usepackage{tkz-euclide} % no need to load TikZ

\begin{document}
\begin{tikzpicture}[scale=1.0]
    %define points A,B,C
    \tkzDefPoint(0,0){C}
    \tkzDefPoint(20:9){B}
    \tkzDefPoint(80:5){A}
    %label point A,B,C
    \tkzLabelPoints(B,C)
    \tkzLabelPoints[above](A)
    %draw triangleABC
    \tkzDrawPolygon[thick,fill=yellow!15](A,B,C)
    %get line orthogonal to base CB
    \tkzDefPointsBy[projection=onto B--C](A){a}
    \tkzDrawSegment[dashed, red](A,a)
    %marking right angles    
    \tkzMarkRightAngle(A,a,C)    
    \tkzMarkRightAngle(C,A,B)
    %drawing dimension 10
    \tkzDrawSegment[style=red, dashed, dim={$10$,15pt,midway,font=\scriptsize, rotate=90}](A,a) 
    %marking the angles
    \tkzFillAngle[fill=blue!20, opacity=0.5](B,C,A)
    \tkzLabelAngle[pos=1.25](B,C,A){$\alpha$}
    \tkzMarkAngle(B,C,A)
    \tkzFillAngle[fill=red!20, opacity=0.5](A,B,C)
    \tkzLabelAngle[pos=1.25](A,B,C){$\beta$}
    \tkzMarkAngle(A,B,C)
    
    
        \tkzDrawPoints(A,B,C)

\end{tikzpicture}
\end{document}
| improve this answer | |
0

Using the code from Angle Label Issues, and commenting out the \draw that uses the undefined coordinate P, I can reproduce the problem with TeX Live 2019 (on Overleaf)

I first thought it was just a matter of using \tkzLabelAngle, but that gave initially the same, erroneous, result. Swapping the order of the coordinates, i.e. using (Q,B,A) instead of (A,B,Q) makes no difference either. In the new version of tkz-euclide, demonstrated in ferahfeza's answer, this works as expected, so if there was a bug, it has been fixed.

A workaround for the old version is to use a negative value for pos, in the options to \tkzLabelAngle:

\tkzMarkAngle[size=1cm,color=black](A,B,Q);  
\tkzLabelAngle[pos=-1.2](Q,B,A){$\beta$};  

enter image description here

\documentclass{standalone}  
\usepackage{tkz-euclide}  
\usetkzobj{all}  
\begin{document}  
\begin{tikzpicture}[dot/.style={fill,circle,inner sep=1.5pt}]  
\path  
  (80:5) node [dot,label=above left:$A$]{} coordinate (A)  
  (20:9) node[dot, label=right:$B$]{} coordinate (B)  
  (0:0) node[dot,label=below left:$C$]{} coordinate(C);  

\path coordinate (Q)at($(C)!(A)!(B)$) node at (Q)[]{} ;  

 \draw[-]  (A)--(C);  
 \draw[-] (C)--(B);  
 \draw[-] (A)--(B);  
 \draw[purple!70!black] (A)--(Q);  

\tkzMarkRightAngle(A,Q,C);  

%\draw[|<->|] ($(P)!-7mm!90:(B)$)--node[fill=white,sloped] {$x$} ($(B)!-7mm!-90:(P)$);  
\draw[|<->|] ($(Q)!-4.9mm!90:(A)$)--node[fill=white] {$10$} ($(A)!-3mm!-90:(Q)$);  

\tkzMarkAngle[size=0.75cm,color=black,label=a](B,C,A);  
\tkzMarkAngle[size=1cm,color=black](A,B,Q);  
\tkzLabelAngle[pos=-1.2](Q,B,A){b};  
\tkzMarkRightAngle(B,A,C);  
\end{tikzpicture}  
\end{document}  
| improve this answer | |

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.