rectangle-varignon.tex 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{tikz}
  3. \usetikzlibrary{shapes, calc}
  4. \begin{document}
  5. \begin{tikzpicture}
  6. % Define display style
  7. \tikzstyle{cross}=[cross out, draw, solid, red, inner sep=1.5pt, thick]
  8. \tikzstyle{diagonals}=[dashed, blue]
  9. % Define coordinates
  10. \newcommand\AX{0}
  11. \newcommand\AY{1}
  12. \newcommand\BX{3}
  13. \newcommand\BY{0}
  14. \newcommand\CX{4}
  15. \newcommand\CY{2}
  16. \newcommand\DX{1}
  17. \newcommand\DY{2}
  18. % Create shortcuts for coordinates and draw labels
  19. \coordinate[label=left:$A$] (A) at (\AX, \AY);
  20. \coordinate[label=right:$B$] (B) at (\BX, \BY);
  21. \coordinate[label=above:$C$] (C) at (\CX, \CY);
  22. \coordinate[label=above:$D$] (D) at (\DX, \DY);
  23. \coordinate[label=below:$E$] (E) at ({(\AX+\BX)/2}, {(\AY+\BY)/2});
  24. \coordinate[label=right:$F$] (F) at ({(\BX+\CX)/2}, {(\BY+\CY)/2});
  25. \coordinate[label=above:$G$] (G) at ({(\CX+\DX)/2}, {(\CY+\DY)/2});
  26. \coordinate[label=left:$H$] (H) at ({(\DX+\AX)/2}, {(\DY+\AY)/2});
  27. % Draw the rectangle
  28. \draw[blue, thick] (A) -- (B) -- (C) -- (D) -- (A);
  29. % Draw the background of the parallelogram
  30. \draw[blue, fill=green!25] (E) -- (F) -- (G) -- (H) -- (E);
  31. % Draw the diagonals
  32. \draw[diagonals] (A) -- (C);
  33. \draw[diagonals] (B) -- (D);
  34. % Draw the parallelogram itself
  35. \draw[blue] (E) -- (F) -- (G) -- (H) -- (E);
  36. % Draw the crosses for each edge
  37. \foreach \coordinateName in {A, B, C, D}
  38. \node[cross] at (\coordinateName) {};
  39. \foreach \coordinateName in {E, F, G, H}
  40. \node[cross, gray!50!black] at (\coordinateName) {};
  41. \end{tikzpicture}
  42. \end{document}