# [texhax] Can I do it more simple (building .sty)?

Uwe Lück uwe.lueck at web.de
Wed Jun 24 18:32:36 CEST 2009

(answer/question mix:)

At 13:26 24.06.09, wawan wrote:
>I build .sty having a lot of newcommand like below, can I do it more simple
>
>\newcommand{\ha}{{\char10}}
>\newcommand{\hE}{{\char17}{\ha}}
>\newcommand{\he}{{\ha}{\char15}}
>\newcommand{\ho}{{\char17}{\ha}{\char20}}
>\newcommand{\hu}{{\ha}{\char23}}
>\newcommand{\hi}{{\ha}{\char25}}

This looks fine, congratulations!

You asked about \def earlier, by which you could replace the former with

\def\ha{{\char10}}

This is shorter, but \newcommand saves you from mistakes -- just to answer
You might do

\NC{\ha}{{\char}}

etc. to save space, then you could type several definitions in one code line.

I wonder about the extra *braces* in the definitions, this is not my field
of expertise.
(Hope *real wizards* see this!)
The braces are useful here when another number follows.
But you could use octal or hexadecimal notation,

\newcommand{\ha}{\char'012}

or

\newcommand{\ha}{\char"0A}

would overcome the parsing problem I alluded to; it may even be more

Another possibility is

\chardef\ha="0F

which, however, doesn't do the check that \newcommand does.
(It is more efficient regarding memory.)

On p. 356 of the TeXbook there are some things with \chardef, some with
\def, some with extra braces, I don't know why. I find it somewhat
difficult to find the corresponding things in LaTeX.

What language are you implementing? This might be really interesting.

Best,

Uwe.