# Remember an class option with newcommand and CurrentOption

I'm trying to make a class but it needs to remember its arguments

I'm using the file

\documentclass[x]{test}

\begin{document}
\end{document}


With the class

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2015/01/15 test class]

\DeclareOption*{
\newcommand{\test}{y}
\typeout{\test}
}

\ProcessOptions\relax

\typeout{\test}

\endinput


It outputs

 y
y


which is good but that's not what I want to do.

With the class

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2015/01/15 test class]

\DeclareOption*{
\newcommand{\test}{\CurrentOption}
\typeout{\test}
}

\ProcessOptions\relax

\typeout{\test}

\endinput


I get

x
<- empty line


It like it does not "dereference" \CurrentOption and take its string value so for the second \typeout, \CurrentOption is not defined to anything anymore and I get an empty value :( Does anyone know how to "dereference" it ? :)

You can use \let to make \test have the definition of \CurrentOption rather than reference it:

\documentclass[jjj]{test}

\stop


with class

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2015/01/15 test class]

\DeclareOption*{%
\let\test\CurrentOption
\typeout{\test}%
}

\ProcessOptions\relax

\typeout{\test}

\endinput

• I had tried with \def but not with \let, you saved my day :) – Benoît Legat Jan 15 '15 at 13:20