答案1
您可以使用pstricks
或 使用获得此信息tikz-cd
:
\documentclass[11pt]{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{linewidth=0.6pt, arrowinset=0.12, linecolor=blue, arrows=->, nodesep=2pt}
\[
\begin{psmatrix}[rowsep=5ex, colsep=1cm, mnode=R]
%%% Nodes
& & & N_{i, 1}\mathrlap{\equiv 1}\\
& & N_{i-1, 2} & N_{i, 2}\\
& N_{i-2, 3} & N_{i-1, 3} & N_{i, 3}\\
N_{i-3, 4}& N_{i-2, 4} & N_{i-1,4} & N_{i,4}
%%% Horizontal arrows
\ncline{1,4}{2,3} \ncline{1,4}{2,4}
\ncline{2,3}{3,2} \ncline{2,3}{3,3} \ncline{2,4}{3,3}\ncline{2,4}{3,4}
\ncline{3,2}{4,1} \ncline{3,2}{4,2}\ncline{3,3}{4,2} \ncline{3,3}{4,3}\ncline{3,4}{4,3}\ncline{3,4}{4,4}
\end{psmatrix} \]
\vskip 1cm
\[ \tikzcdset{arrows={-Stealth, blue}}
\begin{tikzcd}
& & & N_{i, 1}\mathrlap{\equiv 1}\dlar\dar\\
& & N_{i-1, 2}\dlar\dar & N_{i, 2}\dlar\dar\\
& N_{i-2, 3}\dlar\dar & N_{i-1, 3}\dlar\dar & N_{i, 3}\dlar\dar\\
N_{i-3, 4}& N_{i-2, 4} & N_{i-1,4} & N_{i,4}
\end{tikzcd}\]
\end{document}
答案2
您还可以使用 TikZgraphdrawing
自动连接并放置所有内容。这需要 LuaLaTeX。
注意:必须命名包含的节点\equiv
(此处为a
)。否则,您将看到一个相当神秘的
! Missing \endcsname inserted.
<to be read again>
\equiv
我选择了tree layout
图表,但其他布局也很容易实现。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}
\graph [tree layout, math nodes, edge={blue,-stealth}]
{
a / N_{i, 1} \equiv 1 -> {
N_{i-1, 2} -> {
N_{i-2, 3} -> { N_{i-3, 4}, N_{i-2, 4} },
N_{i-1, 3} -> { N_{i-2, 4}, N_{i-1,4} }
},
N_{i, 2} -> {
N_{i-1, 3},
N_{i, 3} -> { N_{i-1,4}, N_{i,4} }
}
}
};
\end{tikzpicture}
\end{document}
答案3
我并不特别推荐这样做,因为它不是一棵树,但如果需要的话,它可以或多或少自动地用 Forest 绘制。
\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage{forest}
\usepackage{amsmath}
\usetikzlibrary{arrows.meta}
\begin{document}
\forestset{
declare count register=thing,
thing'=0,
}
\begin{forest}
for tree={
edge={-Stealth, draw=blue!50!cyan},
math content,
tier/.option=level,
},
label={right:$=1$},
where n'=1{
calign with current edge,
}{},
before typesetting nodes={
for nodewalk={
r,
while nodewalk valid={l}{l}
}{
content/.process={Ow+nw}{level}{#1+1}{\text{N}_{i,#1}}
},
for nodewalk={
fake=r,
while nodewalk valid={1}{
thing'+=1,
1,
for tree={
content/.process={Ow+nRw2}{level}{#1+1}{thing}{\text{N}_{i-#2,#1}}
},
for nodewalk={
while nodewalk valid={l}{
tikz+/.process={Ow}{edge}{\path [#1] (!next on tier.parent anchor) -- (!l.child anchor);},
l
}
}{}
}
}{},
},
[
[
[
[
[]
[]
]
[
[]
]
]
[
[
[]
]
]
]
[
[
[
[]
]
]
]
]
\end{forest}
\end{document}
笔记:代码经过编辑以反映 Forest 2.1 的错误修复。以上版本适用于 2.1.2 版本。如果您拥有早期版本的 Forest,则需要更新才能使用上述代码。
答案4
这里我使用\Shortstack
。编辑:添加了彩色箭头。
\documentclass{article}
\usepackage{stackengine,graphicx,xcolor}
\stackMath
\newcommand\undarrow{{\color{blue}%
\kern15pt
\raisebox{-.5ex}{\rotatebox[origin=bottom]{-45}{\scalebox{1}[1.414]{$\downarrow$}}}
\kern2pt\downarrow\,}}
\renewcommand\stackalignment{r}
\setstackgap{S}{4pt}
\newcommand\schemeunit[3][-]{\stackunder{N\rlap{$_{i#1#2,#3}$}}{\undarrow}}
\newcommand\schemeUnit[3][-]{%
\stackunder[0pt]{N\rlap{$_{i#1#2,#3}$}}{\smash{\phantom{\undarrow}}}}
\begin{document}
\Shortstack{%
\schemeunit[]{}{1}
\schemeunit{1}{2}\schemeunit[]{}{2}
\schemeunit{2}{3}\schemeunit{1}{3}\schemeunit[]{}{3}
\schemeUnit{3}{4}\schemeUnit{2}{4}\schemeUnit{1}{4}\schemeUnit[]{}{4}}
\end{document}