3

I got interested in learning MetaPost but for some reason i can't find any reliable source on where i am supposed to start. All the manuals and guides i found start literally out of nowhere and what's even worse is that they all seem to be considering UNIX only.

I have TeXnicCenter and Miktex.

Can anyone explain me like i'm five how and where to start creating and compiling my very first MetaPost file (or preferably image) using any of the tools i am having?

Or do i need any other compiler? Sorry i can't provide any further information but i am simply stuck and can't figure out where to begin.

5

Give ConTeXt a chance. You won't get a barebone METAPOST compiler, but you will get a metapost layer, named metafun, tightly integrated with TeX.

Open your editor, TeXnicCenter should make it, and write

\starttext
\startMPcode
draw unitsquare scaled 10 ;
\stopMPcode
\stoptext

And compile this text with ConTeXt (MkIV is the current engine). You'll get a square.

Hans Hagen, ConTeXt main developper, works under Windows. His editor is SciTe, which is recommended as an ConTeXt editor but many other editors do the job. You can find some of them is this (uncomplete) ConTeXt wiki page.

I have been learning METAPOST for one year and really enjoy it, although the learning curve is quite step. Some references :

Troy Henderson, MP for beginners
Andre Heck, Learning METAPOST by doing
Hans Hagen, Metafun

4

You might also try lualatex and the luamplib package.

If you have a full MikTeX installation, you should already have the lualatex version of latex installed, so TeXnicCenter should already have created an output profile that says something like LuaLaTex -> PDF. If so, choose this profile. If not, workout how to add one.

Then create a document like this:

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    draw fullcircle xscaled 144 yscaled 89;
    label("Hello \TeX", origin);
endfig;
\end{mplibcode}
\end{document}

and compile it with the lualatex output template. This should produce a PDF file containing something like this:

enter image description here

There are a couple of points to note:

  • You need both the luatex85 and the luamplib packages, but you don't have to use the standalone class.

  • The \mplibtextextlabel{enable} line is important because it makes mplib process all string labels automatically through TeX. This means you don't have to muck about with btex and etex; all you have to do is give a string primary to label and it will do the rest.

  • This is good because it means you automatically use the same fonts in the MP drawings as you are using in rest of the document.

  • It also means that you can do things like label("$" & decimal x & "$", origin); (trust me, this is useful...)

  • The default units are still PostScript points (72 = 1 in = 2.54 cm);

  • The \begin{mplibcode}...\end{mplibcode} environment produces a horizontal mode box with the reference point set to the bottom left corner of your drawing. So the label in the example above is in the middle, even though I drew it at (0, 0).

  • The learning resources on the Metapost page on CTAN are all useful.

  • Eventually you might want to read more about luamplib

  • Apart from the specifics about TeXnicCenter, your question is quite close to being a duplicate of this one.

1
  • thanks a lot for your very detailed and informative answer, i really appreciate your time and effort. It sounds very promising and i can't wait to start. Best regards – Zest Oct 25 '18 at 12:12

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.