[metapost] Can't get write/scantokens to work.

Stephan Hennig mailing_list at arcor.de
Wed Sep 19 21:03:05 CEST 2007


[Forgot to copy this mail to the list.]

Michaël Cadilhac schrieb:

> I'm dreadfully sorry, I would love to understand the ins and outs of
> MetaPost, but I'm just not at this stage.  The very thing I want to do
> is something like that :
> 
> for i := 1 upto 2:
>   beginfig(i)
>     string phantom;
>     phantom := if i = 1: "\phantom" else: "" fi;
>     label (TEX("This is a " & phantom & "{funny} thing"));
>   endfig;
> endfor;
> 
> That is to say, enable some part of TeX text according to the picture
> number (as you can imagine, it's for a presentation).  I hope we've not
> misunderstand this.

I guess you're looking for the latexmp package.  That provides a textext
macro that takes its argument as string (as TEX() does) and so you can
dynamically decide what to process by LaTeX.

input latexmp
setupLaTeXMP(class="article",options="12pt",fontencoding="T1");
prologues := 2;
for i := 1 upto 2:
  beginfig(i)
    string phantom;
    phantom := if i = 1: "\phantom" else: "" fi;
    label (textext("This is a " & phantom & "{funny} thing"), origin);
  endfig;
endfor;
end

Compile this two times with

mpost -latex file.mp

The package provides various set-up options, e.g., in general, I prefer
to provide an external preamble file (via option preamblefile).


> And BTW, you're giving time to help me with this, so I want to give you
> some of my time in return :-) Question is, as I'm an Emacs developer, do
> you need any fix/fanciness on the Meta* mode of Emacs ?

Accidentally, just a few days ago I asked Lennart Borgman if it were
possible to add support for MetaPost and (La)TeX to his mumamo-mode.
I've attached my original mail.  I think Lennart is working on the
feature, but as I understand he doesn't know much about meta-mode and
tex-mode.  So, if you could have a look at that, it would be great.

Best regards,
Stephan Hennig



> Hi Lennart,
> 
> would it be possible to add support for the combination
> metapost-mode/LaTeX-mode/latex-mode/tex-mode to mumamo.el?
> 
> In short the following cases should be recognized in metapost-mode:
> 
> (i) Text between identifiers "verbatimtex" and "etex" should be
> highlighted according to a TeX mode's rules as in
> 
> verbatimtex
> \documentclass{article}
> \usepackage[ngerman]{babel}
> \usepackage{mathptmx}
> \begin{document}
> etex
> 
> 
> (ii)  Text between identifiers "btex" and "etex" should be highlighted
> according to a TeX mode's rules as in
> 
> label(btex Brief"|inhalt etex, origin);
> 
> Currently "| (from package babel: break ligatures) breaks font-locking
> completely.  The rest of the mp file is seen as belonging to a
> MetaPost-string, where in fact there is no string at all.
> 
> 
> (iii)  Text between double quotes should be highlighted according to
> (AUC)TeX mode rules if it is an argument to the following commands:
> 
> TeX() or textext()
> 
> As in
> 
> textext("\emph{Briefinhalt}")  or
> TEX("\emph{Briefinhalt}")
> 
> Additionally, multiple string can be concatenated as in
> 
> textext("$n_{" & decimal(i) & "}$")
> TEX("$n_{" & decimal(i) & "}$")
> 
> All strings ("$n_{" and "}$") should be highlighted according to a TeX
> mode's rules.  (I hope for the best, that AUCTeX will still be able to
> recognize both $'s as belonging to the same math environment.)
> 
> I've attached a small example that contains all the cases (but doesn't
> compile).
> 
> Thanks,
> Stephan Hennig
> 
> 
> verbatimtex
> \documentclass{article}
> \usepackage[ngerman]{babel}
> \usepackage{mathptmx}
> \begin{document}
> etex
> beginfig(1);
>   label(textext("Brief\/inhalt"), origin);
>   label(TEX("Brief\/inhalt"), origin);
>   label(textext("$n_{" & decimal(i) & "}$"), (5mm*i,0));  or
>   label(TEX("$n_{" & decimal(i) & "}$"), (5mm*i,0));.
>   label(btex Brief"|inhalt etex, origin);
> endfig;
> end




More information about the metapost mailing list