1

MWE:

\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}

compilation result

How to remove the thin lines?

  • See the answer of this question for instance. – user121799 May 13 '19 at 14:38
  • Or this one may even be simpler. – user121799 May 13 '19 at 14:41
2

Although I voted to close your question as duplicate (sorry), this is a different approach which give you a real, literal equal sign.

\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}

enter image description here

4

Since this is a repeating question, here is a decoration that draws the double as two paths rather than a thick line with a white line on top, which is why you get the thin lines on the ends (for certain viewers, I think). The syntax is as simple as

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

and also works for curved lines, see

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

Here is the code.

\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}

enter image description here

Using this decoration should also allow one to compute intersections with the double line.

Not the answer you're looking for? Browse other questions tagged or ask your own question.