1

Dear Frank Mittelbach,

I bought your book "The LaTeX Graphics Companion", second edition.

I have a question concerning a MetaPost example in that book, p. 174 above. I have put this in a file called "example.mp". Below my exploits on MetaPost usage:

ubuntu@ubuntu-VirtualBox:~/.../plot$ ls

example.log example.mp LaTeX Graphics Companion, 2nd ed., excerpts.pdf p. 174.pdf

ubuntu@ubuntu-VirtualBox:~/.../plot$ cat example.mp

input piechartmp
SetupColors((.7,.7),this,this);
SetupPercent(this, " %");
Segment(50,"Lions"); Segment(30,"Tigers");
Segment(10,"Hyaena"); Segment(20,"Monkeys");
Segment(20,"Warthogs");
SegmentState(4,this,0.3);
SegmentState(5,invisible,this);
PieChart(2cm,0.15,60,0,0);
Label.auto(0)(name)(outwards,0);
Label(3,4,5)(value)(inwards,0) withcolor white;
Label(1,2)(percent)(inwards,0) withcolor (1,1,0);
Label.lrt(3)("a segment with ",percent)
((0.9,0.8),(0,-2cm)) withcolor .8red;
pickup pencircle scaled 2pt;
Label.auto(2)("a green label")
((0.9,0.1),(-1cm,7mm)) withcolor .8green;

ubuntu@ubuntu-VirtualBox:~/.../plot$ mpost example.mp

This is MetaPost, version 1.504 (kpathsea version 6.0.1)
(mpost.mp (/usr/local/texlive/2011/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.004)) (./example.mp
(/usr/local/texlive/2011/texmf-dist/metapost/piechartmp/piechartmp.mp))
*^C

ubuntu@ubuntu-VirtualBox:~/.gvfs/.../plot$

In the example.log file there is nothing written.

Nevertheless MetaPost loads both example.mp & piechartmp.mp.

What must I do to proceed and obtain an .eps file?

Please let me hear something.

Regards,

Francky Leyn

6

You should include your drawing code into the beginfig()endfig flags and end your file with the end instruction, otherwise nothing will be produced.

input piechartmp;
beginfig(1);
SetupColors((.7,.7),this,this);
SetupPercent(this, " %");
Segment(50,"Lions"); Segment(30,"Tigers");
Segment(10,"Hyaena"); Segment(20,"Monkeys");
Segment(20,"Warthogs");
SegmentState(4,this,0.3);
SegmentState(5,invisible,this);
PieChart(2cm,0.15,60,0,0);
Label.auto(0)(name)(outwards,0);
Label(3,4,5)(value)(inwards,0) withcolor white;
Label(1,2)(percent)(inwards,0) withcolor (1,1,0);
Label.lrt(3)("a segment with ",percent)
((0.9,0.8),(0,-2cm)) withcolor .8red;
pickup pencircle scaled 2pt;
Label.auto(2)("a green label")
((0.9,0.1),(-1cm,7mm)) withcolor .8green;
endfig;
end.

enter image description here

More precisely, the output of your statements between beginfig(n) and endfig flags, where n is an integer, will be saved in an yourfilename.n file, which is in fact an mps file (MetaPost PostScript, a subset of EPS). If you omit the final end instruction, MetaPost will enter interactive mode and be waiting for another instruction of yours. Note that a single .mp file can produced several drawings, each one corresponding to a different pair of beginfig()… endfig flags (with different integer arguments, of course).

  • Maybe input piechart doesn't require a semicolon, but adding it seems clearer. – egreg Nov 25 '15 at 9:51
  • Indeed it doesn't require it, but you're right, it would be less confusing so. Done. – Franck Pastor Nov 25 '15 at 9:59
  • I've rolled back this answer to remove the addition of the OP's edit because this information should be edited into the question, not being part of the answer. – cfr Nov 25 '15 at 14:18
  • When I open this with gv, I get an error, namely: gist.github.com/d50cb32135077a63817d – Faheem Mitha Nov 25 '15 at 15:40
  • @FaheemMitha Probably the same problem (and solution) as here: tex.stackexchange.com/questions/279967/… – Franck Pastor Nov 25 '15 at 15:43

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.