8

I'm new to TikZ and have produced the following figure enter image description here

This is what I want except the fact the arrowed lines do not all join in the centre of the diamonds for some reason, why is this? and how can I make them all join up? The code I used is:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{amsthm, mathrsfs}
\newcommand{\scri}{\mathscr{I}}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings} 
\usetikzlibrary{calc}
\usepgflibrary{arrows}

\begin{document}

%Arrows in centre
\tikzset{->-/.style={decoration={
 markings,
 mark=at position #1 with {\arrow[scale=1]{>}}},postaction={decorate}}}


\begin{tikzpicture}[>=open triangle 90]
\node (I)    at ( 4,0) {};
\node (II)   at (-5,0) {};




\path % Four conners of the right diamond 
   (I) +(90:4)  coordinate[label=90:$i^+$]  (Itop)
       +(-90:4) coordinate[label=-90:$i^-$] (Ibot)
       +(180:4) coordinate (Ileft)
       +(0:4)   coordinate[label=0:$i^0$] (Iright)
       +(45: 2.825)   coordinate (Imidtr)
       +(225:2.825)   coordinate (Imidbl)
       +(135:2.825)   coordinate (Imidtl)
       +(-45:2.825)   coordinate (Imidbr)
       ;
   ;

\draw  (Ileft)  -- 
          node[midway, below, sloped] {$H^+$}
       (Itop)   -- 
          node[midway, above right]    {$\scri^+$}
         node[midway, below, sloped] {$\bar{v}=\infty$}
       (Iright) --
          node[midway, below right]    {$\scri^-$}
          node[midway, above, sloped] {$\bar{u}=-\infty$}
        (Ibot)   --
          node[midway, below, sloped]    {$H^-$}
       (Ileft)  -- cycle;

 %draw arrowed mode lines
\draw[->-=.5] (Imidbr) -- (I);
\draw[->-=.5] (I) -- (Imidtl);   
\draw[->-=.5] (I) -- (Imidtr);    

%REPEAT FOR THE DOWN MODES  
\path % Four conners of the other diamond 
   (II) +(90:4)  coordinate[label=90:$i^+$]  (IItop)
       +(-90:4) coordinate[label=-90:$i^-$] (IIbot)
       +(180:4) coordinate (IIleft)
       +(0:4)   coordinate[label=0:$i^0$] (IIright)
       +(45: 2.825)   coordinate (IImidtr)
        +(225:2.825)   coordinate (IImidbl)
       +(135:2.825)   coordinate (IImidtl)
       +(-45:2.825)   coordinate (IImidbr)
       ;
 % draw other diamond
\draw  (IIleft)  -- 
      node[midway, below, sloped] {$H^+$}
   (IItop)   -- 
      node[midway, above right]    {$\scri^+$}
      node[midway, below, sloped] {$\bar{v}=\infty$}
   (IIright) --
      node[midway, below right]    {$\scri^-$}
      node[midway, above, sloped] {$\bar{u}=-\infty$}
   (IIbot)   --
      node[midway, below, sloped]    {$H^-$}
   (IIleft)  -- cycle;

 %draw modes:
 \draw[->-=.5] (IImidbl) -- (II);
 \draw[->-=.5] (II) -- (IImidtl);   
 \draw[->-=.5] (II) -- (IImidtr);        


 \end{tikzpicture}
 \end{document}
fpghost
  • 1,945

1 Answers1

13

Changing the following nodes to coordinates fixes the problem....

\coordinate (I)    at ( 4,0) ;
\coordinate (II)   at (-5,0) ;

enter image description here

The reason for that is due to the fact that nodes have a default shapes with nonzero area with various anchors at the borders of the shape. As Ryan Reich mentions in his comment, the size depends on a few key values such as minimum width/height,inner sep,outer sep,line width etc. One can try to drive a node to be as small as possible but that is actually not a good idea since then it's underlying path drawing calculations would be forced to the TeX precision and possibly, though not always, it will not behave as a coordinate no matter what.

In contrast coordinates have only one anchor which is the center and it characterizes the coordinate. Also they don't have a shape or background path to be drawn when draw option is used. Since they are indeed coordinates, the lines join.

percusse
  • 157,807
  • 2
    You should add the explanation that it's because of the minimum size of a node (or its inner sep and outer sep) being nonzero. Coordinates are "point particles", by contrast. – Ryan Reich May 10 '13 at 01:42
  • @RyanReich Agreed. It was a fast sweep of unanswered TikZ questions so maybe I did it a little too fast. I'll edit in a sec. – percusse May 10 '13 at 08:17