Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\documentclass{minimal}
\usepackage[everymp= {input boxes;}]{gmp}
\begin{document}
\begin{mpost*}
    % here the MetaPost code
\end{mpost*}
\end{document}

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

inputboxes;
outputtemplate:= "%j.mps";
beginfig(1);

endfig;
end.

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… –  fpast 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. –  fpast Feb 10 '13 at 23:10
show 1 more comment

1 Answer

up vote 2 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 }
#1<-\@currext 
#2<-everymp=input boxes;
#3<-gmp

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

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

\begin{document}
\begin{mpost*}
    % here the MetaPost code
\end{mpost*}
\end{document}
share|improve this answer
    
It works! Thanks a lot, I would never have been able to figure it out by myself. –  fpast Feb 10 '13 at 23:08
add comment

Your Answer

 
discard

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.