I have a class, try to invoke macros/commands via my special macro, but I get no expansion in the class when using \newcommandx, while it is working in the document or without the optional first argument.
I provide a MWE. The console output of latexing the document from 4 \typeouts is:
Code: Select all
--- rollover beethoven ---
--- \mwe@{macro}{beethoven} ---
--- rollover beethoven ---
--- rollover beethoven ---
Class is the file mwe.cls:
Code: Select all
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{./mwe}
[2011/10/14 v1.0
A mwe class]
\IfFileExists{xargs.sty}{%
\RequirePackage{xargs}}{%
\ClassError{./mwe}{%
The xargs package was not found.}{%
The xargs package provides for commands and environments.%
}}
\newcommand\mwe@test[1]{\typeout{--- #1 ---}}
\newcommand\mwemacro[1]{rollover #1 ---}
\newcommandx\mwe@[2]{\@nameuse{mwe#1}{#2}}
\mwe@test{\mwe@{macro}{beethoven}}
\renewcommandx\mwe@[3][1=mwe]{\csname#1#2\endcsname{#3}}% here
\mwe@test{\mwe@{macro}{beethoven}}
\LoadClass[a4paper,10pt,twoside,openright]{report}[2007/10/19]
\endinput
Code: Select all
\documentclass{./mwe}
\begin{document}
\makeatletter
\newcommandx\myt@st[1]{\typeout{--- rollover #1 ---}}
\newcommandx\use@[3][1=my]{\@nameuse{#1#2}{#3}}
\use@{t@st}{beethoven}
\makeatother
\TeX\space it.
\newcommand\mytest[1]{\typeout{--- rollover #1 ---}}
\newcommand\use[3][my]{\csname#1#2\endcsname{#3}}
\use{test}{beethoven}
\end{document}
Yet I cannot seem to fix this. Why is there no expansion in the class code for the \newcommandx with optional first parameter?
Thanks for your help or reply,
Sebastian