-
Notifications
You must be signed in to change notification settings - Fork 9
Timothy Cyrus edited this page Jun 30, 2017
·
4 revisions
MetaUML is bundled with TeX distributions such as TeX Live, so no additional setup steps are usually required.
Create a file named example.mp, with the following contents:
input metauml;
beginfig(1);
Class.A("A")()();
drawObject(A);
endfig;
end
Obtain a PostScript file named example.1 by running:
mpost example.mp
If a PDF file is needed, run the following command instead:
mptopdf example.mp
Create a file called example.tex with the following contents:
\documentclass{article}
\usepackage[pdftex]{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
\title{A Simple MetaUML Example}
\author{John Hacker}
\begin{document}
\maketitle
\section{Example}
\includegraphics{example.1}
\end{document}
Build the MetaUML diagram and then the article:
mpost example.mp
pdflatex example.tex
You might have used the same entity name in more than one diagram, as is the case with A below:
input metauml;
beginfig(1);
Class.A("A")()();
drawObject(A);
endfig;
beginfig(2);
Class.A("AnotherClass")()();
drawObject(A);
endfig;
end
The following workaround is recommended:
input metauml;
beginfig(1);
Class.A("A")()();
drawObject(A);
endfig;
beginfig(2);
save A; % tell MetaPost to forget the old A
Class.A("AnotherClass")()();
drawObject(A);
endfig;
end