I am drawing E-R diagrams using the tikz-er2 package. In the begintikzpicture
environment, there is an optional argument node distance
. This is global for all the nodes. Now, If I give a small distance, The nodes intersect and if I give an average distance, the nodes appear too far. How do I set the distance for individual nodes? The tikz-er2
package sty file and user manual can found here. Here is a MWE:
\documentclass[12pt,draft]{article}
\usepackage{tikz-er2}
\begin{document}
\tikzstyle{every entity} = [draw=blue,fill=blue!20,text=red]
\tikzstyle{every attribute} = [fill=yellow!20]
\tikzstyle{every relationship} = [fill=red!20]
\tikzstyle{every edge} = [link]
\begin{tikzpicture}[node distance=8em]
\node[entity] (student) {Student};
\node[attribute] (stud-id) [left of=student] {\key{student-id}} edge (student);
\node[attribute] (name) [above left of=student] {Name} edge (student);
\node[attribute] (fname) [above left of=name] {First-Name} edge (name);
\node[attribute] (lname) [above right of=name] {Last-Name} edge (name);
\node[attribute] (cgpa) [above right of=student] {CGPA} edge (student);
\node[relationship] (joins) [right of=student] {joins} edge [total] (student);
\node[entity] (pgroup) [right of=joins] {Project-Group} edge [<-] (joins);
\end{tikzpicture}
\end{document}
I have enabled the draft mode. It seems there is a bad box. How do I remove that too?
Best Answer
You can use
positioning
library oftikz
and control the distance between each node pair individually.Adjust the distances to suit your needs.