1

I am using the tikz-uml package to model a class diagram.

The code snippet is placed in the examples sub-directory of the downloaded tikz-uml package.

Here is the code:

\documentclass[a4paper,11pt, svgnames]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{listings}

\usepackage{../tikz-uml}

\textwidth 18.5cm
\textheight 25.5cm
\hoffset=-2.9cm
\voffset=-2.9cm

\sloppy
\hyphenpenalty 10000000

\date{}
\title{}
\author{}

\begin{document}

\begin{tikzpicture}
    \begin{umlpackage}{First}
        \begin{umlpackage}{Second}
            \umlemptyclass[type=abstract]{F}
            \umlemptyclass[y=-3, type=abstract]{M}
            \umlimpl{M}{F}

            \umlemptyclass[y=-3, x = 6]{P}
            \umlemptyclass[y=-6, x = 6]{H}
            \umlimpl{P}{M}
            \umlunicompo[pos1=1.9, pos2=0.2]{P}{M}
            \umlinherit{H}{P}
        \end{umlpackage}
    \end{umlpackage}
\end{tikzpicture}

\end{document}

and it results with the following diagram:

Composition and implementation

The association lines between P and M are overlapping. I would like to redirect the composition line (black diamond) between P and M, so that the line is parallel to the implementation line (empty arrow), only placed above it. I tried reading the documentation, but whatever I do fails. Any help?

2
  • 1
    I think you are looking for To modify the anchor points of a relation manual section. It suggest to use \umlunicompo[anchor1=30, anchor2=150]{P}{M}\umlunicompo[anchor1=30, anchor2=150]{P}{M}.
    – Ignasi
    Jul 29, 2013 at 12:19
  • @Ignasi: you are right, I don't know how I missed this. There is an error in your proposed command though, the anchors need to be switched [anchor1=150, anchor2=30], if you write this as an answer (just this line even), I can accept it. Thank you!
    – tmaric
    Jul 29, 2013 at 12:23

1 Answer 1

4

By default, anchors for associations links are placed between entities' centers. But you can change them with anchor options. You can fix anchor1=...andanchor2=...or both with same optionanchors= ... and ...`

What you need is:

\umlunicompo[anchors=150 and 30]{P}{M}

or

\umlunicompo[anchor1=150, anchor2=30]{P}{M}

You'll find more information in section To modify the anchor points of a relation in Tikz-UML documentation

1
  • 2
    Named anchors (as in TikZ) work as well, so maybe \umlunicompo[anchors=mid west and mid east]{P}{M} might be a valid choice. Jul 29, 2013 at 16:52

You must log in to answer this question.

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