我如何才能准确定位节点锚点?

我如何才能准确定位节点锚点?

所以我有以下 tikz 代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
    \coordinate (O) at (0,0);
    \path (O) -- ++(4,0) coordinate (B);
    \path[name path=l1] (O) -- ++(40:10);
    \path[name path=l2] (B) -- ++(120:10);
    
    \draw [name intersections={of=l1 and l2, by=A}]
    (O) -- (A) node[midway, above left] {$a$} -- (B) -- cycle node[midway, below] {$b$};
    
    \draw (O) ++(0.5,0) arc [start angle=0, end angle=40, radius=0.5] node[above right, midway] {$\theta$};
    \node[left] at (O) {$O$};
    \node[above] at (A) {$A$};
    \node[right] at (B) {$B$};
\end{tikzpicture}
\end{document}

这里,theta 标签被 OA 线覆盖。这是个问题,因为看起来不太好。我想把它放低一点,这样它就不再被覆盖了。但是,我可以在节点上放置的唯一其他“方向”是right,这将导致 theta 标签被 OB 线覆盖。我该如何设置方向或锚点,使其现在恰好位于两条线之间?

答案1

我做了两件事:我改为above rightright并且我在节点\strut中添加了\theta

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
    \coordinate (O) at (0,0);
    \path (O) -- ++(4,0) coordinate (B);
    \path[name path=l1] (O) -- ++(40:10);
    \path[name path=l2] (B) -- ++(120:10);
    
    \draw [name intersections={of=l1 and l2, by=A}]
    (O) -- (A) node[midway, above left] {$a$} -- (B) -- cycle node[midway, below] {$b$};
    
    \draw (O) ++(0.5,0) arc [start angle=0, end angle=40, radius=0.5] 
      node[right,midway] {$\theta$\strut};
    \node[left] at (O) {$O$};
    \node[above] at (A) {$A$};
    \node[right] at (B) {$B$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

如果你想要更多的控制,只需添加一个底部延伸\rule\theta“推它”,就像

\draw (O) ++(0.5,0) arc [start angle=0, end angle=40, radius=0.5] 
   node[right,midway] {$\theta$\rule[-6pt]{0pt}{0pt}};

在此处输入图片描述

相关内容