jubobs / gitdags

A package for drawing educational Git history graphs
218 stars 29 forks source link

Applying [yshift] to a group of elements? #6

Open calvinpark opened 9 years ago

calvinpark commented 9 years ago

This is the graph I want to draw. screen shot 2015-10-02 at 3 13 53 pm

Since mytag sits above u1, u1 had to be shifted down. Since u1 has been shifted down, every element around it also had to be shifted down.

  \gitDAG[grow right sep = 1em]{
    m1 -- { m2 ,
            u1[yshift=-2em] -- u2[yshift=-2em],
            t1[yshift=-2em] -- t2[yshift=-2em]
          }
    };
  \gittag
    {mytag}       % node name and text 
    {above=of u1} % node placement
    {u1}          % target

Is there a better way to draw this graph, without applying yshift to every element?

Thank you

jubobs commented 9 years ago

I can't think of a very convenient way of reducing code duplication (yshift=-2em), in this case. The closest thing is to use branch down, as shown below:

screen shot 2015-10-04 at 11 53 51

\gitDAG[grow right sep = 1em, branch down = 5em]{
    m1 -- {m2 ,
            u1 -- u2,
            t1 -- t2
          }
   };
  \gittag
    {mytag}       % node name and text 
    {above=of u1} % node placement
    {u1}          % target
calvinpark commented 9 years ago

Thank you, that was helpful. It's too bad that there's no way to group elements.