0

There was a good answer about naming angles here: https://tex.stackexchange.com/a/55555/227339

I try to run it on my computer, but I get these errors:

enter image description here

As I understood, the problem is that name path=circle inside the scope is local, so I need to use name path global instead.

And yes, this code compiles and runs:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\newcommand\markangle[6][red]{% [color] {X} {origin} {Y} {mark} {radius} % filled circle: red by default \begin{scope} \path[clip] (#2) -- (#3) -- (#4); \fill[color=#1,fill opacity=0.5,draw=#1,name path global=circle] (#3) circle (#6mm); \end{scope} % middle calculation \path[name path=line one] (#3) -- (#2); \path[name path=line two] (#3) -- (#4); \path[% name intersections={of=line one and circle, by={inter one}}, name intersections={of=line two and circle, by={inter two}} ] (inter one) -- (inter two) coordinate[pos=.5] (middle); % bissectrice definition \path[% name path=bissectrice ] (#3) -- (barycentric cs:#3=-1,middle=1.2); % put mark \path[ name intersections={of=bissectrice and circle, by={middleArc}} ] (#3) -- (middleArc) node[pos=1.3] {#5}; }

\begin{document} \begin{tikzpicture} \coordinate[label=below left:$A$] (A) at (0,0); \coordinate[label=below right:$B$] (B) at (2,0); \coordinate[label=above:$C$] (C) at (5,5);

\draw[thick] (B) -- (A) -- (C) -- cycle;

\markangle{A}{B}{C}{$\beta$}{5} \markangle[blue]{B}{A}{C}{$\alpha$}{6} \markangle[green]{B}{C}{A}{$\gamma$}{12} \end{tikzpicture}

\end{document}

But if I'm right, name math global forces me to use unique path names through the entire document. That is really inconvenient inside large projects.

Then I remember: the original code from the answer doesn't have "global" option! It means, it can be compiled, but why do I get errors?

Allok
  • 405
  • 2
    I haven't tested it, but that question and the answers are from 2011-2012, so probably something has changed in TikZ in the past eight years that causes the code not to work anymore, whereas in 2012 it would have worked without problems. Package authors usually try to preserve the way old code worked when they release a new version, but it is not always possible/practical to keep full backwards compatibility. – Marijn Dec 01 '20 at 14:42
  • Path name circle you need (at least today, I don't remember if this was already a case in 2011) define globally because it is inside of scope. That is reason why the second example work as is desired. – Zarko Dec 01 '20 at 15:44
  • 1
    You do not need to have unique names of the paths over the document, i.e. nothing bad happens if you use circle in a later picture again for another path. Of course, if you use circle later without redefining it you may get funny intersections. –  Dec 01 '20 at 16:24
  • @TikZling, you mean that if I declared path "circle" globally, and then in one {tikzpicture} will declare another path named "circle", compiler will use the last definition? – Allok Dec 01 '20 at 16:55
  • 1
    @Allok Yes, precisely. Notice that all the node coordinates are global, too. –  Dec 01 '20 at 16:56
  • @TikZling, didn't know, thanks! But if I declared another path "circle", then used command "markangle" from the question, first path "circle" will be lost, the compiler will think about "circle" from "markangle", right? – Allok Dec 01 '20 at 16:59
  • @Allok Yes. If you declare one coordinate (A) and then another coordinate also named (A), the first one will be "lost", too. If you want to have unique names, you can introduce counter, but I am not sure what the benefit in this context would be. –  Dec 01 '20 at 17:02

0 Answers0