I have two unaligned nodes



and I want to have the node with the B aligned to the left of the node with AAAs and below it



How can this be done?

  • 1
    Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. – Martin Scharrer Mar 16 '11 at 20:56
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). Otherwise please state what is missing so that people can help you better. – Martin Scharrer Dec 7 '11 at 10:05

You can position "B" below and left of "AAA" without having to know the position of it using the positioning library:



    \node [draw] (A) at (4,5) {AAAA};
    \node [draw,below=of A.west,anchor=west] (B) {B};



| improve this answer | |
  • 2
    Note that you can change the distance by adding a value before of, e.g. below=2cm of A. – Martin Scharrer Mar 16 '11 at 22:29
  • Thanks, your examples helped me to understand the workings of anchor: it makes a node's anchor point (north, east, ...) coincide with the node's position point (defined with "at (x,y)", "below=of p", etc). – Mário Mar 17 '11 at 9:33
  • 1
    For example, using \begin{tikzpicture}[node distance=5mm] \node[draw, anchor=west] (1) {AAAAAAAA}; \node[draw, below=of 1.south west, anchor=north west] (2) {B}; \end{tikzpicture} we can left align the two nodes and have a precise distance of 5mm between them. Thanks a lot. @MichaelUmmels – Mário Mar 17 '11 at 9:49
  • 4
    Important note: one must use below=of A.west, anchor=west (which is what Martin has written) not anchor=west, below=of A.west (which looks just as good, but seems not to work). – John Wickerson Mar 13 '15 at 15:22
  • @MartinScharrer Why does placing anchor=west after below instruction works, but not the other way around? (Just like John pointed out in the comment above) – Andriy Drozdyuk Nov 19 '16 at 18:03

Use anchor=west for both nodes. For example:

\node[anchor=west] (1) at (0,1) {AAAAAAAA};
\node[anchor=west] (2) at (0,0) {B};
| improve this answer | |
  • Thanks, I understand now: you are placing the west anchors of two nodes at two vertically aligned points. That does the trick, the only limitation is that if the top node increases its heigth you have to move the point of the second node further below. To avoid this the second node could be placed using "below=of 1.south west". – Mário Mar 17 '11 at 9:42
  • Yes, I agree that Martin's solution (inlcuding node distance) is more flexible. – Michael Ummels Mar 17 '11 at 10:14

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.