0

I am on Overleaf, using gmp + metauml to create a UML class diagram, in which I wish to use LaTeX commands to better format the text. I tried my best to read the manuals for both packages and scour through TeX.SE but cannot find a way.

Specifically, I wish to use the \vphantom{} comamnd to better format the attributes of a class and fix the problem presented in MetaUML Adds Extra Vertical Spaces.

Attempting to use \textbf{} with

\documentclass{article}
\usepackage[shellescape,latex]{gmp}

\begin{document}
\begin{mpost}[mpsettings={input metauml;}]
    beginfig(1);
        Class.subject("Subject")("-test:\textbf{h}")(static "+attach(o : Observer)");
        drawObjects(subject);
    endfig;
    end
\end{mpost}
\end{document}

results in expansion of the command as shown below:

enter image description here

Attempting to use \vphantom{} results in output

enter image description here

and errors: enter image description here

Any help is appreciated.

2
  • 3
    Are you sure you can use TeX macros in a metauml picture? By the way, you shouldn't have end in the mpost environment.
    – egreg
    Jul 23, 2021 at 19:31
  • @egreg You're right, it turned out that I cannot use TeX macros in metauml. Thank you for the pointers. Accepting Thruston's answer as it provides a suitable working alternative.
    – Bryan K.
    Sep 30, 2021 at 1:46

1 Answer 1

2

You might have better luck using lualatex and luamplib. Here is your example reworked for that environment.

\documentclass[border=5mm]{standalone}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}
input metauml
beginfig(1);
Class.subject("Subject")("-test:\textbf{h}")(static "+attach(o : Observer)");
drawObjects(subject);
endfig;
\end{mplibcode}
\end{document}

compiling this with lualatex produces this:

enter image description here

Note that you have to explicitly set the font to Times (or equivalent) at the document level, and that you need to have \mplibtextextlabel{enable} set so that all labels are automagically processed with the TEX() macro.

Note also that Overleaf has an option (menu top left) to change the compiler to lualatex. And I can confirm that the reworked example I show, produces the same output there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .