4

Does anyone out there have a cute way of previewing images generated by MetaPost? As far as I can tell, after making the .mp file there is a bit a process for viewing the file. I figure there aught to be an easy script to write that would convert the .mp file to a .pdf, and then open the .pdf with Adobe, or something along those lines, but I lack the ability to write BASH code, or even know the proper terminology to use to talk about such scripts. (BASH code, shell scripts... Something)

Edit: I forgot to mention, I was looking for such a script that would run automatically after compiling in TexMaker. Again, I assume there must be a way to do such a thing, but I don't know how. I want to be able to click the "MPost" build option, and then see a preview, without needing to go through the trouble manually running the conversion command.

  • 1
    You mean, like mptopdf? Note that one complication is that there need not be a one-to-one mapping from .mp to .pdf, so the situation is rather unlike the usual .tex case. (There need not be such a mapping there either but there usually is. That's not so for an .mp file.) – cfr Mar 22 '15 at 21:12
  • Try the \convertMPtoPDF command... – Malipivo Mar 22 '15 at 21:16
  • @Malipivo Is that a command in the document, or in the command line? I found the command that converts them, but I want something that will open up the document as soon as I build it in TexMaker- looking at my post I see I omitted that. Let me append to my question. –  Mar 22 '15 at 21:32
  • If you are on Mac OS X, there are the very handy Perl scripts of Nicola Vitacolonna (based on mptopdf, but much more friendly) for previewing MetaPost programs: https://users.dimi.uniud.it/~nicola.vitacolonna/home/software/metapost-texshop/. They were devised for TeXShop, but they can be run from any Unix command line, and so they should be compatible with any editor which can launch external tasks. I don't know about their compatibility with Windows. – Franck Pastor Mar 22 '15 at 21:34
  • I'm using Ubuntu, should it still work? –  Mar 22 '15 at 21:34
  • @Anthony I think so, it's also a Unix. But don't take my word on it, since I don't know anything more about Ubuntu. Better give it a try (don't forget to read the very well-made documentation carefully) and in case of problems you may contact Nicola Vitacolonna directly. – Franck Pastor Mar 22 '15 at 21:39
  • I've forgotten, there is also the possibility of including the MetaPost code into a LuaLaTeX program, thanks to the luamplib package: https://www.ctan.org/pkg/luamplib. In combination with the standalone class, it produces ready-to-use PDF outputs. I've often used it this way myself on this site, for example here: http://tex.stackexchange.com/questions/234116/how-to-fill-an-area-below-sine-wave/234158#234158 – Franck Pastor Mar 22 '15 at 21:48
  • I've asked the same question time ago. Probably one of the answers there might be of help. See http://tex.stackexchange.com/q/118208/31910. – Sterry Mar 22 '15 at 22:03
  • You can use arara or something to convert them and maybe even to open the results. (Or you can configure your editor to open the results.) But the question remains: which PDF should be opened? All of them? Some of them? – cfr Mar 22 '15 at 22:46
  • On OSX, Skim.app does on-the-fly conversion to PDF with live updating - the trick is to use prologues:=3 and an outputtemplate with an extension of .eps. If you open the .eps file in Skim, and turn on the "check for file changes" option (on the Sync tab), it will automagically update the PDF copy when the .eps changes. – Thruston Mar 22 '15 at 22:59
  • @cfr Nicola Vitacolonna's scripts (nv-metapost and nv-metafun) don't choose: they both create a PDF file that includes all the figures defined in the MetaPost file (each figure having its own page), and they both open this multiple-paged PDF for viewing. – Franck Pastor Mar 23 '15 at 07:34
  • @fpast Good to know. But what I meant was: this is something you have to decide. You can create a one-many-one mapping, but that is a decision and might or might not be what you want. (In my case, it would not typically be at all what I wanted!) – cfr Mar 23 '15 at 18:12

0 Answers0