3

I use the following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (10,10);
\draw[very thick,rotate around={45:(2.3,5)}] (2.3,5) rectangle ++(4,0.3) ++(0,-0.15) node[inner sep=0pt,outer sep=0pt] (p2) {};
\draw[very thick,rotate around={-10:($(2.3,5)+(45:4)$)}] (2.3,5)++(45:4) rectangle ++(4,0.3)--++(0,0.2)--++(0.7,0)--++(0,-0.15)--++(-0.55,0)--++(0,-0.4)--++(0.55,0)--++(0,-0.15)--++(-0.7,0)--++(0,0.2)++(-4,0)++(0,0.15) coordinate (p3);
\draw[name path=2nd2] (p2)--+(45:2);
\draw[name path=3rd] (p3)--+(170:2);
\path[name intersections={of=2nd2 and 3rd,by=i23}];
\fill[red] (i23) circle (0.5pt);
\end{tikzpicture}
\end{document}

Here is the output:

When I zoom in, I notice that, in contrast to (p3) with coordinate, there is a distance between (p2) with node[inner sep=0pt,outer sep=0pt] and the line starting from (p2). Could anyone explain what causes the gap? Thank you.

1 Answer 1

4

Your empty node is still not completely empty, even when inner sep and outer sep are both set to 0pt it has a space. A coordinate on the other hand is just a point in your coordinate system. To get the same behaviour with a node you need to set also minimum size=0pt. Compare the three nodes and the coordinate in the example below.

\begin{tikzpicture}
  \draw[gray!40] (0,0) grid (4,3);
  \node[label=below:np] (np) at (1,2){};
  \node[label=below:np2,inner sep=0pt,outer sep=0pt] (np2) at (2,2){};
  \node[label=below:np3,inner sep=0pt,outer sep=0pt,minimum size=0pt] (np3) at (1,1){};
  \coordinate[label=below:cp] (cp) at (2,1);
  \foreach \angle in {0,45,...,315}{
    \draw[very thin,red] (np.\angle) circle (0.2pt);
    \draw[very thin,red] (np2.\angle) circle (0.2pt);
    \draw[very thin,red] (np3.\angle) circle (0.2pt);
    \draw[very thin,red] (cp.\angle) circle (0.2pt);
  }
\end{tikzpicture}

enter image description here

On the upper left there is a normal node, on the upper right a node with inner and outer sep set to zero, on the lower left an empty node with minimum size set to zero and on the lower right a coordinate, all four with small circles at all directions (45 degree separation).

In your example that means when drawing from node (p2) towards 45 degrees it starts at (p2.45), which will give you the small gap. Try changing to

\draw[name path=2nd2] (p2.center)--+(45:2);

or change (p2) to be a coordinate, or add minimum size=0pt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .