2

Reading the koma script source code (more precisely tocbasic.sty), I found, starting at line #623, this:

\DefineFamily{KOMAarg}
\DefineFamilyMember[.toc]{KOMAarg}
\newcommand*{\DeclareNewTOC}[2][]{%
  \newif\iftb@nt@float
  % ...
  \def\tb@nt@tocentrystyle{default}%
  % ...

The syntax of this command according to the manual: \DeclareNewTOC[options]{extension}.

What is the role of the @ (in this context) and what does the \tb@nt@ expand to, if I called the command i. e. like \DeclareNewTOC[float]{foo}?

The reason is that I want to change the last command I added (addtocentrystyle).

Thanks for any help in advance.

  • this is a duplicate (I'll find the link) but in package code ' is just a letter so it is like asking what a does \iftb@nt@float is just a command, it could have been called \iftbzzntzzfloat it's just a name. – David Carlisle Dec 11 '19 at 09:19
  • https://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do – David Carlisle Dec 11 '19 at 09:21
  • Other more-or-less duplicates: https://tex.stackexchange.com/q/164218/82917; https://tex.stackexchange.com/q/55858/82917; https://tex.stackexchange.com/q/11078/82917; https://tex.stackexchange.com/q/6240/82917 – campa Dec 11 '19 at 09:26
  • 6
  • Warning: Do not use or redefine undocumented internal KOMA-Script commands in your documents. They can change in the future without any warning. If you want to change the format of the entries use \DeclareTOCStyleEntry. For more information see the documentation. – esdd Dec 11 '19 at 09:57

2 Answers2

4

Did you hear about the concept of category codes in LaTeX?

At the time of tokenizing, i.e., at the time of reading input from the .tex-file and creating tokens and placing the tokens into the token-stream, LaTeX only takes characters of category code 11(letter) for components of names of multiletter control sequences.

Usually the characters a...z and A...Z are of category code 11(letter).

Usually the character @ is of category code 12(other).

Thus usually in .tex-input-files you cannot denote multiletter control sequences whose names contain the character @.

Thus control sequences intended for user-level don't have the character @ in their names.

But there are the control sequences \makeatletter and \makeatother.
\makeatletter gives the character @ the category code 11(letter).
\makeatother gives the character @ the category code 12(other).

This means:

After \makeatletter the character @ will during tokenozation of subsequent .tex-input be treated like any character of category code 11(letter); usually the characters a...z and A...Z are of category code 11(letter).
Thus after \makeatletter you can in subsequent .tex-input denote multiletter control sequences whose names contain the character @.

(By the way: You don't need \makeatletter..\makeatother within .cls-files/documentclass-files and within .sty-files/package-files because LaTeX gives @ the category code 11(letter) automatically during the processing of such files.)

By the \makeatletter...\makeatother-mechanism it is possible to have @ as a character which is only used within the names of control sequences that are not intended to be called by users directly.

Summa summarum:

The character @ in names of control sequences like \iftb@nt@float or \tb@nt@tocentrystyle is just a component of the name of the control sequence in question, like the characters a...z and A...Z (usually) can be components of names of control sequences.

The circumstance that @ is part of the names of these control sequences indicates that the programmer/maintainer of the code intended them not to be used directly by the user.

It also indicates that the definition of the control sequence token in question can change in future releases of the code in question.

Therefore when redefining/modifying code that is maintained by others and that does contain @ in names of control sequences you cannot rely on your redefinitions/modifications to be suitable for future releases of that code, too.

E.g., in the last release of the LaTeX2e-kernel a lot of internal code (containing @ in the names of control sequences) was changed. Such changes can break private modifications of kernel-macros. ;-)

Ulrich Diez
  • 28,770
2

It is common to use @ in internal code. This is done by assigning @ the category code of a letter so that it can be part of macro names just like any other letter, for this purpose there is the macro \makeatletter and to reverse its effect \makeatother. Those two aren't necessary inside of package or class code as LaTeX already makes sure that there @ is a letter.

Hence in your code snippet there is no macro \tb@nt@, but one that's named \tb@nt@tocentrystyle and which is defined to expand to default, and a conditional \iftb@nt@float, which will either expand to \iftrue or \iffalse, and additionally to that conditional there will be \tb@nt@floattrue and \tb@nt@floatfalse to toggle the conditional (those are created by \newif).

Skillmon
  • 60,462