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.

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?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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}
share|improve this answer
    
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 '12 at 20:58

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.