[NTG-context] Ampersand in Metapost

Aditya Mahajan adityam at umich.edu
Fri May 14 03:07:42 CEST 2010


On Fri, 14 May 2010, Mojca Miklavec wrote:

> On Thu, May 13, 2010 at 23:45, Marco <netuse at lavabit.com> wrote:
>> On Thu, 13 May 2010 22:58:46 +0200, Hans Hagen <pragma at wxs.nl> wrote:
>>> On 13-5-2010 9:18, Marco wrote:
>>> > Hi,
>>> >
>>> > I have a problem producing an ampersand in metapost. In ConTeXt it
>>> > works as expected. Have a look at the following example.
>>> >
>>> > \starttext
>>> > \&  % OK
>>> > \startMPcode
>>> > label(textext("\&"),origin); % produces error
>>> > \stopMPcode
>>> > \stoptext
>>> >
>>> > The compile time error message is as follows:
>>> >    ! Misplaced alignment tab character&.
>>> >    l.1 \MPLIBsettext{1}{&
>>>
>>> \letterpercent
>> Doesn't work. I suppose you mean \letterampersand. If I change \& into
>> \letterampersand I get exactly the same error as \& produces (BTW:
>> \letterpercent also produces an error, but a different one).
>
> So:
> - label(textext("\letterbackslash\letterampersand"),origin);
> - label(textext("\letterbackslash\&"),origin);
>
> This is because the commands are interpreted with TeX before they are
> written to mpgraph.mp. The \letterampersand or \& generates the
> character & alone: you need to preceed it with backslash, so that
> metapost finally knows what to do.

So, should all the \letter... commands (basically anything generated from 
char-def.lua) be unexpandable?

You can also try \noexpand\letterampersand

Aditya


More information about the ntg-context mailing list