亲爱的弗兰克·米特尔巴赫,
我买了你的书《LaTeX 图形伴侣》第二版。
我对该书中的 MetaPost 示例(上文第 174 页)有疑问。我已将其放在名为“example.mp”的文件中。以下是我对 MetaPost 用法的利用:
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$
文件中example.log
没有写任何内容。
尽管如此,MetaPost 还是加载了example.mp
& piechartmp.mp
。
我必须做什么才能继续并获取.eps
文件?
请让我听听一些事情。
问候,
弗兰基·莱恩
答案1
您应该将您的绘图代码包含到beginfig()
...endfig
标志中并用指令结束您的文件end
,否则不会产生任何内容。
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.
beginfig(n)
更准确地说,您在和endfig
标志之间的语句的输出(其中n
是整数)将保存在一个yourfilename.n
文件中,该文件实际上是一个mps
文件(MetaPost PostScript,EPS 的一个子集)。如果您省略最后一条end
指令,MetaPost 将进入交互模式并等待您的另一条指令。请注意,单个.mp
文件可以生成多个绘图,每个绘图对应于不同的beginfig()… endfig
标志对(当然具有不同的整数参数)。