Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I don't understand an example from section 6.1 of expl3-intro.tex from LATEX3 documentation. It is said there:

Here are two equivalent ways of defining the function \foo:nn:

\cs_set:Npn \foo:nn  #1#2 {(#1)/(#2)}
\cs_set:cpn {foo:nn} #1#2 {(#1)/(#2)}

These macros are respectively equivalent to \TeX's


, and

\expandafter\long\expandafter\def\csname foo:nn\endcsname


Note the :nn suffix to denote that |\foo| takes two arguments.

Given equivalents seem to be reduced rather than complete. Could somebody provide accurate equivalents of

\cs_set:Npn \foo:nn  #1#2 {(#1)/(#2)}


\cs_set:cpn {foo:nn} #1#2 {(#1)/(#2)}


In particular, I wonder at \long\def\foo:nn. Is colon allowed in command names in Plain TeX or LaTeX 2e? Is it assumed here that catcode of : has been changed? If so, corresponding commands are suggested to be explicitly added to the above example. And where is the expanded part of definitions (i.e. {(#1)/(#2)})?

share|improve this question

1 Answer 1

up vote 12 down vote accepted

In LaTeX3 code blocks, both : and _ are 'letters'. Thus in the demo, the control sequence is \foo:nn, including the : and the nn. As the docs say

\cs_set:Npn \foo:nn #1#2 { (#1) / (#2) }

is exactly equivalent to



\cs_set:cpn { foo:nn } #1#2 { (#1) / (#2) }

is exactly equivalent to

\expandafter\long\expandafter\def\csname foo:nn\endcsname#1#2{(#1)/(#2)}

Here, I've taken advantage of fact that spaces are ignored in LaTeX3 code blocks. I've also assumed in the first example that : is a 'letter'.

share|improve this answer
So, \long\def should be prepended with \catcode`:=11 and \catcode`_=11. –  Igor Kotelnikov Nov 24 '11 at 8:49
@Igor Conceptually yes, in the same way as saying that with a lot of LaTeX2e snippets "do not forget \makeatletter". –  Joseph Wright Nov 24 '11 at 8:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.