LaTeX forum ⇒ Graphics, Figures & TablesControlling lines in tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 28
Joined: Mon Apr 09, 2012 3:13 pm

Controlling lines in tikz

Postby Kotoschow » Sun May 10, 2015 8:09 pm

Hi all,

I am trying to draw a tikz diagram with nodes and lines. I would like to control the point where lines meet nodes. That is, for some node whose coordinates are (x,y), I want to be able to draw lines that start at (x,y+0.2) and terminates at (x,y-0.2). That is, I want a shortcut for the following commands:

  1. \node(a) at (0,0);
  2. \node(b) at (1,1);
  3. \draw(0,.2) -- (1,.8);

Is there any command which gives me the coordinates of a node? Or an optional argument for the \node command which tells the node where lines should meet it?


User avatar
Stefan Kottwitz
Site Admin
Posts: 9604
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun May 10, 2015 9:11 pm

The easiest:

  1. \draw (a.north) -- (b.south);

With shifts:

  1. \draw ([yshift=0.2ex]a.north) -- ([yshift=-0.1ex]b.south);

Adding arbitrary x and y coordinates:

  1. \usetikzlibrary{calc}% in the preamble
  2. ...
  3. \draw ($(a) + (0,.2)$) -- ($(b) - (0,0.2)$);

Stefan admin

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests