2

I am stuck with inheritance diagram using pgf-umlcd. I am using both pgf-umlcd and tikz-uml. There is no error but the inherited line is not showing.

\documentclass[a4paper,10pt]{book}
\usepackage{tikz-uml}
\usepackage{pgf-umlcd}
\begin{document}
\begin{figure}[H]
\centering

\begin{tikzpicture}
  \begin{abstractclass}[text width=5cm]{Shape}{0,0}
  \end{abstractclass}

  \begin{class}[text width=4cm]{Rectangle}{-3,-3}
    \inherit{Shape}
  \end{class}

  \begin{class}[text width=4cm]{Ellipse}{3,-3}
    \inherit{Shape}
  \end{class}
  \begin{class}[text width=4cm]{Circle}{3,-6}
    \inherit{Ellipse}
  \end{class}

\end{tikzpicture}
\end{figure}
\end{document}
  • Are you using an up-to-date distribution? – user11232 Aug 26 '13 at 6:44
  • Dear harish i am using up-to date one. problem is that if i interchange the packages then one of them is not working correctly – NARAYAN CHANGDER Aug 26 '13 at 11:30
2

The error message explains things fully:

! LaTeX Error: Command \umlnote already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

Both packages attempt to define the command \umlnote. There can only be one! – Highlander

You can work around this by choosing which package should maintain normal functionality of \umlnote and loading that one last. Then, between loading the two packages, use something like

\let\umlnoteold\umlnote
\let\umlnote\relax

The first line is optional, and is used to store the first package's version of \umlnote for later use if needed. This might involve patching the first package to use this saved command instead of the original \umlnote. The second line "erases" the definition of \umlnote so that when the second package tries to create the command, \newcommand doesn't throw an error.

\documentclass[a4paper,10pt]{book}
\usepackage{tikz-uml}
\let\umlnotetikzuml\umlnote
\let\umlnote\relax
\usepackage{pgf-umlcd}
\begin{document}
\begin{figure}[H]
\centering

\begin{tikzpicture}
  \begin{abstractclass}[text width=5cm]{Shape}{0,0}
  \end{abstractclass}

  \begin{class}[text width=4cm]{Rectangle}{-3,-3}
    \inherit{Shape}
  \end{class}

  \begin{class}[text width=4cm]{Ellipse}{3,-3}
    \inherit{Shape}
  \end{class}
  \begin{class}[text width=4cm]{Circle}{3,-6}
    \inherit{Ellipse}
  \end{class}

\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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