如何使“删除线”随图形的其余部分一起旋转?

如何使“删除线”随图形的其余部分一起旋转?

我有一个使用以下代码生成的图形。基本上,当我使用 [rotate=45]选项时,我想确保删除线符号也会旋转。

另外,与此图相关,我怎样才能使它连接两个节点?(以使其尺寸自动适应之间的空间)?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,calc,shapes.misc}

\begin{document}
\begin{tikzpicture}[rotate=45]
    \draw (-0.5,0)-- ++(+0.5,0);
    \coordinate (B) at (0,0);
    \draw ++(-0.5,0.15) -- ++(+0.5,0);
    \draw (-0.15,-0.15)-- (0,0);
    \draw ++(0,0.15)--+(-0.15,+0.15);
    \draw (0,0) .. controls (+0.075,+0.075) .. (0,0.15);
    \coordinate (A) at (-0.5,0.15);
    \node [strike out,draw,anchor=text] (X) at ++($ (A)!.5!(B) $) {};
    \end{tikzpicture}

\end{document}

结果截图:

在此处输入图片描述

正如您所看到的,删除线符号仍然保持原样。


以下是前后对比:

在此处输入图片描述

答案1

正如我在评论中提到的,transform shapetikzpicture环境添加选项可以解决旋转问题:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,calc,shapes.misc}

\begin{document}
\begin{tikzpicture}[rotate=45,transform shape]
    \draw (-0.5,0)-- ++(+0.5,0);
    \coordinate (B) at (0,0);
    \draw ++(-0.5,0.15) -- ++(+0.5,0);
    \draw (-0.15,-0.15)-- (0,0);
    \draw ++(0,0.15)--+(-0.15,+0.15);
    \draw (0,0) .. controls (+0.075,+0.075) .. (0,0.15);
    \coordinate (A) at (-0.5,0.15);
    \node [strike out,draw,anchor=text] (X) at ++($ (A)!.5!(B) $) {};
    \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容