TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following UML diagram describing an OrganizationUnit with Persons that fill zero to many Vacancies. The problem lies with need to have nested OrganizationUnits, since pgf-umlcd does not support self association and the graphical result of using \association is bad.

 \begin{class}[text width=8 cm]{OrganizationUnit}{0,0}
   \attribute{name: String}
   \attribute{contactInformation: List<String>}  
 \begin{class}{Person}{-5, -5}
   \attribute{name : String}
   \attribute{title: String}
   \attribute{yearOfBirth: Integer}
 \begin{class}{Vacancy}{5, -5}
   \attribute{title: String}

 \association{OrganizationUnit}{}{1}{Person}{0..*}{belongs to}  

How would I go about extending the pgf-umlcd to implement \selfAssociation?

share|improve this question

Figured it out, mostly:

Editing the pgf-umlcd.sty, I added the following:

  \draw [umlcd style] (#1.north) -- ($(#1.north) + (0, 1)$)
  node[midway, left]{#2}
  node[midway, right]{#3};
  \draw [umlcd style] ($(#1.north) + (0,1)$) -- ($(#1.east) + (1.5,2)$);
  \draw [umlcd style] ($(#1.east) + (1.5,2)$) -- ($(#1.east) + (1.5,0)$);
  \draw [umlcd style] ($(#1.east) + (1.5,0)$) -- (#1.east)
  node[midway, above]{#4}
  node[midway, below]{#5};

And use it as such:

\selfAssociation{OrganizationUnit}{belongs to}{0,1}{contains}{0..*}

This approach has two problems as far as I can tell:

  1. It "uses up" the north and east connections always -you might want to choose the direction in which the selfassociation lines are drawn.

  2. The corners are not straight: This is because the east is the vertical middle of the class, and since classes can vary by height, you can never know how to position that corner.

Any ideas on how to fix these issues would be appreciated.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.