向 SL 树的两侧添加文本
Adding text to both sides of a SL tree
我需要创建一个像 this tree 这样的树。到目前为止我写的代码是
\documentclass[11pt, a4paper]{article}
% Packages
\usepackage{amsmath, amssymb, amstext}
\usepackage[linguistics]{forest}
% Margins
\usepackage[a4paper,margin=2cm]{geometry}
% Renew Commands
\renewcommand{\land}{~\&~}
\renewcommand{\implies}{\supset}
\renewcommand{\iff}{\equiv}
% Document
\begin{document}
\begin{forest}
[$(E \implies \lnot (P \lor Q)) \land ((Q \land E) \lor (E \land P))$
[$E \implies \lnot (P \lor Q)$ \ $(Q \land E) \lor (E \land P)$
[$E \land (Q \lor P)$
[$E$\$Q \lor P$
[$\lnot (P \lor Q)$
[$\lnot P \land \lnot Q$
[$\lnot P$\$\lnot Q$
[$Q$
[$\times$]
]
[$P$
[$\times$]
]
]
]
]
]
]
]
]
\end{forest}
\end{document}
到目前为止产生 this tree。指定的是我需要一个包含左对齐编号的最左边的列和一个包含左对齐的规则解释的右列。如果您可以包含一种方法让所有节点等距分布,以便左右列与节点对齐,那也将非常有帮助。谢谢!
没关系,我用 tikz-picture 而不是 forest 解决了这个问题:
\begin{tikzpicture}[level/.style={sibling distance=100mm/#1},
baseline,
>=latex,
every text node part/.style={align=center},
font=\sffamily
]
\node (1a){$(E \implies \lnot [P \lor Q]) \land ([Q \land E] \lor [E \land P])$}
child {node {$E \implies \lnot (P \lor Q)$ \ $(Q \land E) \lor (E \land P)$}
child {node {$\lnot E$}
child {node {$Q \land E$}
child {node {$Q$\$E$}
child {node {$\times$}}}
}
child {node {$E \land P$}
child {node {$E$\$P$}
child {node {$\times$}}}
}
}
child {node {$\lnot (P \lor Q)$}
child {node {$Q \land E$}
child {node {$Q$\$E$}
child {node {$\lnot P$\$\lnot Q$}
child {node {$\times$}}}
}
}
child {node {$E \land P$}
child {node {$E$\$P$}
child {node {$\lnot P$\$\lnot Q$}
child {node {$\times$}}}
}
}
}
};
\node[left=3 of 1a] {1}edge from parent[draw=none]
child {node {2\3}edge from parent[draw=none]
child {node {4}edge from parent[draw=none]
child {node {5}edge from parent[draw=none]
child {node {6\7}edge from parent[draw=none]
child {node {8\9}edge from parent[draw=none]}
}
}
}
};
\node[right=3 of 1a] {$\Phi$}edge from parent[draw=none]
child {node { \land$}edge from parent[draw=none]
child {node { \implies$}edge from parent[draw=none]
child {node { \lor$}edge from parent[draw=none]
child {node { \land$}edge from parent[draw=none]
child {node { \lnot \lor$}edge from parent[draw=none]}
}
}
}
};
\end{tikzpicture}
产生这个:
这是通过制作第一棵向下生长的主树、左边的第二棵树用于编号,以及右边的最后一棵树用于使用的规则来实现的。
我需要创建一个像 this tree 这样的树。到目前为止我写的代码是
\documentclass[11pt, a4paper]{article}
% Packages
\usepackage{amsmath, amssymb, amstext}
\usepackage[linguistics]{forest}
% Margins
\usepackage[a4paper,margin=2cm]{geometry}
% Renew Commands
\renewcommand{\land}{~\&~}
\renewcommand{\implies}{\supset}
\renewcommand{\iff}{\equiv}
% Document
\begin{document}
\begin{forest}
[$(E \implies \lnot (P \lor Q)) \land ((Q \land E) \lor (E \land P))$
[$E \implies \lnot (P \lor Q)$ \ $(Q \land E) \lor (E \land P)$
[$E \land (Q \lor P)$
[$E$\$Q \lor P$
[$\lnot (P \lor Q)$
[$\lnot P \land \lnot Q$
[$\lnot P$\$\lnot Q$
[$Q$
[$\times$]
]
[$P$
[$\times$]
]
]
]
]
]
]
]
]
\end{forest}
\end{document}
到目前为止产生 this tree。指定的是我需要一个包含左对齐编号的最左边的列和一个包含左对齐的规则解释的右列。如果您可以包含一种方法让所有节点等距分布,以便左右列与节点对齐,那也将非常有帮助。谢谢!
没关系,我用 tikz-picture 而不是 forest 解决了这个问题:
\begin{tikzpicture}[level/.style={sibling distance=100mm/#1},
baseline,
>=latex,
every text node part/.style={align=center},
font=\sffamily
]
\node (1a){$(E \implies \lnot [P \lor Q]) \land ([Q \land E] \lor [E \land P])$}
child {node {$E \implies \lnot (P \lor Q)$ \ $(Q \land E) \lor (E \land P)$}
child {node {$\lnot E$}
child {node {$Q \land E$}
child {node {$Q$\$E$}
child {node {$\times$}}}
}
child {node {$E \land P$}
child {node {$E$\$P$}
child {node {$\times$}}}
}
}
child {node {$\lnot (P \lor Q)$}
child {node {$Q \land E$}
child {node {$Q$\$E$}
child {node {$\lnot P$\$\lnot Q$}
child {node {$\times$}}}
}
}
child {node {$E \land P$}
child {node {$E$\$P$}
child {node {$\lnot P$\$\lnot Q$}
child {node {$\times$}}}
}
}
}
};
\node[left=3 of 1a] {1}edge from parent[draw=none]
child {node {2\3}edge from parent[draw=none]
child {node {4}edge from parent[draw=none]
child {node {5}edge from parent[draw=none]
child {node {6\7}edge from parent[draw=none]
child {node {8\9}edge from parent[draw=none]}
}
}
}
};
\node[right=3 of 1a] {$\Phi$}edge from parent[draw=none]
child {node { \land$}edge from parent[draw=none]
child {node { \implies$}edge from parent[draw=none]
child {node { \lor$}edge from parent[draw=none]
child {node { \land$}edge from parent[draw=none]
child {node { \lnot \lor$}edge from parent[draw=none]}
}
}
}
};
\end{tikzpicture}
产生这个:
这是通过制作第一棵向下生长的主树、左边的第二棵树用于编号,以及右边的最后一棵树用于使用的规则来实现的。