การเพิ่มข้อความทั้งสองด้านของแผนผัง SL

ฉันต้องสร้างแผนผังแบบ แผนผังนี้ รหัสที่ฉันเขียนจนถึงตอนนี้คือ

\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}

ซึ่งสร้าง แผนผังนี้ จนถึงตอนนี้ ระบุคือฉันต้องการคอลัมน์ซ้ายสุดที่มีหมายเลขจัดชิดซ้ายและคอลัมน์ขวาที่มีคำอธิบายกฎจัดชิดซ้าย นอกจากนี้ยังจะเป็นประโยชน์อย่างยิ่งหากคุณสามารถรวมวิธีให้โหนดทั้งหมดมีระยะห่างเท่ากัน โดยให้คอลัมน์ซ้ายและขวาอยู่ในแนวเดียวกันกับโหนด ขอบคุณ!


person Ethan Thoma    schedule 12.10.2020    source แหล่งที่มา


คำตอบ (1)


ไม่เป็นไร ฉันแก้ไขมันได้โดยใช้ tikz-picture แทนฟอเรสต์:

\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 {$1 \land$}edge from parent[draw=none]
            child {node {$2 \implies$}edge from parent[draw=none]
                child {node {$3 \lor$}edge from parent[draw=none]
                    child {node {$5 \land$}edge from parent[draw=none]
                        child {node {$4 \lnot \lor$}edge from parent[draw=none]}
                    }
                }
            }
        };
                
\end{tikzpicture}

ซึ่งผลิตสิ่งนี้:

เอาท์พุท

วิธีนี้ทำงานโดยการสร้างต้นไม้ต้นแรก ซึ่งเป็นต้นไม้หลักที่โตลงมา ต้นไม้ต้นที่สองที่เหลือไว้สำหรับการนับเลข และต้นไม้ต้นสุดท้ายทางด้านขวาสำหรับกฎที่ใช้

person Ethan Thoma    schedule 16.10.2020