I'm trying to set a custom macro to create frames in my presentations. However, when I tried to set the options I can pass to the frame using xkeyval the whole macro stops working.

How can I pass the fragile option to the frame using a defined macro? Additionally, can you explain why is not working?


% Define the keys for the myframe (my)
\define@cmdkey[abc]{mf}{title}{}%    title of the frame
\define@cmdkey[abc]{mf}{options}{}%  options to the frame

% my frame definition here
#2 #3

% this works
\myframe[title=test]{test1}{test 2}
% this doesn't
\myframe[options=fragile,title=test]{test1}{test 2}


enter image description here

1 Answer 1


Broadly, 'do not do this' is the best answer. There are two problems with your approach, one of which shows up here and one of which shows up if you fix the first one!

The immediate issue is that like most optional arguments, beamer is not looking here for 'something that expands to fragile, it's looking for the text fragile. So what happens is that \cmdabc@mf@options fails to be recognised as an optional fragile, and the text (or some of it!) ends up inside the slide.

The second, much bigger problem comes if we fix that, for example in a testing case by simple hard-coding fragile in to your example


This then dies entirely with an internal error. The reason here is that with fragile slides, beamer does some specialised parsing that relies on line-ends being present. In your 'wrapped-up' version the line ends have been turned into spaces by TeX tokenization, and so beamer fails to find the end of the commands. That leads to the error. As with any verbatim-like grabbing, you really have to be very wary of hiding the marker text.

  • BTW, nothing to do with xkeyval :-)
    – Joseph Wright
    Mar 24, 2014 at 14:38
  • Ok, so I shouldn't do this. Can you provide the good way of doing it? What if I want to define a custom frame environment, then, how can I do that?
    – adn
    Mar 24, 2014 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .