2

I have this \newcommand to draw an isosceles triangle, is there a way to alter this so instead of creating a point D and the circle AB to find C, use AB and an angle to get C and keep AB=AC.

\documentclass{article}

\usepackage{tkz-euclide}

\newcommand{\tri}[4]{%
\tkzDefPoint(0,0){A} 
\tkzDefPoint(#1,#2){B}
\tkzDefPoint(#3,#4){D}
\tkzInterLC(A,D)(A,B) \tkzGetPoints{X}{C}
\tkzDrawPolygon(A,B,C) 
\tkzLabelPoint[left](A){$A$} 
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[above](C){$C$}
}

%Diagram environment
\newenvironment{diagram}
{\stepcounter{CountDiag}\vspace*{10pt}
\begin{center}
\begin{tikzpicture}}
    {\end{tikzpicture}\vspace*{-5pt}\par Diagram~\theCountDiag
\end{center}}

\newcounter{CountDiag}
    
\begin{document}

\begin{diagram}
\tri{3}{0}{8}{4}
\end{diagram}

\end{document} 

Thanks

2 Answers 2

2

With a rotation (you can always calculate the angle)

\documentclass{article}   
\usepackage{tkz-euclide}

\newcommand{\tri}[3]{%
\tkzDefPoint(0,0){A} 
\tkzDefPoint(#1,#2){B}
 \tkzDefPointBy[rotation=center A angle #3](B)
       \tkzGetPoint{C}
\tkzDrawPolygon(A,B,C) 
\tkzLabelPoint[left](A){$A$} 
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[above](C){$C$}
}

    
\begin{document}

\begin{tikzpicture}
\tri{3}{0}{30}
\end{tikzpicture}

\end{document} 

enter image description here

Possible in some cases:

\tkzDefTriangle[two angles = 50 and 70](A,B)
\tkzGetPoint{C}

If angle(A) = 30 then angle(B)=angle(C) = 75 and \tkzDefTriangle[two angles = 30 and 75](A,B) answers the question.

3

Just for the isosceles triangle I like this minimalist code:

\documentclass[border=10pt]{standalone}
\usepackage{tikz} 

\begin{document}
    \begin{tikzpicture}
        \draw (0,0) node[left] {A}--(0:8) node[right] {B}--(30:8) node[above] {C}--cycle;   
    \end{tikzpicture}
\end{document}

Output:

enter image description here

4
  • Yes it's a minimalist code but if you have several dozen similar figures, this is not very practical. You have to modify the values inside the code, and if you change these values, it's quite possible that you'll have to change the label options. Dec 10, 2023 at 9:12
  • @AlainMatthes Yes Alain You are correct. In fact in my answer I say ' Just for the isosceles triangle' ... (one time). Dec 10, 2023 at 9:19
  • I agree with you. I loved working with TikZ and I still do, but when it came to writing my mathematics lessons, I needed a more suitable tool. Even more adapted, now, is the use of Lua and that simplifies everything as with my tkz-elements package for geometry. Dec 10, 2023 at 9:26
  • I have never used Lua, so my coding is probably very limited, I have gotten round the label options by just changing the LabelPoint(A){$A$} to LabelPoint(A){$#4$}. There is probably a better way but for the 10 or so times I need it per document this works.
    – Paul A
    Dec 10, 2023 at 13:27

You must log in to answer this question.

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