5

I have some questions in LaTeX, There are many "new" and "set" in LaTeX3, I don't quite understand when “new” is needed,such as

\int_set:Nn \l_my_int{12}

An error occurred

! Undefined control sequence.
<argument> \l_my_int                                 
l.11 \int_set:Nn \l_my_int {12}

also,i use

\tl_set:Nn \l_my_tl{\maketitle}

it is normal

Hope to explain to me,thanks!

ljguo
  • 1,213
  • 1
  • 4
  • 12

1 Answers1

10

In expl3, all variables should be declared before use, as this is the convention for the language. At the implementation level, some expl3 variables are TeX registers, whereas others are TeX macros. The latter can be created without allocation, but registers need to be allocated before use (at least using a name).

There is checking code available that will pick up if you 'shortcut' and forget to declare a variable before assigning it, even if behind the scenes it's a macro. However, as that slows things down, it's not active by default. You can active it with

\RequirePackage[enable-debug,check-declarations]{expl3}
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036