1
我試圖做到以下幾點:字符串在mpost for循環
xN := 200;
topp:= 3;
bott := -3;
spac := 20;
% draw number line
draw (0,0)--(xN,0);
last := 3;
% draw 4 tick marks from left side
for i := 0 upto last:
draw (spac*i,topp)..(spac*i,bott);
endfor;
% label tick marks accordingly
for i := 0 upto last:
label.bot(btex $x_{i}$ etex, (i*spac,bott));
endfor;
目標是讓左勾是X_0,下一個是X_1,等等。但是由於我在tex環境中進行了標記,因此它不使用label
命令中的i
作爲變量,而只是一個字母。結果是每個刻度標記都標記爲「x_ {i}」。對不起,如果這不清楚,這是我第一次嘗試使用metapost,我認爲必須有一種方法來使用循環而不是蠻橫的強制它。