2

I tried using MetaUML to create UML diagrams for my LaTeX file, but for some reason, I do not get an output. Still, TEXnicCenter 2.02 (64bit) compiles without error.

I already tried a previous suggestion from here, but it still doesn't produce anything.

I used the following code:

\usepackage{emp}
\usepackage{ifpdf,graphicx}
\ifpdf
  \DeclareGraphicsRule{*}{mps}{*}{}
\fi

\begin{document}
\begin{empfile}
\begin{empcmds}
input metauml;
\end{empcmds}

and in my chapter file, I used the following:

\begin{figure}
\centering
\begin{emp}[classdiag2](20, 20)
Class.A("A")()();
Class.B("B")()();
B.e = A.w + (-20, 0);
drawObjects(A, B);
link(inheritance)(B.e -- A.w);
\end{emp}
\caption[Algorithm concep2t]{The concept of the algorithm}
\label{fig:algorithmConcept2}
\end{figure}

Could the problem be due to the fact that the actual code for the figure is in a seperate .tex file?

Thank you!

1 Answer 1

1

You have to run mpost on the produced file, the emp package doesn't do it automatically.

This works:

\documentclass{article}
\usepackage{emp}
\usepackage{ifpdf,graphicx}
\ifpdf
  \DeclareGraphicsRule{*}{mps}{*}{}
\fi

\begin{document}

\begin{figure}
\centering

\begin{empfile}
\begin{empcmds}
input metauml;
\end{empcmds}
\begin{emp}[classdiag2](20, 20)
Class.A("A")()();
Class.B("B")()();
B.e = A.w + (-20, 0);
drawObjects(A, B);
link(inheritance)(B.e -- A.w);
\end{emp}
\end{empfile}

\caption[Algorithm concep2t]{The concept of the algorithm}
\label{fig:algorithmConcept2}

\end{figure}

\end{document}

If I save this document as boboaut.tex and compile it, I find a file boboaut.mp in the same directory (it's immaterial if the code for the figure environment is in a separate file you load with \input or \include). Then you must open a command window and run mpost boboaut.mp in it. You don't need to do this every time, but only when you add or modify MetaUML graphs. Note that with more than one of them you should name the output .mp file with

\begin{empfile}[<meaningful name>]

where <meaningful name> might be the same as the argument to \label, for instance. You have to manually run every produced .mp file.

Having a \begin{empfile} at the start and \end{empfile} at the end is not recommendable, because it would mean compiling the whole document in a group, which is bad.

enter image description here

Note that there are TikZ libraries for UML diagrams, look in the site for them. They're much more powerful than MetaUML with emp.

1
  • I looked at TikZ for UML but apparently it does not support activity diagrams, which I actually need. But thanks for your answer!
    – BoboAUT
    Mar 18, 2015 at 9:37

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.