[metapost] Outputtemplate influences %& format comment parsing in verbatimtex

Ben Frank ben.frank at mail.de
Sun Dec 24 12:51:14 CET 2023


Dear mailing list,

consider the following code:

```
outputtemplate := "%j-%2c.mps";

verbatimtex %&latex
   \documentclass{article}
   \begin{document}
etex

beginfig(1)
   label.lft(btex \textbf{J} etex,origin);
endfig;

end;
```

Why does it not compile when fed to mpost as is (because of the space 
before %&latex carrying into the output preventing its parsing as a 
format comment) but compile fine when the outputtemplate line is 
commented (i.e., the space seems to be gobbled as expected)?

Bonus: If this is a known bug/feature/… (I could not find something 
about this by means of a simple web search) a reference to the design 
rationale would be appreciated.

Note: I am not asking how to make this example compile regardless (I 
know that I can remove the space before %& or put the format comment on 
a new line). I am specifically asking about the cause of the interaction 
and its rationale/intention.

Best,
Ben

P.S.: I have originally asked this on TeX.SX 
(https://tex.stackexchange.com/questions/705570) and was pointed to this 
mailing list instead.


More information about the metapost mailing list.