# metauml installation and usage error

This question is a bit broad but I am trying to install metauml (I am using Mac and texlive). I downloaded the package and ran the install script which put a metauml directory under the metapost directory (which I Was expecting). However, I cannot get it to run. I have this code:

\documentclass[a4paper,12pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[ngerman]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[margin=1.5cm]{geometry} %layout

% this is needed for forms and links within the text
\usepackage{hyperref}

% 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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE DOCUMENT BEGINS                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Class diagram}
\end{document}


The metadiagram.mp is in the same folder and is defined as follows:

input metauml;
beginfig(1);
Class.World("World")
("-age: int",
"#ressources: List")
("+sayHello(): void");

Class.NoHuman("Human")
("-birthday: Date",
"-nickname: String",
"-secret: String")
("+code(language: Language): Program");

leftToRight(50)(World, NoHuman);
drawObjects(World, NoHuman);

item(iAssoc)("1")(obj.n     = .2[World.e,NoHuman.w]);
item(iAssoc)("has >")(obj.n = .5[World.e,NoHuman.w]);
item(iAssoc)("0..*")(obj.n  = .8[World.e,NoHuman.w]);

endfig;
end


I am getting the error: Cannot determine size of graphic in metadiagram.mp (no BoundingBox)

Can anyone help ?

-

You can't include a .mp file, which should be processed by Metapost beforehand.

How to run Metapost depends on your operating system and TeX distribution; possibly TeXShop and TeXworks have menu items for this. In general you can open a Terminal window, cd to the directory containing the file and do

mpost metadiagram.mp


This will produce a file metadiagram.1, because you're saying beginfig(1) and

\includegraphics{metadiagram.1}


will do.

Note that what you're using for loading graphicx is wrong. It should be

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


There's another way to proceed, with the gmp package. For your case the input should be

\documentclass[a4paper,12pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[ngerman]{babel} % this is needed for german umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[margin=1.5cm]{geometry} %layout

\usepackage[shellescape]{gmp}

\usepackage{ifpdf}
\ifpdf
\DeclareGraphicsRule{*}{mps}{*}{}
\fi

% this is needed for forms and links within the text
\usepackage{hyperref}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE DOCUMENT BEGINS                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Class diagram}

\begin{mpost}[mpsettings={input metauml;},use]
Class.World("World")
("-age: int",
"#ressources: List")
("+sayHello(): void");

Class.NoHuman("Human")
("-birthday: Date",
"-nickname: String",
"-secret: String")
("+code(language: Language): Program");

leftToRight(50)(World, NoHuman);
drawObjects(World, NoHuman);


If you process this document (notice that the Metapost source is embedded in it) with the -shell-escape switch (a preference in TeXShop allows you to enable it), then the Metapost run will be performed automatically.