[OS X TeX] Concatinating backslash and id

Peder Axensten peder at axensten.se
Thu May 11 03:43:53 EDT 2006


Thank you very much!

A variant of the question:
If I want to write the newcommand to a text file, something like:

	\immediate\write\fileid{\newcommand{\#1}{#2}}%

The same problem here, I want to concatenate \ and #1. How can I do  
that?

/Peder


On 11 maj 2006, at 01.30, Ross Moore wrote:

> \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

------------------------- 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 MacOSX-TeX mailing list