jubobs / gitdags

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

Adjust Distance between nodes #5

Closed amacgregor closed 9 years ago

amacgregor commented 9 years ago

Is there a way to set a custom distance between nodes? I'm using the following code:

  \begin{subfigure}[c]{\textwidth}
    \centering
    \begin{tikzpicture}
      % Commit DAG
      \gitDAG[grow right sep = 2em]{
        M5[DAGedge] -- M6 -- M7 -- {
        M7 -- M8,
        M7 -- F1 -- F2 -- F3 -- F4 -- M8,
        }
      };
      \gitbranch
        {master}      % node name and text
        {above=of M7} % node placement
        {M7}
      \gitHEAD
        {above=of master} % node placement
        {master}          % target
      \gitbranch
        {feature}      % node name and text
        {below=of F4} % node placement
        {F4}
    \end{tikzpicture}
    \subcaption{\ldots{} we sync our local feature branch \texttt{git rebase master}}
  \end{subfigure}

Which generates the attached graph:

screenshot 2015-07-10 09 09 31

However the alignment is not correct is there any way to move M8 to the right so it aligns with F4?

calvinatintel commented 9 years ago

Judging by the second to the last image on SO, it certainly seems possible. I wish the author would tell us how.

jubobs commented 9 years ago

Some manual tweaking is required; same technique as in issue #3. Note that you shouldn't use DAGedge as you do, though.

\documentclass{article}

\usepackage{gitdags}

\begin{document}
  \begin{tikzpicture}
    % Commit DAG
    \gitDAG[grow right sep = 2em]{
      M5 -- M6 -- M7 -- {
        M7 -- M8[xshift=13.2em],      % <-----------
        M7 -- F1 -- F2 -- F3 -- F4 -- M8,
      }
    };
    \gitbranch
      {master}      % node name and text
      {above=of M7} % node placement
      {M7}
    \gitHEAD
      {above=of master} % node placement
      {master}          % target
    \gitbranch
      {feature}     % node name and text
      {below=of F4} % node placement
      {F4}
  \end{tikzpicture}
\end{document}

screen shot 2015-09-30 at 20 27 13

calvinatintel commented 9 years ago

Thank you @Jubobs for the response! Is there a way to set the shift property to a group? For yshift, I'm finding that I need to apply it to pretty much all nodes in a branch.

jubobs commented 9 years ago

@calvinatintel The method for shifting an entire part of the graph vertically is to use branch down option at the right place. Could you open a new issue with a minimal working example and a description of the desired output?