# [Tex/LaTex] How to add length and right angle to triangle

tikz-pgf

The following creates a triangle.

Q1. How can I add lengths such as 5cm, 6cm and xcm for each side.

Q2. How can I add a right angle sign to A?

 \item[b)]
\begin{tikzpicture}
% Draw the triangle
\draw[fill=gray!10]  (0, 0) coordinate (A)
-- (0,5) coordinate (C)
-- (6,0) coordinate (B)
-- (0, 0);

% Draw nodes
\node at (A)[anchor=north] {A};
\node at (B)[anchor=north] {B};
\node at (C)[anchor=south] {C};
\end{tikzpicture}


One option:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
% Draw the triangle
\draw[fill=gray!10]  (0, 0) coordinate (A)
-- node[left] {$3$\,cm} (0,5) coordinate (C)
-- node[above right] {$5$\,cm} (6,0) coordinate (B)
-- node[below] {$4$\,cm}  (0, 0);
\draw (0,10pt) -- ++(10pt,0) -- ++(0,-10pt);
% Draw nodes
\node at (A)[anchor=north] {$A$};
\node at (B)[anchor=north] {$B$};
\node at (C)[anchor=south] {$C$};
\end{tikzpicture}

\end{document}


Using a brace decoration, you could add braces to the sides to indicate the lengths:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}
% Draw the triangle
\draw[fill=gray!10]  (0, 0) coordinate (A)
-- (0,5) coordinate (C)
-- (6,0) coordinate (B)
-- (0, 0);
\draw[decoration={brace,mirror,raise=2pt},decorate]
(A) -- node[below=4pt] {$4$\,cm} (B);
\draw[decoration={brace,mirror,raise=2pt},decorate]
(B) -- node[above=4pt,sloped] {$5$\,cm} (C);
\draw[decoration={brace,mirror,raise=2pt},decorate]
(C) -- node[left=4pt] {$3$\,cm} (A);

\draw (0,10pt) -- ++(10pt,0) -- ++(0,-10pt);
% Draw nodes
\node at (A)[anchor=north] {$A$};
\node at (B)[anchor=north] {$B$};
\node at (C)[anchor=south] {$C$};
\end{tikzpicture}

\end{document}