![同时使用相对定位和“of”符号](https://linux22.com/image/262438/%E5%90%8C%E6%97%B6%E4%BD%BF%E7%94%A8%E7%9B%B8%E5%AF%B9%E5%AE%9A%E4%BD%8D%E5%92%8C%E2%80%9Cof%E2%80%9D%E7%AC%A6%E5%8F%B7.png)
一个相当高的节点在其右侧有一个不太高的节点。
我喜欢定位和尺寸,但我希望两个节点共享其北边界的相同 Y 轴。
\tikzstyle{big} =[rectangle, draw=blue, text centered, minimum height=60]
\tikzstyle{small}=[rectangle, draw=black, text centered, minimum width=60]
\begin{tikzpicture}
\node[big] (l) {Left High};
\node[small] (r) [right of = l, anchor = west] {Rigth Low};
\end{tikzpicture}
这是一个强力示例,其中只有 Y 轴按照我希望的方式对齐。
\node[big] (l) at (0,0) [anchor = north] {Left High};
\node[small] (r) at (3,0) [anchor = north] {Right Low};
我的目标是仍然使用[right of = l]
符号并以l.north
某种方式使用参考来设置r.north = l.north
。
答案1
这可能是因为你使用了显式定位语法,at (coord)
因此显式坐标优先于定位指令。以下是两个示例
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
big/.style={rectangle, draw=blue, text centered, minimum height=60},
small/.style={rectangle, draw=black, text centered, minimum width=60}
]
\node[big] (l) at (0,0) {Left High};
\node[small,right= 3 cm of {l.north},anchor=north] (r) {Right Low};
\node[big,anchor=north west] (r2) at (r.north east) {righter};
\end{tikzpicture}
\end{document}