1

How can I get the text of a previously drawn nodes?

In https://tex.stackexchange.com/a/40851/49283 I read how one can access the current text width.

I also found out that \pgfpointanchor{mynode}{east} gives me the coordinate of an anchor.

How can I other other attributes from a node? What is the general approach?

I am especially interested in getting the text of a node.

EDIT: Solution

I solved the issue with a workaround: Tikz: Saving text/content from node

1

For the node contents....

Short answer : You can't (almost impossible).

Long answer : TikZ don't keep track of the node contents. It instead passes the content to a hbox or a minipage and measures its size. After placing it, the box is unprotected meaning that its continuously overwritten; if you have 3 consecutive node commands you can only reach to the last one if possible at all. You need to assign the content specifically to the shape name which is not only very tedious but also boring.

But if the clever clever people here come up with a simpler hack, I'm all ears.

  • Could I not reach out to the text of the last node, put it into a variable, get on with my life and then get the text later on? This would be done in a style, so it's all automated anyway. So, how could I do this? – Make42 Dec 9 '15 at 10:15
  • @user49283 Save the text and use it multiple places instead. – percusse Dec 9 '15 at 10:19
  • That is not possible after all. What I want to do is this: tex.stackexchange.com/questions/282163/… - which I nearly solved. All I need to do now is to redraw the original body text. – Make42 Dec 9 '15 at 10:21
  • @user49283 Use the tcolorbox package. It has everything you need and much more – percusse Dec 9 '15 at 10:22
  • Fair enough, I will check it out. However it is also a good learning example ;-). – Make42 Dec 9 '15 at 10:29

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.