Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using TIKZ-UML to create four simple usecase diagrams. I have made them individually in seperate files to make sure that they all compile as they should.

I include the required packages in my preamble and include a reference to the files containing the tikzpictures in my document. When I compile the first diagram it compiles (and shows) just fine, but the following three diagrams seem to be affected by a width stated in a \usecase of the first diagram.

This diagram is the first one that is included in the document:

\begin{figure}
\centering

\begin{tikzpicture}

\umlactor[y=4]{Supervisor}
\umlactor[y=2]{Co-Supervisor}
\umlactor[y=0]{Examinator}

\umlusecase[x=5, y=2, fill=lightgray!50, width=3cm]{Determining examiner availability}

\umlactor[x=10, y=2]{Secretary}

\umlassoc{Supervisor}{usecase-1}
\umlassoc{Co-Supervisor}{usecase-1}
\umlassoc{Examinator}{usecase-1}

\umlassoc{usecase-1}{Secretary}

\end{tikzpicture}
\caption{Scenario: Determining examiner availbility.}
\end{figure}

The other diagrams are much the same, only with a different text for the \usecase (and possibly an other width.

The preamble for the diagram contains:

\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{positioning,chains,fit,shapes,calc}

Link to example: First diagram OK, next one has the wrong width

Thank you for your time :)

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

The problem is that you always refer to usecase-1 in your associations. The names and counters are global, however, so in your second tikzpicture, you should be referring to usecase-2.

The nodes and anchors are defined globally, so even though you didn't define a usecase-1 in your second picture, you can still refer to it as if you had, and the lines will end up at the same positions as in your first picture.

Alternatively, you can just reset the counter tikzumlUseCaseNum to 0 at the start of every new tikzpicture, so the numbering will start again:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{positioning,chains,fit,shapes,calc}


\begin{document}

\begin{tikzpicture}

\umlactor[y=4]{Supervisor}
\umlactor[y=2]{Co-Supervisor}
\umlactor[y=0]{Examinator}

\umlusecase[x=5, y=2, fill=lightgray!50, width=3cm]{Determining examiner availability}

\umlactor[x=10, y=2]{Secretary}

\umlassoc{Supervisor}{usecase-1}
\umlassoc{Co-Supervisor}{usecase-1}
\umlassoc{Examinator}{usecase-1}

\umlassoc{usecase-1}{Secretary}

\end{tikzpicture}

\begin{tikzpicture}
\setcounter{tikzumlUseCaseNum}{0}% Reset the counter
\umlactor[y=4]{Supervisor}
\umlactor[y=2]{Co-Supervisor}
\umlactor[y=0]{Examinator}

\umlusecase[x=5, y=2, fill=lightgray!50, width=2cm]{Sudden}

\umlactor[x=10, y=2]{Secretary}

\umlassoc{Supervisor}{usecase-1}
\umlassoc{Co-Supervisor}{usecase-1}
\umlassoc{Examinator}{usecase-1}

\umlassoc{usecase-1}{Secretary}

\end{tikzpicture}


\end{document}
share|improve this answer
1  
Thank you very much for your well-explained answer! Is there a way to explicitly name a node and then reference it instead of using the name for the node as a reference? For example, I reference the actor "Supervisor" as "Supervisor" - sometimes it would be nice to give such node a destinct name and another "id". –  thilemann Apr 18 '12 at 10:32
1  
@thilemann: Certainly! You can just add name=<your name> to the options of \umlusecase. –  Jake Apr 18 '12 at 12:42
    
Thanks - again just what I was looking for :) –  thilemann Apr 18 '12 at 22:59
add comment

Your Answer

 
discard

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.