# Vertical alignment

**URL:** <https://forum.graphviz.org/t/vertical-alignment/1966>\
**Category:** Help\
**Created:** [January 9, 2024, 6:50pm UTC](https://forum.graphviz.org/t/vertical-alignment/1966 "2024-01-09T18:50:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fsalvi](https://avatars.discourse-cdn.com/v4/letter/f/ac91a4/32.png) [@Fsalvi](https://forum.graphviz.org/u/Fsalvi)\
**Post date:** [January 9, 2024, 6:50pm UTC](https://forum.graphviz.org/t/vertical-alignment/1966/1 "2024-01-09T18:50:22Z")

</div>

Hello everybody. This question will sound silly to someone, but I’m not experienced enough to solve it.  
I need to vertically align some nodes (in the example they are named a, b, c and d).  
Another node has to be but aside of one of them without distorting the vertical arrangement.  
The minimal script is:

digraph {

```
rankdir="LR"
//rankdir="TB"

//main nodes
a
b
c
d

//let nodes lay vertically in a nice column
a->b->c->d

//secondary node
secondary [style=filled fillcolor=yellow]
{rank = same; a; b; c; d}
b->secondary

//all is good until here when using rankdir="LR"
//unfortunately rankdir="TB" is required by other graph elements

// I would like the yellow node to sit politely on the side the "c" node 
//without messing with the {a, b, c, d} perfect vertical alignment
//using just DOT engine

```

}

I’ve tried several solutions, but the vertical alignment always gets distorted: what solution am I missing? Thanks

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [January 9, 2024, 10:19pm UTC](https://forum.graphviz.org/t/vertical-alignment/1966/2 "2024-01-09T22:19:26Z")

</div>

Here you go,

- no guarantees on **a b c d** , but should stay vertical
- **b secondary** will stay nailed to same rank

```auto
digraph V {
rankdir="TB"

// main nodes
// let nodes lay vertically in a nice column
{
  node [group=xyz] // not required, but it may help as you add nodes
  a->b->c->d
}
secondary [style=filled fillcolor=yellow]
{ rank=same
    b->secondary
}
// I would like the yellow node to sit politely on the side the "c" node 
//without messing with the {a, b, c, d} perfect vertical alignment
//using just DOT engine
}

```

---

<div class="post-metadata">

**Author:** ![Fsalvi](https://avatars.discourse-cdn.com/v4/letter/f/ac91a4/32.png) [@Fsalvi](https://forum.graphviz.org/u/Fsalvi)\
**Post date:** [January 10, 2024, 8:59am UTC](https://forum.graphviz.org/t/vertical-alignment/1966/3 "2024-01-10T08:59:34Z")

</div>

Great! I was sure to be missing something.  
Simply I didn’t think about imposing “rank=same” to and edge.  
Many thanks.

F
