[texhax] need a llittle help

Morten Høgholm moho01ab at student.cbs.dk
Sat Jun 5 15:44:32 CEST 2004


On Fri, 04 Jun 2004 18:30:33 -0400, Dr. Simant R. Upreti  
<supreti at ryerson.ca> wrote:

> Hi there,
>
>
> I was wondering if it possible to have a \newcommand whose name is made  
> up
> of the argument of an outer \newcommand.
>
> With this association, my objective is to have a class like structure to
> retrieve records.
>
>
> I would really appreciate it if you could advise me. I look forward to
> hearing from you.

Maybe something like:

\documentclass{minimal}

\newcommand*\DefineSomething[1]{%
   \expandafter\newcommand\csname first#1\endcsname[2]
     {\textbf{arg1: ##1}, arg2: ##2}%
   \expandafter\newcommand\csname second#1\endcsname[2][Empty]
     {\textbf{arg1: ##1}, arg2: ##2}%
}
%% notice the double hash marks above. We're one level down,
%% so they must be doubled.
\begin{document}
\DefineSomething{test}
\firsttest{A}{B} \par
\secondtest[optional]{A} \par
\secondtest{A}
\end{document}


-- 
Morten Høgholm



More information about the texhax mailing list