我是 METAPOST 的初学者。我只是想画一个箭头。我在 TeXstudio 2.11.0 中输入以下代码:
% This program uses the METAPOST language to produce the eps file of {fig:R_5}.
% In TeXstudio, click Tools->Commands->MetaPost to compile this file.
prologues:=3;
filenametemplate "%j.eps";
input boxes
beginfig(1);
% The upper bound of $z_1$.
z1UB=8.6cm;
% Draw the $z_1$-axis.
drawarrow (0,0)--(z1UB,0);
endfig;
end;
然后我点击 Tools->Commands->MetaPost 来编译上述文件。出乎意料的是,我收到了以下错误消息:
Process started: mpost.exe -interaction=nonstopmode R_5.mp
Process exited with error(s)
日志文件是:
This is MetaPost, version 1.803 (MiKTeX 2.9 64-bit) 2 SEP 2016 16:49
**R_5.mp
(mpost.mp (C:/Program Files/MiKTeX 2.9/metapost/base/plain.mp
Preloading the plain mem file, version 1.004) ) (./R_5.mp
(C:/Program Files/MiKTeX 2.9/metapost/base/boxes.mp)
>> (x1UB,y1UB)
>> 243.77965
! Equation cannot be performed (pair=numeric).
<to be read again>
;
l.10 ^^Iz1UB=8.6cm;
I'm sorry, but I don't know how to make such things equal.
(See the two expressions just above the error message.)
! Missing `)' has been inserted.
<to be read again>
,
l.13 drawarrow (0,0)--(z1UB,
0);
I found no right delimiter to match a left one. So I've
put one in, behind the scenes; this may fix the problem.
>> x1UB
! Undefined x coordinate has been replaced by 0.
<to be read again>
,
l.13 drawarrow (0,0)--(z1UB,
0);
I need a `known' x value for this part of the path.
The value I found (see above) was no good;
so I'll try to keep going by using zero instead.
(Chapter 27 of The METAFONTbook explains that
you might want to type `I ???' now.)
>> y1UB
! Undefined y coordinate has been replaced by 0.
<to be read again>
,
l.13 drawarrow (0,0)--(z1UB,
0);
I need a `known' y value for this part of the path.
The value I found (see above) was no good;
so I'll try to keep going by using zero instead.
(Chapter 27 of The METAFONTbook explains that
you might want to type `I ???' now.)
! Extra tokens will be flushed.
<to be read again>
,
<argument> ,
0)
_finarr->draw._apth(TEXT0)
;filldraw.arrowhead._apth(TEXT0)
<to be read again>
;
l.13 drawarrow (0,0)--(z1UB,0);
I've just read as much of that statement as I could fathom,
so a semicolon should have been next. It's very puzzling...
but I'll try to get myself back together, by ignoring
everything up to the next `;'. Please insert a semicolon
now in front of anything that you don't want me to delete.
(See Chapter 27 of The METAFONTbook for an example.)
! Extra tokens will be flushed.
<to be read again>
,
<argument> ,
0)
_finarr->...TEXT0);filldraw.arrowhead._apth(TEXT0)
<to be read again>
;
l.13 drawarrow (0,0)--(z1UB,0);
I've just read as much of that statement as I could fathom,
so a semicolon should have been next. It's very puzzling...
but I'll try to get myself back together, by ignoring
everything up to the next `;'. Please insert a semicolon
now in front of anything that you don't want me to delete.
(See Chapter 27 of The METAFONTbook for an example.)
[1] )
1 output file written: R_5.eps
您能告诉我如何编写正确的代码吗?非常感谢。
答案1
Metafont/Metapost 中的标准约定是z
(带下标)表示一对。因此您无法设置z1UB=8.6cm
。
当你这样做
z1=(1,2);
你基本上是在做
x1=1;y1=2;
对变量使用不同的名称。
或者,
prologues:=3;
filenametemplate "%j.eps";
input boxes
beginfig(1);
% The upper bound of $z_1$.
z1UB=(8.6cm,0);
% Draw the $z_1$-axis.
drawarrow (0,0)--z1UB;
endfig;
end;
您还可以使用
drawarrow origin--z1UB;