# Linebreaks in MetaUML

I'm trying to draw an UML diagram with MetaUML for my LaTeX document. Unfortunatly I'm a little bit dissatisfied with the layout because functions with a long signature (i.e. many parameters) become quite long lines and therefore overly broaden the drawn box of the class in which they are in, so I want to make MetaUML split up those long lines.

Is there a way to get a linebreak into attributes of a MetaUML class object?

The handbook does not say anything about it. I need to incorporate my method signatures, but without linebreaks they would make my classes way to wide for readable diagram. A short example (note: the LaTeX builder has to be run with -shell-escape option):

\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{mpost}[mpsettings={input metauml;},use]

Class.Config("Config")
("-key1:char*","-value1:char*","-key2:char*","-value2:char*","-key3:char*","-value3:char*","-key4:char*","-value4:char*","-key5:char*","-value5:char*")
("+setValues(key1:char*,value1:char*, key2:char*,value2:char*, key3:char*,value3:char*,key4:char*,value4:char*,key5:char*,value5:char*)");
drawObjects(Config);

\end{mpost}
\end{document}


Doing so, the line for function setvalues() becomes pretty long and, thus, the drawing of the class in the diagram becomes overly wide. I want to put something like a \newline or \\ in between key3 and value3 in order for the function being distributed over two lines and the drawing becomes a little more compact. While this is, semantically speaking, of course not a sensible example, I think it's getting my point across: I basically want to split overlong lines in classes of the UML diagram.

• Did you mean to ask this on stackoverflow, it seems off topic for this TeX typesetting system site? – David Carlisle Dec 7 '13 at 10:45
• If the question is about typesetting with the Metapost package, please edit your question with an example of code and we'll reopen it. – egreg Dec 7 '13 at 11:41
• Hi, it's indeed about typesetting. I want to add a line break in a Class box of an UML diagram included in a LaTeX document. – Marste Dec 7 '13 at 23:13
• Sorry, but that's very far from being an example; can you add what's needed to be fed to Metapost and compiled? – egreg Dec 7 '13 at 23:16
• Of course, no big deal. I just added a better one, embedded in LaTex, as did it in my actual document. I hope it's a little bit clearer now what I want to (and unfortunately can't) do... – Marste Dec 7 '13 at 23:39

It is possible to have the attributes and methods on multiple lines, for example:

Class.A("Point")
("#x:int",
"#y:int")
("+set(x:int, y:int)",
"+getX():int",
"+getY():int",
"-debug():void",
"test():void");
drawObject(A);


A long method string may be built from its parts using the Metapost string concatenation operator '&', as in "f(" & ")".

https://github.com/ogheorghies/MetaUML/blob/master/manual/fig/class.mp#L21

• This shows different attributes on different lines, but the question appears to ask how to have the same attribute on multiple lines. Is that possible? – Paul Feb 5 '16 at 4:03
• @Paul: Yes, the contents of various attributes or methods may be identical. – Ovidiu Gheorghies Feb 6 '16 at 18:49
• The string concatenation operator you mention is a way for getting the information on two lines in the UML code. The original question (which I also have) is how to get a single method or member in the output diagram on two lines after it is processed in mpost. The code in the MWE have many attributes in the method that would make an output diagram go off the page in his LaTeX document. – Paul Feb 8 '16 at 20:55