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

luigi scarso luigi.scarso at gmail.com
Wed Dec 27 10:56:05 CET 2023


On Sun, 24 Dec 2023 at 20:49, luigi scarso <luigi.scarso at gmail.com> wrote:

>
>
> On Sun, 24 Dec 2023 at 19:42, Ben Frank <ben.frank at mail.de> wrote:
>
>> Hi,
>>
>> On 24.12.23 19:33, luigi scarso wrote:
>> > Here I have
>> >
>> > $> mpost test.mp <http://test.mp>
>> > This is MetaPost, version 2.02 (TeX Live 2023) (kpathsea version 6.3.5)
>> > (/<...>/tex-2023/texmf-dist/metapost/base/mpost.mp <http://mpost.mp>
>> > (/<...>/tex-2023/texmf-dist/metapost/base/plain.mp <http://plain.mp>
>> > Preloading the plain mem file, version 1.005) ) (./test.mpfatal:
>> Command
>> > failed: etex --parse-first-line --interaction=nonstopmode mpK6cPmm.tex;
>> > see mpxerr.log
>> >  >> test.mp <http://test.mp>
>> >  >> test.mpx
>> > ! ! Unable to read mpx file.
>> > l.10    label.lft(btex
>> >                         \textbf{J} etex,origin);
>> > Transcript written on test.log.
>>
>> That's the error I mentioned you would get because the wrong format is
>> chosen due to the wrongly output format comment.
>>
>
> ok
> $> mpost -record -debug test.mp
> shows what happens:
>
>  %&latex
>    \documentclass{article}
>    \begin{document}
>
> \gdef\mpxshipout{\shipout\hbox\bgroup%
>   \setbox0=\hbox\bgroup}%
> \gdef\stopmpxshipout{\egroup  \dimen0=\ht0 \advance\dimen0\dp0
>   \dimen1=\ht0 \dimen2=\dp0
>   \setbox0=\hbox\bgroup
>     \box0
>     \ifnum\dimen0>0 \vrule width1sp height\dimen1 depth\dimen2
>     \else \vrule width1sp height1sp depth0sp\relax
>     \fi\egroup
>   \ht0=0pt \dp0=0pt \box0 \egroup}
> \mpxshipout% line 10 ./test.mp
> \textbf{J}%
> \stopmpxshipout
> \end{document}
>
> i.e. there is an  initial space before %&latex that should be not there
> (and indeed the next code  is ok, if there are no spaces after verbatimtex:
> outputtemplate := "%j-%2c.mps";
>
> verbatimtex
> %&latex
>    \documentclass{article}
>    \begin{document}
> etex
>
> beginfig(1)
>    label.lft(btex \textbf{J} etex,origin);
> endfig;
>
> end;
> end
> )
>
> I need to check.
>
>
Indeed, it seems an oversight :
in mpxout.w
verbatim_written = 1; at line 664 should be moved at line 659

    655       if (!verbatim_written)
    656          mpx_copy_mpto(mpx, outfile, FIRST_VERBATIM_TEX);
    657       else
    658          mpx_copy_mpto(mpx, outfile, VERBATIM_TEX);
    659       verbatim_written = 1;
    660       fprintf(outfile,"%s", mpx_postverb[mode]);
    661     } else {
    662       mpx_error(mpx,"unmatched etex");
    663     }
    664     /*verbatim_written = 1;*/

 --
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/metapost/attachments/20231227/44dd0f7a/attachment.htm>


More information about the metapost mailing list.