Graphics, Figures & Tablesgmp package not work

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
nphaibk
Posts: 23
Joined: Fri Sep 19, 2008 4:34 pm

gmp package not work

Post by nphaibk »

I am trying to just test how to use gmp package to plot images inside Latex.
However, only [MP] showed in the pdf.

I used Texstudio with Miktex29 (also tested with Texlive, same error).

I saw a message "mpost is not recognized as an internal or external command...". But I did configure the mpost in /miktex/bin/mpost and added the option "-enable-write18" for pdflatex.

Can someone get me out of this?

Code: Select all

\documentclass[a4paper,11pt]{article}
\usepackage[shellescape,latex]{gmp}
\begin{document}
\begin{figure}
\centering
\begin{mpost}[mpsettings=input metauml;]
Class.A("A")()();
Class.B("B")()();
B.e = A.w + (-20, 0);
drawObjects(A, B);
link(inheritance)(B.e -- A.w);
\end{mpost}
\caption{A class diagram}
\end{figure}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: gmp package not work

Post by Johannes_B »

Clicking on Open on Writelatex just above the code you posted opens an online LaTeX editor compiling the code sample. It works just fine. The package has last been updated in 2011, so i guess it is not simply solvable by an update.

Try compiling this code on the command line, so we can rule the editor out. Sometimes they are overprotective or do crazy things.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
nphaibk
Posts: 23
Joined: Fri Sep 19, 2008 4:34 pm

Re: gmp package not work

Post by nphaibk »

Thank you very much.

I have tried Texworks (built-in editor with Miktex) but received the same result.

Could you give some detailed guide for compiling the code via cmd line, I have never done with that, either Latex or Metapost. I am a Windows user.
nphaibk
Posts: 23
Joined: Fri Sep 19, 2008 4:34 pm

Re: gmp package not work

Post by nphaibk »

I managed to make it work.

mpost command in gmp package needs to be written in full path, for example:

"C:/somefolder/MikTex29/MikTex/bin/mpost"

(in the package, it is just "mpost").

This works with simple plot "draw (100,0)--(200,0)". For my example above, it still generates some error, but I think it is not related to my original question.

Thanks anyway.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

gmp package not work

Post by Stefan Kottwitz »

Hi nphaibk,

very interesting, that you use MetaPost! Do you have experience with it, or specific reasons to use it? It's very capable, just today many people work with TikZ. The latter works natively within LaTeX and is very user friendly and also capable. Did you compare when choosing the plotting program?

Perhaps have a look at TeXample.net for seeing what I mean. For plotting, there's also PGFPlots which builds on TikZ.

I would be interested in what you make with MetaPost, so it would be great if you would post such images from time to time so that we can learn this code.

Stefan
LaTeX.org admin
Post Reply