0

I'm new to LaTeX so please excuse my beginner's questions. So in node positioning in tikz-er2 we can position nodes in 8 different positions relatively to one node(above of, above right of, above left of, below of, below right of, below left of, right of, and left of). My questions are

  1. what if I have more than 8 attributes and relationships to one entity(in this case I have 12 of them)?

  2. can I draw multiple edges from the same point in the entity so it would be something like in the picture?enter image description here

3 Answers 3

1

1) You can add others if you position them manually.

2) You can expressly connect to node.east for example.

Here an adapted example from the manual.

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-er2}
\usetikzlibrary{positioning}

\begin{document}
\tikzstyle{every attribute} = [fill=yellow!20]
\begin{tikzpicture}[node distance=7em]
    \node[entity] (person) {Person};
    \node[attribute] (pid) [left of=person] {\key{ID}} edge (person);
    \node[attribute] (name) [above left of=person] {Name} edge (person); 
    \node[attribute] (name2) [left of=name, xshift=-5mm] {Other Name} edge (person); 
    \node[multi attribute] (phone) [above of=person] {Phone} edge (person);
    \node[attribute] (address) [above right of=person] {Address} edge (person);
    \node[attribute] (street) [above right of=address] {Street} edge (address);
    \node[attribute] (city) [right of=address] {City} edge (address);
    \node[derived attribute] (age) [right of=person] {Age} edge (person);
    \node[attribute] (gender) [below right of=person] {Gender} edge (person.east);
\end{tikzpicture}
\end{document}

enter image description here

0
1

You can position nodes explicitly at specific coordinates (and connect to them) using Cartesian or polar coordinates. When drawing lines you can specify the target node also relatively to the current position, by preceding the Cartesian or polar coordinates by a + or ++ (with + the current position stays where it is, with ++ the current position moves to the new coordinates).

enter image description here

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\tikzset{dot/.style={circle,fill,draw,inner sep=1pt}}
\begin{tikzpicture}[node distance=1cm]
  \node[dot,label={[left]$a=(0,0)$}] (a) {};
  \node[dot,label=above $a$] (b) [above=of a] {};
  \node[dot,label={$(2,1)$}] (c) at (2,1) {};
  \node[dot,label={[right]{$(-30^\circ:2\mathrm{cm})$}}] (d) at (-30:2) {};
  \draw (a) -- (b);
  \draw (a) -- (c);
  \draw (a) -- (d);
  \node[draw] (e) at (5,0) {e};
  \foreach \angle in {0, 10, ..., 350}
    \draw (e) -- +(\angle:1);
\end{tikzpicture}
\end{document}
0

If you don't have a fixed position for the nodes, but several relationships between them, maybe you can use the graphdrawing library from tikz (it makes use of LuaLaTeX, so if that's not an option disconsider this).

You can draw the relationships like they are with the \graph command:

\graph{A -- {B,C,D,E,F,G,H}, F--B};

That means all nodes from B to H are connected to A and F is connected to B. The layout has to be chosen from the available ones, mostly this decision depends on the resulting graph you want, so since you didn't show an example I'm choosing arbitraly the simple necklace layout from the circular graph drawing library.

An MWE with the previous an example:

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{circular}
\begin{document}
    \begin{tikzpicture}
        \graph[simple necklace layout, grow=right]{ A[regardless at={(0,0)}] --[tail anchor=east] {B,C,D,E,F,G,H}, F--B};
    \end{tikzpicture}
\end{document}

Results in

enter image description here

You must log in to answer this question.

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