
我正在嘗試畫這樣的東西。我嘗試過 tikz 但我無法切斷兩點之間的線。另外,我無法獲得帶有年份的第一列。有什麼建議麼?
這就是我到目前為止所擁有的
\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',auto,node distance=3cm,
thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]
\node[main node] (1) {};
\node[main node] (2) [below of=1] {};
\node[main node] (3) [below of=2] {};
\node[main node] (4) [below of=3] {};
\node[main node] (5) [left of=2] {};
\node[main node] (6) [left of=3] {};
\node[main node] (7) [left of=4] {};
\node[main node] (8) [left of=7] {};
\path[every node/.style={font=\sffamily\small}]
(5) edge node [right] {} (2)
(6) edge node [right] {} (3)
(7) edge node [right] {} (4)
(8) edge node [right] {} (7);
\end{tikzpicture}
\end{document}
但也許我的方向是錯的。
答案1
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{decorations.markings,
matrix}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[node distance=3cm,
thick,
decoration = {markings,% switch on markings
mark=% actually add a mark
at position 0.5 with {\draw (-2pt,-2pt) -- (2pt,2pt);}
},
]
\matrix (m) [matrix of math nodes,
nodes in empty cells,
column sep=9mm]
{
t-2 & t-1 & t & \text{year} \\
& & \circ & 0 \\
& \circ & \bullet & 1 \\
& \bullet & \bullet & 2 \\
\bullet & \bullet & \bullet & 3 \\
};
\draw[postaction={decorate}] (m-4-2.center) -- (m-4-3.center);
\draw[postaction={decorate}] (m-5-1.center) -- (m-5-2.center);
\draw[postaction={decorate}] (m-5-2.center) -- (m-5-3.center);
\end{tikzpicture}
\end{document}
所有節點都組織為矩陣。 forlines 使用 TikZ 函式庫decorations.markings
。