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 use the pgf-umlcd package written by Xu Yuan (see http://code.google.com/p/pgf-umlcd/) in order to write UML class diagrams. It is easy to use - however there is a bug which I don't know how to fix.

In the below snippet there is a description of a package System.Lang Compiling the file leads to the Error message:

!Package pgf Error: No shape named System is known....

\documentclass{minimal}
%%%% Tikz pictures
\usepackage{tikz} 
%%%% UML Class Diagrams
\usepackage[simplified]{pgf-umlcd} 
\begin{document}
\begin{tikzpicture}%[show background grid]
\begin{package}{System.Lang} % <<<<-------- The problem is here!

    \begin{interface}{ISet}{7,0}
        \attribute{NoOfItems}
        \operation{Add(element)}
    \end{interface}

\end{package}
\end{tikzpicture} 
\end{document}

I have tried inconvenient work arounds, like drawing up the System package too - but that did not work either. At the moment I only use the sub-folder name instead of System.Lang, which leads to new problems because the name of the "reversed root" is not unique in the system I work with.

Any ideas?

share|improve this question
    
@Jake Thanks! :) –  AD. May 16 '12 at 8:21

1 Answer 1

up vote 5 down vote accepted

This is caused by the period in your package name System.Lang. The name is also used to name the package node. However, in TikZ, periods are used to separate the node name from an anchor, so the period can't be used in the name itself.

As a fix, you can introduce an optional parameter for the package environment that will be used as the node name instead of the package name that is displayed.

If you add

\renewenvironment{package}[2][\umlcdPackageTitle]{
\edef\umlcdPackageTitle{#2}
\def\umlcdPackageFit{}
\def\umlcdPackageName{#1}
}{
  \begin{pgfonlayer}{background}
  \node[umlcd style, draw, inner sep=0.5cm, fit = \umlcdPackageFit] (\umlcdPackageName) {};
  \node[umlcd style, draw, outer ysep=-0.5, anchor=south west] (\umlcdPackageName caption) at
  (\umlcdPackageName.north west) {\umlcdPackageTitle};
  \end{pgfonlayer}
}

to your preamble, you can create a new package using

\begin{package}[SystemLang]{System.Lang}

where SystemLang is the internal node name that you can use for drawing connections, for example, and System.Lang is the text that will be used in the package title. The normal syntax \begin{package}{<package title>} will also still work.

\documentclass{minimal}
%%%% Tikz pictures
\usepackage{tikz} 
%%%% UML Class Diagrams
\usepackage[simplified]{pgf-umlcd} 

\renewenvironment{package}[2][\umlcdPackageTitle]{
\edef\umlcdPackageTitle{#2}
\def\umlcdPackageFit{}
\def\umlcdPackageName{#1}
}{
  \begin{pgfonlayer}{background}
  \node[umlcd style, draw, inner sep=0.5cm, fit = \umlcdPackageFit] (\umlcdPackageName) {};
  \node[umlcd style, draw, outer ysep=-0.5, anchor=south west] (\umlcdPackageName caption) at
  (\umlcdPackageName.north west) {\umlcdPackageTitle};
  \end{pgfonlayer}
}


\begin{document}
\begin{tikzpicture}%[show background grid]
\begin{package}[SystemLang]{System.Lang} % <<<<-------- The problem is here!

    \begin{interface}{ISet}{7,0}
        \attribute{NoOfItems}
        \operation{Add(element)}
    \end{interface}

\end{package}

\end{tikzpicture} 
\end{document}
share|improve this answer
    
Nice job! Thanks Jake! –  AD. May 16 '12 at 8:27

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.