在这篇先前的文章,比布拉让我能够使用一些样式来对齐内容。我确实需要使用像以下 MN(ot)WE 中的宏。
\coordinate (write me coord) at (current bounding box.east);
我正在尝试调整解决方案的使用比布拉但我的操作方式是每次使用宏时都会改变边界框。也许叠加可以完成这项工作……
\documentclass{article}
\usepackage{forest}
\useforestlibrary{linguistics}
\newcommand\comment[2]{
\node [anchor=mid west, xshift=.75cm] at (#1.mid -| current bounding box.east)) {#2};
}
\begin{document}
\begin{forest}
for tree = {%
sn edges,
grow' = 0,
anchor = parent,
}
[
[$A$
[$B$, name = nB]
[$C$, name = nC]
]
[$D$, name = nD]
]
\comment{nB}{Node B}
\comment{nC}{Node C}
\comment{nD}{Node D}
\end{forest}
\end{document}
答案1
通过添加回坐标解决了该问题write me coord
。
\documentclass{article}
\usepackage{forest}
\useforestlibrary{linguistics}
\newcommand\comment[2]{
% use node "write me coord"
\node [anchor=mid west, xshift=.75cm] at (#1.mid -| write me coord) {#2};
}
\begin{document}
\begin{forest}
for tree = {%
sn edges,
grow' = 0,
anchor = parent,
},
% define coordinate "write me coord"
tikz+={
\coordinate (write me coord) at (current bounding box.east);
}
[,use as bounding box
[$A$
[$B$, name = nB]
[$C$, name = nC]
]
[$D$, name = nD]
]
\comment{nB}{Node B}
\comment{nC}{Node C}
\comment{nD}{Node D}
\end{forest}
\end{document}