如何让 TikZ 在后期记住“倾斜”选项?

如何让 TikZ 在后期记住“倾斜”选项?

\begin{tikzpicture}
 \node (C0) at (0pt,0pt) []{$C_0$};
 \node (C1) at (100pt,100pt) []{$C_1$};
 \draw[->] (a)--(b) node [sloped,above]{\text{an isotopy from $C_0$ to $C_1$}};
\end{tikzpicture}

但也可以通过命名节点并稍后绘制来“外部化”从 (a) 到 (b) 的箭头注释的绘制,例如:

\begin{tikzpicture}
\begin{scope}[transparency group,opacity=0.5]
 \node (C0) at (0pt,0pt) []{$C_0$};
 \node (C1) at (100pt,100pt) []{$C_1$};
 \draw[->] (a)--(b) node (positionofannotation) [sloped,above]{};
\end{scope}
 \node (nameofannotation) at (positionofannotation) [sloped]{$\text{an isotopy from $C_0$ to $C_1$}$};
\end{tikzpicture}

此时“倾斜”选项就变得无效了。

如何让 TikZ“记住”这个节点要“倾斜绘制”?

答案1

借用Heiko Oberdiek 的想法

输出

增加了一个障碍物来显示节点绘制晚于路径。

在此处输入图片描述

代码

\documentclass[12pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \begin{scope}[transparency group,opacity=0.5]
    \node (C0) at (0pt,0pt) []{$C_0$};
    \node (C1) at (100pt,100pt) []{$C_1$};
    \draw[->] (C0)--(C1) node (positionofannotation) [sloped,midway] {};
  \end{scope}

  \fill [red!10, rounded corners] (25pt,25pt) rectangle (75pt,75pt);

  \path (positionofannotation.west) -- (positionofannotation.east) 
      node (nameofannotation) [midway, above, sloped, font=\scriptsize] 
        {an isotopy from $C_0$ to $C_1$};
\end{tikzpicture}
\end{document}

相关内容