Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I produce automatically generated LaTeX-files with nodes and links.

Is it possible to put the label of the node outside of the node and it is automatically positioned somewhere, such that there is no line crossing it?

I know I can position the label by hand:

\node[label= above right: N-1](N-1) at (0.0,2.0){ };

But this it not what I want, since sometimes there could be a line right there.

Does anyone have any idea?

share|improve this question
    
Welcome to TeX.sx! Personally I don't think there is a way that LaTeX or TikZ can do this automatically. It's not smart enough to take other material into account. You would write own code in your automation script to handle this. –  Martin Scharrer Apr 18 '12 at 12:32
    
You could take a look at Automatically connect nodes without overlapping other nodes or connections and Automatically avoid more than one node when drawing a path. Adapting this for label placement wouldn't be trivial, however. –  Jake Apr 18 '12 at 12:35
    
Exactly, in your case the label text is empty for the node (N-1), with label= above right: N-1 you create a new node (in the pgfmanual this node is designed by label node). I think it's difficult to know if your new node could be on a line because it depends of the size of the label node and you need to create a tool to know if there is something drawn where you want to place the label. I'm not very optimistic about existence of such kind of tool ! –  Alain Matthes Apr 18 '12 at 13:56

1 Answer 1

up vote 5 down vote accepted

No, in the general case it's not possible to automatically place a label in a way so that it doesn't overlap anything. TikZ is simply just not smart enough to check for collisions. Programming something like this with TeX would be very complicated for the general case. It might be possible to have something for a very limited case.

If you produce your LaTeX pictures automatically using some script then I would do the collision checks using the scripting language, which is better suited for this. However, even with that it is absolutely not trivial.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.