TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the "gmp" package which allows to insert MetaPost coding (placed inside an mpost or mpost* environment) in a LaTeX source file. In few words, it does approximately the same job as other packages like "emp" or "mpgraphics", with additional features that are not relevant here.

In particular, "gmp" defines as an (xkeyval-type) option key named everymp which is supposed to contain some code to be inserted at the beginning of each MetaPost files produced. Here is a minimal example:

\usepackage[everymp= {input boxes;}]{gmp}
    % here the MetaPost code

Here the everymp key contains the metapost instruction input boxes ; which is thus supposed to be inserted at the beginning of the MetaPost file produced by the compilation. But what I obtain is different:

%% Do not edit, this file has been generated
%% automatically by bug-everymp.tex via gmp.sty

outputtemplate:= "%j.mps";


As you can see, the line input boxes; has become inputboxes; which means nothing to MetaPost…

I have found what triggers this bug, but this makes it weirder still: it comes from the space inserted between = and {input boxes;} in the option declaration:

everymp= {input boxes;}

If I suppress this space, i.e. if I write

everymp={input boxes;}

I obtain

input boxes ; 

in the MetaPost, i.e. what is expected.

Of course this problem is not very important, but it puzzles me. How come that a space character inserted between = and its argument can produce that behaviour? Is it a problem with the gmp package, or with the (x)keyval package? In the latter case it should have been noticed elsewhere, but until now I haven't found something similar.

I am using the MacTeX 2012 distribution (i.e. TeX Live 2012) on Mac OS X Snow Leopard (10.6.8), and the gmp package in its first and so far only version (1.0).

share|improve this question
Puzzling indeed. I guess it depends somehow on xkeyval. – egreg Feb 10 '13 at 22:34
The gmp package just delegates the absorption of the value to xkeyval and missing braces or a space before the opening brace results in getting inputboxes; as #1. :( – egreg Feb 10 '13 at 22:40
If I do the same with the mpsettings option of the 'mpost(*)' environment, i.e if I write [mpsettings= {input boxes;}]I get input boxes; in the mp file, as expected. Really, I don't understand… – Franck Pastor Feb 10 '13 at 22:48
The problem seems to be in bad interaction with the working of \usepackage; if I use \gmpoptions{...} after \usepackage{gmp} the problem does not show. Actually \usepackage uses \zap@spaces that is quite drastic in the way it works. – egreg Feb 10 '13 at 22:54
Thanks! You're certainly right. Ahmed Musa's answer confirms it, by the way. – Franck Pastor Feb 10 '13 at 23:10
up vote 3 down vote accepted

The space between input and boxes; is removed by the LaTeX kernel, not by xkeyval package. We see that here:

\@pass@ptions #1#2#3->\expandafter \xdef \csname opt@#3.#1\endcsname {\@ifundef
ined {opt@#3.#1}\@empty {\csname opt@#3.#1\endcsname ,}\zap@space #2 \@empty }
#2<-everymp=input boxes;

A solution: load the catoptions package before \usepackage[everymp=input boxes;]{gmp}. Then there will be no need to wrap input boxes; in braces.

\usepackage[everymp=input boxes;]{gmp}

    % here the MetaPost code
share|improve this answer
It works! Thanks a lot, I would never have been able to figure it out by myself. – Franck Pastor Feb 10 '13 at 23:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.