pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.15k stars 109 forks source link

Improve Euclid tutorial to use veclen(\p1) instead of veclen(\x1,\y1)? #1317

Open user202729 opened 7 months ago

user202729 commented 7 months ago

Brief outline of the proposed feature

As mentioned in the title. I think this could clean up the code.

Usage example

No response

### Tasks
muzimuzhi commented 7 months ago

One benefit of veclen(\x1,\y1) than veclen(\p1): the former indicates that veclen takes two arguments.

user202729 commented 7 months ago

That's true, but also worth mentioning that the user could do that.

It's a bit tricky though. Everything is done through macro expansion, so a function that "takes" coordinate argument actually just take two consecutive number arguments.

ilayn commented 7 months ago

a coordinate does not expand to two numbers, hence in that sense it is not a data structure. In the case of node, holds the name and then chooses by default the center anchor for convenience. Expanding \p1 does not seem to me a huge time saver here.

muzimuzhi commented 7 months ago

Currently the Euclid tutorial introduces \p1 as "\p<digit> yields the same as \x<digit>,\y<digit>". We could add some words like

"So practically veclen(\p1) is the same as veclen(\x1, \y1), but Euclid prefers the latter form to inform himself that veclen() takes two arguments."

https://github.com/pgf-tikz/pgf/blob/913d955f9a2f6693b0154311f0cdc94d68a45e84/doc/generic/pgf/pgfmanual-en-tutorial-Euclid.tex#L243-L262