Text: have an option to specify anchor position of text box

jdgilbey shared this idea 9 years ago
Completed

I wondered how to label an axis-like object, and rami kindly showed me a solution:

https://www.geogebra.org/fo...


Two significant downsides with this is the complexity of the labelling method and that the text has to be rendered via LaTeX; this makes the minus signs unfortunately look fuzzy (something perhaps to do with using image fonts or something like that?). And even with this, getting the alignment correct is a bit of a game - I've figured that on my screen, I have to shift the box 3 pixels to the right from centre because of the way that Geogebra places a Text[] when the content is a TableText.


Far simpler and more general would be to have an option for the Text[] function which specifies where the anchor is. At present, Text["x", (1,2)] places the text box so that the left end of the baseline is at (1,2); similarly, Text["jx",(1,2)] has the descender of the "j" going below y=2. What I would suggest/request is an extension of the Text[] command to offer something like the following if a fifth parameter is given (so that it does not break any existing geogebra files):


Text[ <Object>, <Point>, <Boolean for Substitution of Variables>, <Boolean for LaTeX formula>, <Anchor location> ]

where <Anchor location> specifies where the text box is in relation to <Point> as a two-letter string: the first letter is "l", "c", "r" specifying the left, centre or right of the text box; the second letter is "b", "l", "c", "t" specifying the baseline, lower edge, centre or top edge of the the text box. For example:

"lb" = <Point> is at left end of baseline (default)

"ll" = <Point> is at left lower corner of the text box

"ct" = <Point> is at centre top of the text box

"cc" = <Point> is at the centre of the text box


In that way, specifying that a label should be centred immediately below the point (1,2) would be:

Text["x", (1,2), false, false, "ct"]


The current solution, as demonstrated in that thread, involves setting up a sample text box using a TableText, measuring its size, and then placing the label at a position relative to (1,2) calculated from this sample text box.


What are people's thoughts on this?


Thanks for listening,


Julian

Comments (6)

photo
1

I now think the need is even greater than I did yesterday: it turns out that when the Geogebra file is uploaded to GeogebraTube, the alignment is out by so many pixels that the y-axis labels appear on top of the axis rather than next to it, rendering them unreadable. My proposed solution should solve this problem in a clean way.

photo
1

I fully agree. I have a dire need of placing a text box relative to its centre (or sometimes relative to the centre of one side) rather than a point on its edge. I would put this request at the very top of my needs when using geogebra. I have been struggling to create a protractor as you can see in the attached file and all the labels are out of place even though I have tried hard to compensate for their size, rotation angle etc...

If the requested feature were to be implemented I'd be extremely happy.

Massimo


Massimo

photo
1

New syntax

Text( <Object>, <Point>, <Boolean for Substitution of Variables>, <Boolean for LaTeX formula>, <Horizontal alignment [-1|0|1]>, <Vertical alignment [-1|0|1]> )

photo
1

Thank you very much for the quick reply. Are there the same options for RotateText ?

photo
photo
1

Genial!!! GRACIAS

y la posición centrada con ayuda de un \phantom y un rotate es fabulosa

Files: foro.ggb
© 2023 International GeoGebra Institute