I'm using LuaTex to draw some UML diagrams in MetaUML. The diagrams appear left align in the page. How do I center them?

I tried \centering before the mplibcode environment and also tried enclosing the environment in center environment. But did not work.

  • 1
    I know you have found the answer, but even so a small MWE would enhance your question. (And the answer...)
    – Thruston
    May 19, 2020 at 18:40
  • Okay. I will add it to the question and answer May 20, 2020 at 12:31

1 Answer 1


I just found the solution. Adding \mplibforcehmode makes \centering work for mplibcode environments.

\mplibforcehmode When this macro is declared, every mplibcode figure box will be type- set in horizontal mode, so \centering, \raggedleft etc will have effects. \mplibnoforcehmode, being default, reverts this setting. (Actually these commands redefine \prependtomplibbox. You can define this command with anything suitable before a box.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.