4

I fail to understand what the default unit of measure is for TikZ's angle radius option of the angles TikZ library. By "default unit of measure" I mean the one used when no unit is specified explicitly. For example, under "normal" circumstances TikZ will process the instruction \draw (0,0) -- (2,1); by drawing a rectangle 2cm in length and 1cm in height, because \draw's default unit of measure is 1cm, so when no unit is specified explicitly, the cm unit is used. This is true in general in TikZ, however the following LaTeX code demonstrates that this is not the case as far as the angle radius option is concerned.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}
   \coordinate (a) at (1,0);
   \coordinate (b) at (0,0);
   \coordinate (c) at (0,1);

   \draw (a) -- (b) -- (c);

   \draw pic [draw, angle radius = 1cm] {angle=a--b--c};

   \coordinate (d) at (3,0);
   \coordinate (e) at (2,0);
   \coordinate (f) at (2,1);

   \draw (d) -- (e) -- (f);

   \draw pic [draw, angle radius = 1] {angle=d--e--f};
\end{tikzpicture}
\end{document}

This produces (in Overleaf, using the 2022 LuaLatex engine)

The angle radius option with and without explicit units

For the left hand figure explicit units were specified, but for the right hand figure the units were not specified explicitly.

Why is the right hand figure different to the left hand one? Why wasn't cm taken as the default unit, as is the norm in TikZ pictures? Is this a bug in TikZ? How is it possible to configure TikZ in such a way that the angle radius option will use as its default unit of measure whatever unit is used by the TikZ picture in which the angle radius option occurs?


EDIT: I have opened a ticket about this issue in the PGF/TikZ bug tracker.

5
  • angle radius = 1 = angle radius = 1pt
    – Zarko
    Feb 8 at 6:38
  • @Zarko Oh, I see. Thanks. Is there a way to make sure the angle radius adjusts automatically to scaling of the TikZ picture and to changes to the TikZ picture's x and y units?
    – Evan Aad
    Feb 8 at 6:43
  • Actually, this is interesting and probably something that should be addressed in future updates of the library, because the modern notation for circle or arc uses the option radius where 1 means 1 basic unit (being 1cm by default). Feb 8 at 8:18
  • @JasperHabicht Also the canvas polar coordinate system uses cm as the default unit, e.g. (90:1) is the point that is 1cm above the origin.
    – Evan Aad
    Feb 8 at 8:41
  • Yes, but I think the problem is more relevant for radius and angle radius, which are both options and therefore look very similar to the user. So, it is likely that the user expects that 1 passed to these two options would result in somewhat similar results. Feb 8 at 8:44

1 Answer 1

4

As noted in the comments already, 1 as unitless value passed to angle radius will be interpreted by the library as 1pt.

This is actually an interesting find, because the modern notation for circle and arc is very different in that the option radius that can be used for both (and probably looks quite similar to angle radius to the user) does not interpret 1 as 1pt but as 1 * <basic unit> which is 1cm by default. I think this is an unlucky inconsistency which is probably due to the different ways the angles library and the modern notation for circle and arc have developed. I personally think that it should become unified. (Of course, it might not be straght-forward to unify this behaviour, because the x and y base units may differ resulting in elliptical arcs, which is probably not wanted for the angles library. So somehow one would have to decide whether to use the x or the y base unit, or to accept that the arc for the angle pic can be elliptical.)

Anyways, you can extract the length of the basic x and y units easily unsing \pgfpointxy{1}{1} \pgfgetlastxy{\baseunitx}{\baseunity} for further use:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles}

\begin{document}
\begin{tikzpicture}
    \coordinate (a) at (1,0);
    \coordinate (b) at (0,0);
    \coordinate (c) at (0,1);
    
    \draw (a) -- (b) -- (c);
    
    \draw pic [draw, angle radius = 1cm] {angle=a--b--c};
    
    \coordinate (d) at (3,0);
    \coordinate (e) at (2,0);
    \coordinate (f) at (2,1);
    
    \draw (d) -- (e) -- (f);

    \pgfpointxy{1}{1}
    \pgfgetlastxy{\baseunitx}{\baseunity}

    \draw pic [draw, angle radius = {1 * \baseunitx}] {angle=d--e--f};
\end{tikzpicture}
\end{document}

enter image description here

2
  • To me, it is unclear what OP means with "default unit of measure conforms to the TikZ picture". Default radius size is, of course according to my opinion, select so small, that can be adopted to any coordinates distance longer than 1pt. So, there is no inconsistency, but if OP doesn't like (deliberate select) this base unit, it can change as you suggest.
    – Zarko
    Feb 8 at 10:38
  • Well, what I mean with "inconsistency" is, that when you use a notation like \draw circle[radius=1]; the radius of the circle will not be 1pt, but it will be 1 <base unit> which is 1cm by default. I am not sure, though, whether this is also what the OP meant. Of course, you can argue that it is not inconsistent at all, because the angle library just does not work like this and uses other internal logics. Feb 8 at 10:46

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.