Given an arbitrary point, let's say p, that may or may not be obtained by several indirect processes such as penpos or by intersections, how do I get to display the coordinates "(px,py)" of the point in the pdf generated ? when I don't have those coordinates to beguin with ? I remember having done this once already, but I forgot how to do it.

  • Try z1 = p; Then x1 and y1 will hold the values you are looking for. You can use a label to display them in the PDF. – TeXnician Sep 14 '19 at 20:55
  • That doesn't do it for me, I really need the value of the coordinates of the point, not just to use the point. – Felipe Dilho Sep 15 '19 at 2:42
  • That doesn't seem to work in my code: – Felipe Dilho Sep 15 '19 at 3:08
  • z23=(-1.272cm,-3.053cm); z24=(-1.12cm,-2.148cm); z25=(-1.2405cm,-1.6084cm); z3=(-1.072cm,0cm); z27=(-1.011cm,0.468cm); z26=(-1.296cm,-0.331cm); penpos23(0.25cm,70.2567+90); penpos24(0.7cm,-87.3949-90); penpos25(0.8cm,-66.3078-90); penpos26(1.07cm,77.13501+90); penpos3(1.24cm,21.801); penpos27(1.1294cm,64.09569+78); z111=(precontrol 5 of (z23l..z24l..z25l..z3r--z27..z26..z25..z24..z23--cycle)); label.bot(TEX decimal(x111) ,(10,20)); – Felipe Dilho Sep 15 '19 at 3:08
  • In the log it says that there is a `,' missing. – Felipe Dilho Sep 15 '19 at 3:09

Given a pair p, the two values are available as xpart p and ypart p.

To make a string representation of the pair try:

"(" & decimal xpart p & "," & decimal ypart p & ")"

You can then type set that string as usual with infont or the TEX() macro.

 label.bot(TEX("$(" & decimal xpart p & "," & decimal ypart p & ")$"), (10, 20));

This is rather less cumbersome if you use the built-in plain shorthand notation for pairs. So given a pair variable z1, the two values are available as x1 and y1. And you can make a string representation as

 "(" & decimal x1 & "," & decimal y1 & ")"

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.