双线显示​​为矩形

双线显示​​为矩形

梅威瑟:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (x) {X};
\node[above right=1mm and 2mm of x] (y) {Y};

\draw[double,double distance=2mm] (x) -- (y);
\end{tikzpicture}
\end{document}

编译结果

如何去除细纹?

答案1

尽管我投票关闭您的问题,因为重复了(抱歉),但这是一种不同的方法,可以为您提供真正的文字等号。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (x) {$X$};
\node[above right=1mm and 2mm of x] (y) {$Y$};
\path (x) -- (y) node[midway,sloped] {$=$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

由于这是一个重复的问题,因此这里有一个装饰,它将双线绘制为两条路径,而不是一条粗线,顶部有一条白线,这就是为什么你会在两端看到细线(我认为对于某些观众来说)。语法很简单,

\draw[alt double,alt double distance=2mm] (x) -- (y);

并且也适用于曲线,参见

\draw[alt double,alt double distance=2mm] (y) to[out=90,in=180] (z);

这是代码。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations,positioning} 
\pgfkeys{/tikz/.cd,
    alt double distance/.initial=5pt,
    alt double step/.initial=1pt,
}

\pgfdeclaredecoration{double deco}{initial}
{% initial arrow butt
\state{initial}[width=\pgfkeysvalueof{/tikz/alt double step},next state=cont] {
    \pgfmoveto{\pgfpoint{\pgfkeysvalueof{/tikz/alt double step}}{\pgfkeysvalueof{/tikz/alt double distance}/2}}
    \pgfpathlineto{\pgfpoint{0.3\pgflinewidth}{\pgfkeysvalueof{/tikz/alt double distance}/2}}
    \pgfpathmoveto{\pgfpoint{0.3\pgflinewidth}{-\pgfkeysvalueof{/tikz/alt double distance}/2}}
    \pgfpathlineto{\pgfpoint{1pt}{-\pgfkeysvalueof{/tikz/alt double distance}/2}}
    \pgfcoordinate{lastup}{\pgfpoint{1pt}{\pgfkeysvalueof{/tikz/alt double distance}/2}}
    \pgfcoordinate{lastdown}{\pgfpoint{1pt}{-\pgfkeysvalueof{/tikz/alt double distance}/2}}
  }
  \state{cont}[width=\pgfkeysvalueof{/tikz/alt double step}]{
     \pgfmoveto{\pgfpointanchor{lastup}{center}}
     \pgfpathlineto{\pgfpoint{\pgfkeysvalueof{/tikz/alt double step}}{\pgfkeysvalueof{/tikz/alt double distance}/2}}
     \pgfcoordinate{lastup}{\pgfpoint{\pgfkeysvalueof{/tikz/alt double step}}{\pgfkeysvalueof{/tikz/alt double distance}/2}}
     \pgfmoveto{\pgfpointanchor{lastdown}{center}}
     \pgfpathlineto{\pgfpoint{\pgfkeysvalueof{/tikz/alt double step}}{-\pgfkeysvalueof{/tikz/alt double distance}/2}}
     \pgfcoordinate{lastdown}{\pgfpoint{\pgfkeysvalueof{/tikz/alt double step}}{-\pgfkeysvalueof{/tikz/alt double distance}/2}}
  }
  \state{final}[width=0pt]
  { % perhaps unnecessary but doesn't hurt either
    \pgfmoveto{\pgfpointdecoratedpathlast}
  }
}
\tikzset{alt double/.style={decorate,decoration=double deco}}
\begin{document}
\begin{tikzpicture}
\node (x) {X};
\node[above right=1mm and 2mm of x] (y) {Y};
\draw[alt double,alt double distance=2mm] (x) -- (y);

\node[above right=1cm and 2cm of y] (z) {Z};
\draw[alt double,alt double distance=2mm] (y) to[out=90,in=180] (z);
\end{tikzpicture}
\end{document}

在此处输入图片描述

使用这种装饰也应该允许计算与双线的交点

相关内容