5

enter image description here

How to shade a right triangle like in the picture?

Here's my code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{intersections}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{tikzpicture}[scale=2]
\coordinate [label=left:$\textcolor{white}A$] (A) at (1cm,-3cm);
\coordinate [label=below:$\textcolor{white}B$] (B) at (1cm,1cm);
\coordinate [label=below:$\textcolor{white}C$] (C) at (-4cm,1cm);
\node at (-3.4cm, .85cm) {$\textcolor{blue}{38^\circ}$};
\tkzMarkAngle[size=0.4cm,color=black,mark=](A,C,B)
\tkzMarkRightAngle[draw=red,size=.2](C,B,A);
\draw [thick=black] (A) -- node[right] {$\textrm{\textcolor{blue}{11}}$} (B) -- node[sloped,above] {$\textrm{\textcolor{blue}{x}}$} (C) -- node[sloped, above] {$\textrm{\textcolor{white}{hypotenuse = 82}}$} (A);
\end{tikzpicture}

\end{document}

Don't mind the text's in white; I use it when it's needed.

3 Answers 3

5

Another option. Only with TikZ and its library angles.

Then there is something wrong with the numbers, so I'm letting TikZ do the math for me.

This is the code:

\documentclass[border=6mm]{standalone}
\usepackage    {siunitx}
\usepackage    {tikz}
\usetikzlibrary{angles}
\sisetup       {output-decimal-marker={,}}

\begin{document}
\begin{tikzpicture}[scale=0.5,line join=round]
\def\yb{11}
\def\ac{38} % angle C
\pgfmathsetmacro\x{\yb/tan(\ac)}
\pgfmathsetmacro\h{\yb/sin(\ac)} % hypothenuse
\coordinate (A) at (0,0);
\coordinate (B) at (0,-\yb);
\coordinate (C) at (-\x,0);
\draw[thick,fill=blue!20] (A) -- node[right]        {\color{blue}$\yb$}
                          (B) -- node[sloped,above] {\color{white}hypotenuse = \num{\h}}
                          (C) -- node[sloped,above] {\color{blue}$x$} cycle;
% angles, with angles library
\draw[thick] pic [draw] {angle=B--C--A} node [below,xshift=1cm] at (C) {\ang{\ac}};
\draw[thick] pic [draw,angle radius=3mm] {right angle=B--A--C};
\end{tikzpicture}
\end{document}

An the output: enter image description here

5

Something like this? I am assuming that you know how to add the values of the angles.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{intersections}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{tikzpicture}[scale=2]
\coordinate [label=left:$\textcolor{white}A$] (A) at (1cm,-3cm);
\coordinate [label=below:$\textcolor{white}B$] (B) at (1cm,1cm);
\coordinate [label=below:$\textcolor{white}C$] (C) at (-4cm,1cm);
\node at (-3.4cm, .85cm) {$\textcolor{blue}{38^\circ}$};
\tkzMarkAngle[size=0.4cm,color=black,mark=](A,C,B)
\tkzMarkRightAngle[draw=red,size=.2](C,B,A);
\draw [thick=black, fill=white!80!blue] (A) -- node[right] {$\textrm{\textcolor{blue}{11}}$} (B) -- node[sloped,above] {$\textrm{\textcolor{blue}{x}}$} (C) -- node[sloped, above] {$\textrm{\textcolor{white}{hypotenuse = 82}}$} (A);
\end{tikzpicture}

\end{document}

enter image description here

6
  • How about the right angle ? Commented Sep 7, 2021 at 9:17
  • Simply a new \draw starting and ending in some points close to it. The precise values are up to your taste. Commented Sep 7, 2021 at 9:18
  • There is a code for right angle in my code but it's not present when I try to use your new code Commented Sep 7, 2021 at 9:22
  • Oh, indeed! They are covered by the previous blue colour, so moving \tkzMarkRightAngle[draw=red,size=.2](C,B,A); to the end makes it visible. Should I correct my answer or it is clear? Commented Sep 7, 2021 at 9:25
  • But if I code that one after the blue fill, it will overlap the black line. Commented Sep 7, 2021 at 9:28
4

My solution with automatically printing numbers.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line join=round,scale=.5,
declare function={c=11;ACB=38;a=c/tan(ACB);b=c/sin(ACB);}]
    
\path
(0,-c) coordinate (A) node[right]{$A$}
(0,0)  coordinate (B) node[right]{$B$}
(-a,0) coordinate (C) node[left]{$C$}
;
\fill[blue!10] (A)--(B)--(C)--cycle;
\draw[magenta] (B) rectangle +(-135:1);
\begin{scope}
\clip (A)--(C)--(B);
\draw[magenta] (C) circle(1.2) +(-ACB/2:2) node{$\pgfmathparse{ACB}\pgfmathprintnumber{\pgfmathresult}^{\circ}$};
\end{scope}

\draw[thick,nodes={magenta}] (A)
--node[right]{\pgfmathparse{c}\pgfmathprintnumber{\pgfmathresult}} (B)
--node[above,blue]{$a\approx$ \pgfmathparse{a}\pgfmathprintnumber[precision=3]{\pgfmathresult}} (C)
--node[sloped,above,blue]{hypothenus $b \approx $ \pgfmathparse{b}\pgfmathprintnumber[precision=3]{\pgfmathresult}} cycle;
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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