如何使用基于 tikz 的包 gitdags 绘制 git merge -no-ff 的结果?
How to draw the result of git merge -no-ff using the tikz-based package gitdags?
此来源
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{gitdags}
\begin{document}
\begin{tikzpicture}
\gitDAG{
A -- {B, C} -- D
};
\end{tikzpicture}
\begin{tikzpicture}[
commit/.style={circle, draw=green!30!blue, fill=green!20!white, thick, text=black, font=\ttfamily},
]
\node (a) [commit] {A};
\node (c) [commit, below right = 0.8cm of a] {C};
\node (d) [commit, right = 1.3cm of a] {D};
\draw (d) edge [->] (a)
(d) edge [->] (c)
(c) edge [->] (a);
\end{tikzpicture}
\end{document}
编译成下图:
如何说服gitdags
(用于创建第一张图片的包)绘制具有第二张图片所示拓扑结构的图形?
因为 A
是 C
和 D
的父级,所以 C
和 D
应该在 A
之后一起支撑.由于 D
是 A
和 C
的子代,因此 A
和 C
都应该在 D
之前放在一起。因此 C
必须与 A
一起用大括号括起来,同时在 A
之后放在单独的大括号中。我不明白这怎么可能。
是否缺少某些 gitdag
语法?
这是一种可能的解决方案:
\documentclass[]{article}
\usepackage{tikz}
\usepackage{gitdags}
\begin{document}
\begin{tikzpicture}
\gitDAG{
A -- C[yshift=-10mm] -- D,
A -- D
};
\end{tikzpicture}
\end{document}
DAG 中的任何节点都可能被多次提及。此方案通过C
一次提A
建立其link到D
,然后再提A
建立link之间的直接link 11=] 和 D
.
默认情况下 C
会与 A
和 D
对齐,因此它的高度需要手动调整 yshift
。
此来源
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{gitdags}
\begin{document}
\begin{tikzpicture}
\gitDAG{
A -- {B, C} -- D
};
\end{tikzpicture}
\begin{tikzpicture}[
commit/.style={circle, draw=green!30!blue, fill=green!20!white, thick, text=black, font=\ttfamily},
]
\node (a) [commit] {A};
\node (c) [commit, below right = 0.8cm of a] {C};
\node (d) [commit, right = 1.3cm of a] {D};
\draw (d) edge [->] (a)
(d) edge [->] (c)
(c) edge [->] (a);
\end{tikzpicture}
\end{document}
编译成下图:
如何说服gitdags
(用于创建第一张图片的包)绘制具有第二张图片所示拓扑结构的图形?
因为 A
是 C
和 D
的父级,所以 C
和 D
应该在 A
之后一起支撑.由于 D
是 A
和 C
的子代,因此 A
和 C
都应该在 D
之前放在一起。因此 C
必须与 A
一起用大括号括起来,同时在 A
之后放在单独的大括号中。我不明白这怎么可能。
是否缺少某些 gitdag
语法?
这是一种可能的解决方案:
\documentclass[]{article}
\usepackage{tikz}
\usepackage{gitdags}
\begin{document}
\begin{tikzpicture}
\gitDAG{
A -- C[yshift=-10mm] -- D,
A -- D
};
\end{tikzpicture}
\end{document}
DAG 中的任何节点都可能被多次提及。此方案通过C
一次提A
建立其link到D
,然后再提A
建立link之间的直接link 11=] 和 D
.
默认情况下 C
会与 A
和 D
对齐,因此它的高度需要手动调整 yshift
。