[OS X TeX] Concatinating backslash and id
Ross Moore
ross at ics.mq.edu.au
Thu May 11 01:30:36 CEST 2006
Hi Peder,
On 11/05/2006, at 7:09 AM, Peder Axensten wrote:
> I need to define a macro, but I have the macro name without a
> backslash.
> How can I concatenate them (\ and #1, below)?
>
\newcommand{\mynewcommand}[2]{%
\expandafter\newcommand\expandafter{\csname#1\endcsname}{#2}%
}
cs = control sequence
Or you can leave some braces and one of the \expandafter commands
(as in Frank's posting):
\newcommand{\mynewcommand}[2]{%
\expandafter\newcommand\csname#1\endcsname{#2}%
}
This also works when #1 contains non-letter charcters;
e.g., digits and punctuation.
But in that case, to call the macro that was defined this
way, you need to use, e.g. \csname item37name\endcsname
>
> /Peder
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 +2 9850 8955
Sydney, Australia 2109 fax: +61 +2 9850 8114
------------------------------------------------------------------------
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
More information about the macostex-archives
mailing list