2

This is what I want to achieve.

enter image description here

And this is what I got so far.

enter image description here

I am not sure how to add length x at the top.

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

      \begin{tikzpicture}
        \tkzDefPoint(2,0){A}
        \tkzDefPoint(4,2){B}
        \tkzDefPoint(2,4){C}
        \tkzDefPoint(0,2){D}
        \tkzDefPoint(2,2){E}
        \tkzDrawPolygon[fill=gray!10](A,B,C,D)
        \tkzDrawSegment[dashed](D,B)
        \tkzDrawSegment[dashed](C,A)
        \tkzLabelSegment[left=4pt](E,C){$7$}
        \tkzLabelSegment[below=4pt](B,A){$10$}
        \tkzMarkSegments[mark=|,size=4pt](A,B B,C C,D A,D)
        \tkzMarkRightAngle(C,E,B)
        \foreach \Nodo in {B,D}
        \draw ([yshift=9pt]\Nodo) -- ([yshift=15pt]\Nodo);
        \draw[<->,>=latex] ([yshift=12pt]A) -- node[fill=white] {$x$} ([yshift=12pt]B);
     \end{tikzpicture}

\end{document}

1 Answer 1

3

The vertical rules from B and D can be drawn using

    \foreach \Nodo in {B,D}
      \draw[help lines] ([yshift=9pt]\Nodo) -- ++(0,2.2cm);

The acotation rule (not sure of the name in English) can be drawn with

    \draw[<->,>=latex] 
      ([yshift=2.3cm]B) -- node[fill=white] {$x$} ([yshift=2.3cm]D);

A complete example:

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

\begin{document}
      \begin{tikzpicture}
        \tkzDefPoint(2,0){A}
        \tkzDefPoint(4,2){B}
        \tkzDefPoint(2,4){C}
        \tkzDefPoint(0,2){D}
        \tkzDefPoint(2,2){E}
        \tkzDrawPolygon[fill=gray!10](A,B,C,D)
        \tkzDrawSegment[dashed](D,B)
        \tkzDrawSegment[dashed](C,A)
        \tkzLabelSegment[below left=2pt](E,C){$7$}
        \tkzLabelSegment[below right=2pt](B,A){$10$}
        \tkzMarkSegments[mark=|,size=4pt](A,B B,C C,D A,D)
        \tkzMarkRightAngle(C,E,B)
        \foreach \Nodo in {B,D}
          \draw[help lines] ([yshift=9pt]\Nodo) -- ++(0,2.2cm);
        \draw[<->,>=latex] 
          ([yshift=2.3cm]B) -- node[fill=white] {$x$} ([yshift=2.3cm]D);
        \end{tikzpicture}

\end{document}

enter image description here

2
  • What does ` ++(0,2.2cm)` do? Is it a length of line?
    – shin
    Commented May 6, 2014 at 3:33
  • @shin I already explained the meaning of ++ in a comment to an answer to other question of yours. ++(0,2.2cm) adds 2.2cm to the y-coordinate of the previous point. So, something like \draw (A) -- ++(0,2.2cm); draws a line from (A) to the point having the same x-coordinate as (A), but with y-coordinate equal to 2.2cm plus the y-coordinate of (A). Commented May 6, 2014 at 3:35

You must log in to answer this question.

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