3

enter image description here

I am trying to replicate this figure in latex. Obviously, it is quite easy to do it in Geogebra... but I was wondering if there is a special package we can use to do this sort of figures in latex. Many thanks in advance.

6
  • What is given (a,b,theta,c,d) / what is searched? That's helpful for the construction.
    – cis
    Commented Sep 5, 2020 at 4:24
  • nothing, all are variables that can take any value (as possible) Commented Sep 5, 2020 at 4:27
  • wiki.geogebra.org/en/… Commented Sep 5, 2020 at 4:44
  • @JimmySabater you can use tikz and tz-euclide also
    – js bibra
    Commented Sep 5, 2020 at 5:00
  • If nothing is given or searched, the task is quite unspectacular as it is all about creating the image. You can do this with the commands \coordinate for the corners, \draw for the edges and the library angles for the angles, all of which can be found in the TikZ manual. The whole thing becomes interesting when it is a construction, but then one has to know what is given and what is searched.
    – cis
    Commented Sep 5, 2020 at 5:06

2 Answers 2

9

I assume that a, b, theta are given.
Then like that:

enter image description here

€dit: With the 'sharp right angle', which you want:

\draw pic [draw, angle radius=3mm, 
angle eccentricity=0.5, "$\cdot$",
] {right angle =C--P--D};

Note, that you can comment out angle eccentricity=0.5, "$\cdot$" if you do not want an inner dot.

\documentclass[margin=5pt, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{angles, quotes, babel}
\usepackage{amsmath, amssymb}

\begin{document}
\pgfmathsetmacro{\a}{4} %  
\pgfmathsetmacro{\b}{2.5} %  
\pgfmathsetmacro{\thetaA}{33} %  

\pgfmathsetmacro{\x}{\a*tan(\thetaA)} %  
\pgfmathsetmacro{\y}{\b/tan(\thetaA)} %  

\begin{tikzpicture}[%scale=0.7,
font=\footnotesize,
>={Triangle[length=0pt 9,width=0pt 4]}
]
\coordinate[label=left:$A$] (A) at (0,0); 
\coordinate[label=below:$B$] (B) at (\x+\y,0); 
\coordinate[label=left:$D$] (D) at (0,\a); 
\coordinate[label=below:$P$] (P) at (\x,0); 

\draw[] (A) -- (D) node[midway, left]{$a$};
\draw[] (A) -- (P) node[midway, below]{$x$};
\draw[] (P) -- (B) node[midway, below]{$y$};
\draw[] (B) -- +(0,\b) coordinate[label=right:$C$](C) node[midway, right]{$b$};

\draw[] (D) -- (P) node[midway, above]{$c$};
\draw[] (C) -- (P) node[midway, above]{$d$};
\draw[] (C) -- (D);

%% Angles
\draw pic [draw, angle radius=7mm, %angle eccentricity=1.3,
"$\theta$", ->
] {angle =A--D--P};
\draw pic [draw, angle radius=8mm, %angle eccentricity=1.3,
"$\theta$", ->
] {angle =P--D--C};
\draw pic [draw, angle radius=7mm, %angle eccentricity=1.3,
"$\theta$", ->
] {angle =B--P--C};
    
\draw pic [draw, angle radius=3mm, 
angle eccentricity=0.5, "$\cdot$",
] {right angle =C--P--D};
\draw pic [draw, angle radius=3mm, 
angle eccentricity=0.5, "$\cdot$",
] {right angle =P--A--D};
\draw pic [draw, angle radius=3mm, 
angle eccentricity=0.5, "$\cdot$",
] {right angle =C--B--P};

%% Points
\foreach \P in {P} \draw[fill=black!1] (\P) circle (1.75pt);

%% Annotations
\path[local bounding box=figure] (A) -- (B) -- (C) -- (D) --cycle;
\node[yshift=-5mm, draw, align=left, fill=lightgray!50,
anchor=north west,  % text width=\x cm+\y cm,
] at (figure.south west) {
$\begin{array}{l l}
a = \a \text{ cm}  &  \\
b = \b \text{ cm}  & \\ 
\theta = \thetaA^\circ   &  \\ \hline \\%[0.1em]
x = a\cdot\tan(\theta)   &  =\x  \text{ cm}    \\ 
y = \dfrac{b}{\tan(\theta)}   &  =\b \text{ cm} \hspace{2.0cm}\\
\end{array}$
};
\end{tikzpicture}
\end{document}
2
  • thanks!!!!!!!!!! Commented Sep 5, 2020 at 15:51
  • I overseen that there is a Pic type right angle (TikZ-manual, p. 569). Maybe since a newer version.
    – cis
    Commented Oct 1, 2020 at 3:54
3

For fun, a pstricks code that mimicks a construction with ruler and compass on a sheet of paper:

\documentclass[12pt, border=6pt, svgnames]{standalone}
\usepackage[upright]{fourier} 
\usepackage{pst-eucl}

\begin{document}

\begin{pspicture}(-0.1,-0.1)(5.2,4)
\psset{linestyle=none, PointSymbol=none, PointName=none}%
\pstGeonode(0,0){O}(0,4){B}(8,0){A}
\pstBissectBAC{O}{B}{A}{X} \pstInterLL{B}{X}{O}{A}{C}
\pstSymO{C}{B}[B1]
\pstMediatorAB{B}{B1}{C}{Y}\pstInterLL{A}{B}{C}{Y}{D}
\pstProjection{O}{A}{D}[E]
\psset{linestyle=solid, linejoin=1, linecolor=Coral}
\pspolygon(O)(B)(D)(E)
\psline(B)(C)(D)
%%angles
\psset{linecolor=black, linewidth=0.5pt}
\pstRightAngle[RightAngleSize=0.25]{B}{C}{D}
\psset{arrows=->,arrowinset=0.12, MarkAngleRadius=0.7}
\pstMarkAngle{C}{B}{D}{$\theta$}
\pstMarkAngle[MarkAngleRadius=0.8]{O}{B}{C}{$\theta$}
\pstMarkAngle{E}{C}{D}{$\theta$}
\end{pspicture}

\end{document} 

enter image description here

You must log in to answer this question.

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