HomeDownloadsGoals and PropagandaFAQInstallation HowTo-sContributorsNews
 

MetaUML: Frequently Asked Questions

Which is the minimal MetaUML diagram?

Create a file example.mp with the following contents:

input metauml;
beginfig(1);
    Class.A("A")()();
    drawObject(A);
endfig;
end

Save it, then compile it with the command:

mpost example.mp

If everything goes well, the mpost program should end without prompting you with any questions, and you should get on the disk a PostScript file called metauml.1

What do I need to compile the minimal example?

Please install the latest TeX Live distribution. The TeX programs that come with some Linux distributions (e.g. Fedora Core) are antiquated and need to be removed and replaced with the TeX Live version.

Make sure that MetaUML is properly installed as a MetaPost package. You should consult the documentation of your TeX distribution on how this is done. The install script in MetaUML gives a hint on this.

If you still you can't get it to work, feel free to write to the maintainer of MetaUML and attach the very file that you were trying to compile. Also include the output of the mpost program.

How do I get standalone PDF diagrams?

mptopdf example.mp

Older versions of MetaUML happened to yield some error when this command was run, but this issue is fixed in the latest release.

How do I include MetaUML diagrams in my LaTeX article?

Create a file article.tex:

\documentclass{article}

% The following is needed in order to make the code compatible
% with both latex/dvips and pdflatex.
\ifx\pdftexversion\undefined
\usepackage[dvips]{graphicx}
\else
\usepackage[pdftex]{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
\fi

\title{A Minimal Example for MetaUML}
\author{John Hacker}

\begin{document}

\maketitle

\section{Example}
\includegraphics{example.1}

\end{document}

Provided that you have compiled example.mp with

mpost example.mp

you obtain a pdf article by running

pdflatex article.tex

Why these strange errors when having multiple diagrams in an mp file?

Consider using:

input metauml;

beginfig(1);
    Class.A("A")()();
    drawObject(A);
endfig;

beginfig(2);
    save A; % tell MetaPost to forget about the old A
    
    Class.A("AnotherClass")()();
    drawObject(A);
endfig;
end
        

The following code just won't work:

input metauml;

beginfig(1);
    Class.A("A")()();
    drawObject(A);
endfig;

beginfig(2);
    Class.A("AnotherClass")()();
    drawObject(A);
endfig;
end
        

This happens because the 'A' from the second figure becomes in conflict with the 'A' from the first figure.