METAPOST에서 btex 및 etex를 사용하는 라텍스 라벨 문제

METAPOST에서 btex 및 etex를 사용하는 라텍스 라벨 문제

다음의 간단한 METAPOST 코드는 오류 없이 컴파일되지 않습니다.

verbatimtex
%&latex
\documentclass{article}
\begin{document}
etex
beginfig(1);
z0 = (0,0); z1 = (sqrt(3)*cm,0);
z2 = (sqrt(3)*cm,1cm);
draw z0--z1--z2--cycle;
label.bot(btex $w$ etex, 1/2[z0,z1]);
endfig;
end;

로그 파일에는 다음과 같이 명시되어 있습니다.

This is MetaPost, version 2.01 (MiKTeX 22.3)  14 APR 2022 17:40
Sample.mp Preloading the plain mem file, version 1.005) (./Sample.mp
>> Sample.mp
>> Sample.mpx
! ! Unable to read mpx file.
l.10 label.bot(btex
                $w$ etex, 1/2[z0,z1]);
The two files given above are one of your source files
and an auxiliary file I need to read to find out what your
btex..etex blocks mean. If you don't know why I had trouble,
try running it manually through MPtoTeX, TeX, and DVItoMP

mpxerr 파일에는 다음과 같이 명시되어 있습니다.

This is mikTeX, Version 3.141592653 (MiKTeX 22.3) (preloaded format=tex 2022.4.14)  14 APR 
2022 
17:38
restricted \write18 enabled.
%&-line parsing enabled.
**./mp8HtMK1.tex
(mp8HtMK1.tex
! Undefined control sequence.
l.2 \documentclass
              {article}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
l.3 \begin
      {document}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

[1] [1] )
Output written on mp8HtMK1.dvi (2 pages, 340 bytes).

나는 당황했다. 코드를 확인하고 다시 확인해 보니 올바른 것 같습니다. 컴파일할 때 올바른 실행 파일(예: mpost.exe, latex.exe)이 호출됩니다. 무슨 일이 일어나고 있나요?

나는 이 포럼에서 관련 질문을 읽고 제안된 솔루션을 구현하려고 노력했습니다. 아무것도 작동하지 않습니다.

답변1

2022년이니까 %&latex더 이상 Metapost로 앤티크 통화를 사용할 필요가 없습니다. 이전 문서와 샘플은 실제로 모두 업데이트해야 합니다.

여기에는 두 가지 옵션이 있습니다.

먼저, 단순하게 시험해보고 싶고 mpost복잡한 LaTeX 형식과의 통합에 별로 관심이 없다면 MP 파일이 다음과 같이 보이도록 프리앰블을 교체하십시오.

prologues := 3;
outputtemplate := "%j%c.%{outputformat}";
beginfig(1);
z0 = (0,0); z1 = (sqrt(3)*cm,0);
z2 = (sqrt(3)*cm,1cm);
draw z0--z1--z2--cycle;
label.bot(btex $w$ etex, 1/2[z0,z1]);
endfig;
end;

이것을 컴파일하면 mpost이제 확장자가 있는 파일에 캡슐화된 PostScript 형식의 출력이 생성됩니다 .eps. 이 출력은 PostScript 뷰어로 보거나 epstopdf유사한 도구를 사용하여 PDF로 만들 수 있습니다.

반면에 필요한 경우 유용한 LaTeX 형식을 모두 포함하여 보다 현대적인 스타일로 MP를 사용하려면 using lualatexluamplib패키지로 전환하세요. 이와 같이:

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
beginfig(1);
z0 = (0,0); z1 = (sqrt(3)*cm,0);
z2 = (sqrt(3)*cm,1cm);
draw z0--z1--z2--cycle;
label.bot(btex $w$ etex, 1/2[z0,z1]);
endfig;
\end{mplibcode}
\end{document}

이것을 컴파일하여 lualatexPDF 파일을 직접 생성합니다.

실제로 번거로운 메커니즘을 완전히 제거할 수 있는 현명한 라벨 옵션이 있습니다 btex ... etex. mplib textext 옵션을 확인하세요...

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable} % <---- extra option
\begin{mplibcode}
beginfig(1);
z0 = (0,0); z1 = (sqrt(3)*cm,0);
z2 = (sqrt(3)*cm,1cm);
draw z0--z1--z2--cycle;
label.bot("$w$", 1/2[z0,z1]);
endfig;
\end{mplibcode}
\end{document}

이것을 컴파일하여 lualatex다음과 같은 PDF를 얻습니다.

여기에 이미지 설명을 입력하세요

(희소) 문서를 읽을 수 있습니다luamplib 여기.

관련 정보