9

Howdy please consider the following expample:

\RequirePackage{ expl3 , xparse , l3keys2e , xfrac  }

\ProvidesExplPackage
  {somewhat}
  {2012/04/29}
  {1}
  {descrr}


  \cs_new_nopar:Npn\font_color{green}

  \keys_define:nn {tgquixoptions} {
   font-color .tl_set:N = \tg_font_color, 
   font-color .default:n =\tl_set:Nn\tg_font_color{white},
   background-color .code:n=#1, 
   background-color .default:n = blue,
   }
  \ProcessKeysOptions{tgquixoptions}

  \message{------------message-----\tl_to_str:N\tg_font_color}

This works like a charm. But how can i make this into a Class? I tried this:

\LoadClass{beamer}
\RequirePackage{ expl3 , xparse , l3keys2e , xfrac  }

\ProvidesExplPackage
  {somewhat}
  {2012/04/29}
  {1}
  {descrr}


  \cs_new_nopar:Npn\font_color{green}

  \keys_define:nn {tgquixoptions} {
   font-color .tl_set:N = \tg_font_color, 
   font-color .default:n =\tl_set:Nn\tg_font_color{white},
   background-color .code:n=#1, 
   background-color .default:n = blue,
   }

  \ProcessKeysOptions{tgquixoptions}

  \message{------------message-----\tl_to_str:N\tg_font_color}

It seems that l3 doesn´t process the class options. When called like this:

\documentclass[font-color=somevalue]{somewhat}
%\usepackage[font-color=somevalue]{somewhat}
 \begin{document}
  \frame{
  }
\end{document}

So how can i make l3 listen to Package Options?

1 Answer 1

11

Class options are dealt with whenever a class is loaded. Thus if you want to process some package options but also load another class, you need to process your options first

\ProcessKeysOptions{tgquixoptions}
\LoadClass{beamer}

You may want to use the .unknown property to pass any other options to beamer.


Your code in working form:

\begin{filecontents}{somewhat.cls}
\RequirePackage{ expl3 , xparse , l3keys2e , xfrac  }

\ProvidesExplClass
  {somewhat}
  {2012/04/29}
  {1}
  {descrr}


  \cs_new_nopar:Npn\font_color{green}

  \keys_define:nn {tgquixoptions} {
   font-color .tl_set:N = \tg_font_color_tl,
   font-color .default:n =white,
   background-color .code:n=#1, 
   background-color .default:n = blue,
   }

  \ProcessKeysOptions{tgquixoptions}

  \LoadClass{beamer}

  \message{------------message-----\tl_to_str:N\tg_font_color_tl}
\end{filecontents}
\documentclass[font-color=somevalue]{somewhat}
%\usepackage[font-color=somevalue]{somewhat}
 \begin{document}
  \frame{
  }
\end{document}
1
  • well that makes sense but when i try to re-order my code i get some nasty ! LaTeX Error: Missing \begin{document}. errors. Could you go a bit more in detail?
    – bloodworks
    Apr 29, 2012 at 20:58

You must log in to answer this question.

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