2

I want to draw Euclid's parallel postulate together with angle markings that indicate where the lines will meet. My code:

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{calc, positioning, shapes, through, intersections}

\begin{document}

\begin{tikzpicture}
%\clip (1,0) rectangle (5,4);
%\draw[help lines] (0,0) grid (7,3);
\coordinate (A) at (0,0);
\coordinate (B) at (4,3.5);
\coordinate (C) at (-0.3,-0.3);
\coordinate (D) at (6,2);
\draw[blue,thick,name path=azul] (A) -- (B);
\draw[green, thick,name path=verde] (C) -- (D);
\draw[red,name path=roja] (0.5,4.5) -- (7,-1);
\path [name intersections={of=roja and azul}];
\coordinate (F) at (intersection-1)  {}; 
\path[name path=circ1,draw=gray,dashed] (F) circle (17pt);
\path [name intersections={of=azul and circ1}];
%%  \node[fill=black,circle,inner sep=0pt,minimum size=3pt] (f1) at (intersection-1) {};
%%  \node[fill=green,circle,inner sep=0pt,minimum size=3pt] (f2) at (intersection-2) {}; % These lines are just to visualize the intersection points and are not important
    \coordinate (f1) at (intersection-2) {};
\path [name intersections={of=roja and circ1}];
    \coordinate (f2) at (intersection-2) {};
    \begin{scope}
    \path[clip] (f2) -- (F) -- (f1) -- cycle;
     \node (alpha) [circle,draw,minimum size=5pt,label=below:{\tiny $\alpha$}] at (F) {};
    \end{scope}
\path [name intersections={of=roja and verde}];
\node (E) at (intersection-1) {};
\path[name path=circ2,draw=gray,dashed] (E) circle (17pt);
\path [name intersections={of=verde and circ2}];
    \coordinate (e1) at (intersection-2) {};
\path [name intersections={of=roja and circ2}];
    \coordinate (e2) at (intersection-2) {};
    \begin{scope}
    \path[clip] (e2) -- (E) -- (e1) -- cycle;
    \node (beta) [circle,draw,minimum size=3pt,label=left:{\tiny $\beta$}] at (E) {}; % % This doesn't get drawn!!!!
    \end{scope}

\end{tikzpicture}

\end{document}

For visual help I've drawn the circles that help me mark the angles (dashed, gray). However, angle $\beta$ won't appear. Here's the picture I get: Second angle won't appear

Any ideas of how to get the second angle mark? Thanks in advance!

  • Have you considered using the angle library? – cfr Mar 1 '16 at 3:34
  • I can't install it from the repos (I use Mint 17) and I can't seem to find the standalone *.code.tex file to place in my CWD. – Óscar Guajardo Mar 1 '16 at 5:26
  • label=left:{\tiny $\beta$} places label to the left of circle beta and \path[clip] (e2) -- (E) -- (e1) -- cycle; keeps only lower section and clips left one where label is placed. – Ignasi Mar 1 '16 at 9:08
  • Ah, you have an outdated version of PGF/TikZ, then. The angle library is part of it and not separate. The individual file would not work with a version of TikZ that old. – cfr Mar 1 '16 at 12:48
  • @Ignasi: placing the label elsewhere doesn't solve the problem; although my editor (TeXstudio) marks the label (as a little yellow rectangle) where it should be displayed, but wihtout displaying it. Apparently the editor "knows" what should be there but doesn't draw it. – Óscar Guajardo Mar 1 '16 at 15:54
4

I've simplified a little bit your code and now is faster because there's no need for computing circle-line intersections. You used them to fix a clipping area, but you already have coordinates which can define similar areas. Instead of (f2) -- (F) -- (f1) -- cycle you can use (A) -- (F) -- (E) -- cycle. Of course you need to know E before using it.

Now code is

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{calc, positioning, shapes, through, intersections}

\begin{document}

\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (4,3.5);
\coordinate (C) at (-0.3,-0.3);
\coordinate (D) at (6,2);
\draw[blue,thick,name path=azul] (A) -- (B);
\draw[green, thick,name path=verde] (C) -- (D);
\draw[red,name path=roja] (0.5,4.5) -- (7,-1);
\path [name intersections={of=roja and azul}];
\coordinate (F) at (intersection-1); 
\path [name intersections={of=roja and verde}];
\coordinate (E) at (intersection-1);
\begin{scope}
    \path[clip] (A) -- (F) -- (E) -- cycle;
     \node (alpha) [circle,draw,minimum size=5pt,label=below:{\tiny $\alpha$}] at (F) {};
\end{scope}
\begin{scope}
    \path[clip] (C) -- (E) -- (F) -- cycle;
    \node (beta) [circle,draw,minimum size=3pt,label=left:{\tiny $\beta$}] at (E) {}; % % This doesn't get drawn!!!!
\end{scope}

\end{tikzpicture}

\end{document}

and the result

enter image description here

Update: answer to comment.

Cyan triangle in following graph shows the area which is clipped with path (C) -- (D) -- (F)--cycle. Everything drawn inside this area is kept, therefore, the semicircle, and beta label.

enter image description here

And cyan triangle in next figure shows the area clipped by (C)--(E)--(F)--cycle which only keeps "left quadrant" and beta. I thought you wanted this one.

enter image description here

  • Nice approach but it doesn't print the beta angle, even if I comment out the code that draws alpha. I copied your code as is from your answer. If I replace (C) -- (E) -- (F) in the last scope with (C) -- (D) -- (F) it draws the full semicircle. Alas, the angle I want cannot get drawn! Any ideas? – Óscar Guajardo Mar 1 '16 at 15:50
  • @ÓscarGuajardo I've updated my answer trying to explain what happens. What I don't understand is which angle do you want to keep. Can you explain it? – Ignasi Mar 1 '16 at 19:00
  • Silly me! (E) was defined as a node, not as a coordinate. Thanks a lot @ignasi!!! – Óscar Guajardo Mar 1 '16 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.