
vardef 매크로 이름 "mymacro@#"이 생성된 메타포스트 파일에 "mymacro@##"로 기록되는 gmp 버그가 발생한 것 같습니다. gmp 패키지를 처음 사용하는데 뭔가 빠졌을 수 있습니다. 누구든지 이것이 버그인지 확인할 수 있습니까? 실제로 버그인 경우 해결 방법이나 가능한 수정 사항이 있습니까?
티아!
TeX 입력:
\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{mpost}
u=2cm;
vardef mymacro@#=
pair @#.mid;
@# := (0u, 0u) -- (50u, 75u);
@#.mid := 0.5[(0u, 0u), (50u, 75u)];
enddef;
path a;
mymacro.a;
draw a;
\end{mpost}
\end{document}
로그 파일:
This is MetaPost, version 2.00 (TeX Live 2019) (kpathsea version 6.3.1) 29 NOV 2019 13:41
**foo+mp0001
(/usr/local/texlive/2019/texmf-dist/metapost/base/mpost.mp
(/usr/local/texlive/2019/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.005) ) (./foo+mp0001.mp
>> mymacro.a
! Isolated expression.
<to be read again>
;
l.14 mymacro.a;
I couldn't find an `=' or `:=' after the
expression that is shown above this error message,
so I guess I'll just ignore it and carry on.
>> unknown path a
! Improper `addto'.
<to be read again>
withpen
draw->...:also(EXPR0)else:doublepath(EXPR0)withpen
.currentpen.fi._op_
<to be read again>
;
l.15 draw a;
This expression should have specified a known path.
So I'll not change anything just now.
[1] )
1 output file written: foo+mp0001.mps
메타포스트 파일:
%% Do not edit, this file has been generated
%% automatically by foo.tex via gmp.sty
outputtemplate:= "%j.mps";
beginfig(1);
u=2cm;
vardef mymacro@##= pair @##.mid;
@## := (0u, 0u) -- (50u, 75u);
@##.mid := 0.5[(0u, 0u), (50u, 75u)];
enddef;
path a;
mymacro.a;
draw a;
endfig;
end.
답변1
네, 버그인 것 같습니다. 환경 을 스캔할 때 mpost
패키지는 의 catcode를 #
로 설정하지 않으므로 12
TeX는 평소처럼 이를 두 배로 늘립니다. \do\#
다음에 추가해야 합니다 \gmp@otherchars
.
\makeatletter % added vvvvv
\def\gmp@otherchars{\do\!\do\=\do\:\do\"\do\?\do\'\do\`\do\|\do\#}
\makeatother
이를 추가하고 페이지에 맞게 줄 길이를 약간 줄이면 코드가 작동합니다.
\documentclass{article}
\usepackage[shellescape]{gmp}
\makeatletter
\def\gmp@otherchars{\do\!\do\=\do\:\do\"\do\?\do\'\do\`\do\|\do\#}
\makeatother
\begin{document}
\begin{mpost}
u=2cm;
vardef mymacro@#=
pair @#.mid;
@# := (0u, 0u) -- (5u, 7u);
@#.mid := 0.5[(0u, 0u), (5u, 7u)];
enddef;
path a;
mymacro.a;
draw a;
\end{mpost}
\end{document}