Albert Wifstrand
Albert Wifstrand

Reputation: 230

How do I, in a TikZ/er picture, omit the "diamond" symbol of a relationship and control placement of text along the relationship's path?

I have the following LaTeX file:

\documentclass[border=10pt]{standalone}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{er,positioning}
\begin{document}
\begin{tikzpicture}[auto,node distance=1.5cm]
  \node[entity] (node1) {Fancy Node One};
  \node[relationship] (rel1) [right = of node1] {has};
  \node[entity] (node2) [right = of rel1] {Fancy Node Two};
  \path (rel1) edge node {1} (node1)
  edge node {n} (node2);
\end{tikzpicture}
\end{document}

When I render it it looks like this:

Fancy Node example

Is it possible to a) omit the "diamond" symbol entirely and b) control placement of "1" and "n"? What I want in this particular example is to have the "1" above the line, and both "1" and "n" closer to the nodes -- basically, this:

Fancy Node example, edited with MS Paint

(Not sure if this would be regarded as valid ER diagram notation, but that's a separate concern.)

If it's not possible or impractical with TikZ and/or er, I'm open to suggestions for other LaTeX packages suitable for making ER diagrams. (If it is possible, I'd also appreciate pointers to documentation on this.)

Upvotes: 1

Views: 341

Answers (1)

Quick hack:

\documentclass[border=10pt]{standalone}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{er,positioning}
\begin{document}
\begin{tikzpicture}[auto,node distance=1.5cm]
  \node[entity] (node1) {Fancy Node One};
  \node[entity] (node2) [right = 3cm of node1] {Fancy Node Two};
  \draw (node1.east) -- (node2.west);
  \node[anchor=south west] at (node1.east) {1};
  \node[anchor=south east] at (node2.west) {n};
\end{tikzpicture}
\end{document}

enter image description here

Upvotes: 1

Related Questions