Some people use the word 'macro' and 'command' interchangeably to refer to the instructions given to LaTeX. Is there a real difference between the two terms? If there is, can we see some examples on what the differences are?

  • 2
    We write macro or command or control sequence because we don't want to use the same name all the time. We're not lazy ;-)
    – user31729
    Jan 4, 2019 at 8:15
  • 2
    I personally do use these three words slightly differently, and I'm now wondering if this is correct. For me a "macro" is a command defined in terms of other commands (it can be expanded, so I exclude primitives and lengths), a "command" is an instruction that does something (which is admittedly vague, but this would include macros, but not lengths) and a "control" sequence" is a single token that consists of a backslash followed by a sequence of characters (irrespective of whether it is defined at all, but I'm not including active characters). Most commands are all three of these things. Jan 4, 2019 at 8:39
  • @Circumscribe There are expandable primitives that are sometimes expanding to a value, e.g. \eTeXrevision. Is this a macro as per your definition?
    – TeXnician
    Jan 4, 2019 at 8:41
  • 1
    Perhaps Lamport introduced the term command for pedagogical reasons in an attempt to hide the supposedly arcane macro-expansion-based TeX user interface. Official LaTeX books propagate this. Recently, LaTeX3 does something a bit alike by introducing function-terminology (see the Abstract at very start of texdoc expl3). There is some analogy here that in both cases it is felt TeX terminology needs some additional layer.
    – user4686
    Jan 4, 2019 at 10:36
  • 1
    "Commad" is used better when you want to be understood, "macro" could be used when you want to remark that is a custom (not primitive) command to initiated people and "control sequence" is useful when you want that the uninitiated do not understand you.
    – Fran
    Oct 10, 2020 at 14:56

4 Answers 4


I seldom use the term "command" when it is about (La)TeX.

In the TeXbook the term "command" does also appear in contexts where not single tokens but the coming into being of sequences of control word tokens plays a rôle.

E.g., chapter 15 of the TeXbook includes a double dangerous bend paragraph where you can read:

[...] Therefore plain TeX provides an allocation function for registers; Appendix B includes the command
which defines \footins as the number for footnote insertions. [...]

So, e.g., \newinsert\footins is a "command".

(By the way: The mentioned appendix B does actually not exhibit tokens. It exhibits TeX code, i.e., TeX-input which the programmer of the plain TeX format did produce. That TeX-input itself is not tokens. TeX will create tokens when processing that code.)

In the TeXbook you also find the phrase "primitive command". It is used in contexts where very short and easily to grasp sequences of TeX-input play a rôle. (Sequences that, when being read and tokenized, yield primitives...)

I suppose, a "command" according to the diction of the TeXbook is a sequence of characters which forms some portion of TeX-input. A portion of TeX-input which, when TeX reads and tokenizes that sequence of characters, yields a set of whatsoever tokens and/or (e.g., in case the command in question contains "invalid characters"/characters of category code 15) some error-messages. In case of yielding a set of tokens, that set of tokens is intended to form a syntactical entity which TeX's token-processing-apparatus can attempt to carry out/to process in whatsoever way. Such an attempt in turn may also yield error-messages and/or erroneous behavior.

Thus the term "command" in the diction of the TeXbook itself seems to actually not focus on things as results of TeX's "digestive processes". One of the earlier results of TeX's digestive processes are tokens. Tokens are produced in TeX's mouth. Thus the term "command" itself seems to actually not refer to tokens. It seems to refer to subsets of the things which TeX "looks at" with its "eyes"—it refers to portions of the TeX-input, i.e., to the things which in interactive mode the user/programmer can type, or which TeX can read from .tex-input-files or \read-handles for tokenization and further processing.

In the LaTeX 2e-kernel you have things like \newcommand and \renewcommand.

These things during LaTeX's digestive processes cause LaTeX to perform assignments. But the point of view seems not to be the view of the LaTeX-program which "looks at" LaTeX-input and while "digesting" produces "tokens" etc. The point of view seems to be the view of the programmer. The programmer does not produce tokens. She/he produces LaTeX-input. That LaTeX-input is not tokens yet. It is a sequence of input-characters.

After writing \newcommand..., the programmer in her/his code can take the thing introduced via \newcommand for a small portion of LaTeX-input which when tokenized by LaTeX yields a token which itself is considered a syntactical entity which, when used as intended, can be carried out via LaTeX's token-processing-apparatus without yielding erroneous behavior.

I could not find the phrase "command token" in texbook.tex.

This can also be taken for an indication that "command" and "token" in the diction of the TeXbook do in the upshot not refer to the same stage of work.

It seems, in the TeXbook the term "command" is used when the focus is on that stage where the programmer produces/delivers/types whatsoever .tex-input.

It seems, in the TeXbook the terms "token" and "macro" are used when the focus is on that stage where the TeX-program does process the .tex-input.

The term "macro" seems to refer to the concept of TeX's tokens while tokens and thus macro-tokens do not come into being while writing/producing/delivering TeX-input but while having the TeX-program read and tokenize TeX-input and from the resulting tokens expand the expandable ones.

As far as I know, macro-tokens are ⟨control sequences⟩ that both are expandable and do not have the meaning of one of those about 300 low-level atomic operations that are called "primitives".

Besides "macro" and "command" there is another term in the TeX world which deserves the attempt of shedding light: The term "function".

The tern "function" is used a lot in the documentation of expl3—expl3 is an en-vogue and state-of-the-art programming layer for LaTeX.

A macro-token is processed in TeX's gullet, where expansion of expandable tokens takes place in some sort of "regurgitative process". A macro-token gets processed in TeX's gullet during a single expansion-step. After the expansion-step the macro-token and the tokens forming its arguments and argument-delimiters are removed from the token-stream and tokens forming replacement-text according to the macro-definition are inserted into the token-stream instead. After the expansion-step carrying out the macro is done.

Carrying out a macro does not necessarily mean entirely carrying out an algorithm. Carrying out a macro implies carrying out a single expansion-driven step of a routine/of an algorithm.

The term "function" focuses on the result of entirely carrying out a routine/an algorithm for obtaining a desired result whereby cascades of expansion-steps and other kinds of operation-steps—i.e., the invoking of (several) macros and/or the invoking of primitives (be they expandable or not), and/or the invoking of unexpandable non-primitives—may play a rôle.

Implementing a "function" may require defining several macros and non-expandable non-primitives that underlie the "mechanism".

In expl3-jargon also that token/control sequence is called a "function" which initiates the cascade of expansion-steps and/or whatsoever other operation-steps which yields carrying out the algorithm/routine in question.

Above I said:

"As far as I know, macro-tokens are ⟨control sequences⟩ that both are expandable and do not have the meaning of one of those about 300 low-level atomic operations that are called 'primitives'."

What kinds of tokens can form such ⟨control sequences⟩?

⟨control sequences⟩ come in two flavors:

  1. ⟨control sequence tokens
    These divide into ⟨control symbol tokens and ⟨control word tokens
  2. ⟨active character tokens

With this remark we reach the question of how to divide up ⟨control sequences⟩.

As just seen, one way of dividing up ⟨control sequences⟩ is by looking at the question what kinds of tokens can form ⟨control sequences⟩:

⟨control sequence tokens are those lovely "thingies" that in TeX input need to be preceded by a character whose category code is 0 (escape).
Usually the backslash-character is the only character whose category code is 0.

⟨control sequence tokens come in two flavors:

⟨control symbol tokens⟩ have names which consist of a single character which does not have category code 11 (letter).

E.g., usually \. and \\ are ⟨control symbol tokens⟩ as usually the characters . and \ do not have category code 11 (letter). \a usually is not a ⟨control symbol token⟩ as usually the character a does have the category code 11 (letter).

⟨control word tokens⟩ have names which consist either of several characters which do not need to have the same category code, or of a single character which does have the category code 11 (letter).

There are two ways how a ⟨control sequence⟩ (, i.e., a ⟨control sequence token⟩ or an ⟨active character token⟩, see below) can come into being:

  1. When (La)TeX reads and tokenizes input.
  2. When (La)TeX inserts it during expansion; e.g., as part of the ⟨replacement text⟩ of a macro; e.g., as part of the \the-expansion of a token-register.

A ⟨control sequence token⟩ can come into being also

  • as the result of expanding some \csname..\endcsname-expression.

Any character whose current category code is not 11 (letter), even a character of category code 15 (invalid), can form the name of a ⟨control symbol token⟩ that came into being as a result of reading and tokenizing TeX-input.
(I say "current" because as soon as the character that forms the name of the ⟨control sequence token⟩ in question is switched to 11 (letter), the ⟨control sequence token⟩ in question will not be treated as a ⟨control symbol token⟩ (any more) but as a ⟨control word token⟩.)

Otherwise you could, e.g., not use ⟨control symbol tokens⟩ for changing the category codes of characters that currently have category code 15 (invalid).

But you can do, e.g.,:

\catcode`\A=15 % Now uppercase-a is invalid.
% Typing an "A" both outside a comment and not behind a character
% of category code 5 (end of line) which is not
% intended to form the name of a control-symbol-token would yield
% an error-message now.
% But you can do:
\catcode`\A=11 % Now uppercase-a is a letter again.

After elaborating on the names of ⟨control symbol tokens⟩, let's elaborate on the names of ⟨control word tokens⟩:

On the one hand, TeX's reading- and tokenizing-apparatus will only take sequences of characters of category code 11 (letter) as names of ⟨control word tokens⟩.
Thus names of ⟨control word tokens⟩ created via having TeX read and tokenize them directly from TeX-input consist only of characters that had category code 11 (letter) at the time of reading and tokenizeng them.
On the other hand names of ⟨control word tokens⟩ created via evaluating \csname..\endcsname-expressions can consist either of more than one character of whatsoever category code differing from 5, 9, 14 and 15 at the time of reading and tokenizing the \csname..\endcsname-expression , or of a single character of category code 11 (letter).

Now some remarks about the subtle differences between TeX's treatment of ⟨control symbol tokens⟩ and TeX's treatment of ⟨control word tokens⟩:

Usually the space character (code-point 32 both in ASCII and in unicode) and the horizontal tab character (code-point 9 both in ASCII and in unicode) are the only characters which have category code 10 (space).

A character of category code 10 (space) that in the TeX-input occurs behind a character-sequence that got tokenized as a ⟨control symbol token⟩ whose name is formed by a character which does not have category code 10 (space) will be tokenized as an explicit space token.

A character of category code 10 (space) that in the TeX-input occurs behind a character-sequence that got tokenized as a ⟨control symbol token⟩ whose name is formed by a character which does have category code 10 (space) will be ignored/will not yield any token.

E.g., category code 10 (space)-characters that follow the control-space, \␣, i.e., that ⟨control symbol token⟩ whose name is formed by the space character, will be ignored/will not yield any token.

A character of category code 10 (space) that in the TeX-input occurs behind a character-sequence that got tokenized as ⟨control word token⟩ will be ignored/will not yield any token.

When (La)TeX does unexpanded-write a ⟨control word token⟩ (be it writing to file, be it writing to the screen), it automatically inserts a space character at the end of the character sequence that represents the ⟨control word token⟩ in question.

When (La)TeX does unexpanded-write a ⟨control symbol token⟩ it will not automatically insert such a trailing space character.

When applying \string for transforming the following token into a sequence of ⟨character tokens⟩ (La)TeX will not attach an additional trailing space token.
(\string produces character tokens of category 12 (other). Exception: Spaces produced by \string will be so called explicit space tokens, i.e., character tokens with character code 32 and of category 10 (space).)

You can change the way in which TeX does unexpanded-write a ⟨control sequence token⟩ whose name consists of a single character by before writing changing the category code of that character either to 11 (letter)—in this case it will be written as a ⟨control word token⟩ with trailing space— or to a value differing from 11—in this case it will be written as a ⟨control symbol token⟩ without trailing space.

Thus you can have fun with TeX's automatic insertion of spaces when doing delayed writes with unexpanded ⟨control sequence tokens⟩ whose names consist of a single character—the code

\immediate\openout\mywrite test.txt\relax






besides the .dvi- or .pdf-file yields a file test.txt with the following content:

b\A b

As both \write-commands were issued while A was of category code 12 (other), you might have expected each \A to be unexpanded-written as ⟨control symbol token⟩ without a trailing space, and thus you might have expected the output


. But the first \write was not \immediate and thus it got carried out not immediately but at the time of shipping out the page. At that time, the second \write, which was \immediate, was already done and \A had category code 11 (letter) again and thus the \A in the first \write was written within the second line as a ⟨control word token⟩, with LaTeX attaching a trailing space character.

The nameless ⟨control sequence token⟩—methods for forming it are: 1) expanding \csname\endcsname; 2) placing a backslash (a character of category code 0 (escape)) at the end of a line while the parameter \endlinechar has a non-positive value or a value outside the range of code-points of the TeX-engine's input-encoding—deserves special attention:
Applying \string to it usually yields the catcode 12(other) character token sequence \12c12s12n12a12m12e12\12e12n12d12c12s12n12a12m12e12.
There is no space token between \12c12s12n12a12m12e12 and \12e12n12d12c12s12n12a12m12e12. There also is no trailing space token.
Unexpanded-writing it yields the character sequence \csname\endcsname␣—there is a trailing space character.
TeX will not necessarily produce backslash-character-tokens with \string/backslash-characters when unexpanded-writing to external text file or screen but will produce those character-tokens/characters whose character-code/code-point-number in the TeX-engine's internal character representation scheme (which with traditional TeX is ASCII and with LuaTeX/XeTeX is unicode whereof ASCII is a strict subset) equals the value of the integer parameter \escapechar.
If the value of \escapechar is outside the range of possible code-point-numbers for encoding characters, TeX will not deliver escape-character-tokens/characters.
Usually the value of \escapechar is 92 which denotes the backslash. But after \escapechar=65 the command \expandafter\string\csname\endcsname yields A12c12s12n12a12m12e12A12e12n12d12c12s12n12a12m12e12because 65 is the number of the code-point of the character A.
But after \escapechar=-8 the command \expandafter\string\csname\endcsname yields c12s12n12a12m12e12e12n12d12c12s12n12a12m12e12 because -8 is outside the range of possible code-point-numbers for encoding characters and thus tokens representing escape-characters (backslashes) are not delivered.
Character tokens produced via \string are of category 12(other). The only exception is: If the character code of the character token produced due to \string is 32 (32 denotes the space character), then the category is 10(space).

Besides the ⟨control sequence tokens there is another kind of ⟨control sequences⟩: ⟨active character tokens⟩.

An ⟨active character token⟩ is a ⟨character token⟩ whose category code is 13 (active).
An ⟨active character token⟩ can be used like a ⟨control sequence token⟩.
E.g., after \catcode`\b=13 you can do \def b{The active character \string b is a macro now.}

Another way of dividing up ⟨control sequences⟩ is by looking at their "decomposability":

The TeXBook says:

About 300 of TeX's control sequences are called primitive; these are the low-level atomic operations that are not decomposable into simpler functions. All other control sequences are defined, ultimately, in terms of the primitive ones. For example, \input is a primitive operation, but \’ and \" are not; the latter are defined in terms of an \accent primitive.

(It should not be overlooked that when defining ⟨control sequences⟩ that are macros, ⟨non-active character tokens⟩ can play a rôle also.)

Yet an another way of dividing up ⟨control sequences⟩ is by looking at the actions triggered by them and at the point in time when these actions are triggered:

There is the analogy between TeX's input-processing and digestive processes:

  • TeX input is divided up into so-called tokens (⟨control sequence tokens⟩ and ⟨character tokens⟩) in TeX's mouth.
  • Expansion of expandable ⟨control sequences⟩ takes place in the gullet.
  • Unexpandable ⟨control sequences⟩ will be handled in the stomach.

So you distinguish expandable ⟨control sequences⟩ and unexpandable ⟨control sequences⟩.

Expandable ⟨control sequences⟩ (and their arguments) will in the gullet be replaced by other constellations of tokens. Replacement of expandable ⟨control sequences⟩ takes place in the gullet until there are no more expandable ⟨control sequences⟩ left.

Unexpandable ⟨control sequences⟩ (which came into being either during tokenization in TeX's mouth or via replacement of expandable tokens during expansion) pass the gullet and reach the stomach where boxes will be built, assignment-primitives will be carried out, etc.

There are primitive ⟨control sequences⟩ that are expandable:

E.g., the \string-primitive is an expandable primitive. Together with the following token it vanishes in TeX's gullet and as replacement you get a set of ⟨character tokens⟩ of category 12 (other) or 10 (space) that represents the name of the ⟨control sequence token⟩ in question/is the catcode-12-pendant of the ⟨character token⟩ in question. (When in TeX's token stream an explicit space token trails the control-word-token \string, expanding \string yields an explicit space token.)

E.g., the \csname-primitive is an expandable primitive. It triggers the processing of a \csname..\endcsname-expression in TeX's gullet and it vanishes in TeX's gullet and as replacement you get the corresponding ⟨control symbol token⟩ or ⟨control word token⟩. In case that token is undefined, it will get the meaning of the \relax-primitive within the current scope.

E.g., the \romannumeral-primitive is an expandable primitive. It and a following ⟨number⟩ vanish in TeX's gullet and in case the ⟨number⟩ is positive as replacement you get a sequence of ⟨character tokens⟩ of category code 12 (other) that represent the corresponding ⟨number⟩ in lowercase-roman notation.

There are primitive ⟨control sequences⟩ that are not expandable:

E.g., the \relax-primitive is not expandable. It does pass the gullet and reach the stomach.

E.g., the assignment-primitives \def, \edef, \gdef, \xdef, \countdef etc are not expandable. They do not trigger their replacement in TeX's gullet but will reach the stomach.

There are non-primitive ⟨control sequences⟩ that are expandable:

Macros are non-primitive ⟨control sequences⟩ that are expandable. They and their arguments get replaced with their ⟨replacement text⟩ in TeX's gullet. Macros are defined in TeX's stomach in terms of the primitives \def, \edef, \gdef and \xdef. Be aware that LaTeX's \newcommand also is just a macro which "decomposes" in LaTeX's gullet to some set of tokens containing the \def-primitive.

There are non-primitive ⟨control sequences⟩ that are not expandable:

You can, e.g., do things like \let\bgroup={.

\bgroup is a ⟨control sequence⟩. More specific: It is a ⟨control sequence token. It is a ⟨control word token⟩. It is not expandable but it also does not have the meaning of one of the about 300 non-decomposable functions of TeX that are called primitives. \bgroup is an implicit character  token. ;-)

Other kinds of non-primitive ⟨control sequences⟩ that are not expandable are, e.g., \chardef-tokens, \countdef-tokens, \toksdef-tokens, ...

In order to get used to the terminology, let's unravel some cases:

After carrying out the assignments

\catcode`\W=13 %
\catcode`\X=13 %
\catcode`\Y=13 %
\catcode`\Z=13 %
\newcommand W{The active character \stringW is a macro.}
\newcommand\something{This is a macro.}
\newcommand\+{This is a macro, too.}
\let X=a
\let Y=\relax
\let Z=\romannumeral


  • W is a ⟨control sequence⟩: It is an ⟨active character token⟩. It is a macro and thus both expandable and not a primitive.
  • X is a ⟨control sequence⟩: It is an ⟨active character token⟩. It is not expandable. Thus it cannot be a macro. It also is not an unexpandable primitive. It has the same meaning as the catcode 11(letter) ⟨character token⟩ a. It is an implicit character token.
  • Y is a ⟨control sequence⟩: It is an ⟨active character token⟩. Its meaning equals the meaning of the unexpandable \relax-primitive. Thus it is an unexpandable primitive.
  • Z is a ⟨control sequence⟩: It is an ⟨active character token⟩. Its meaning equals the meaning of the expandable \romannumeral-primitive. Thus it is an expandable primitive.
  • \something is a ⟨control sequence⟩: It is a ⟨control sequence token⟩. It is a ⟨control word token⟩. It is expandable. Its meaning does not equal one of the about 300 non-decomposable functions of TeX that are called primitives. It is a macro.
  • \+ is a ⟨control sequence⟩: It is a ⟨control sequence token⟩. It is a ⟨control symbol token⟩. It is expandable. Its meaning does not equal one of the about 300 non-decomposable functions of TeX that are called primitives. It is a macro.

The term "macro" does always denote a non-primitive expandable ⟨control sequence⟩.
Thus when you know that a token is a macro, you can conclude that it cannot be a ⟨non-active character token because ⟨non-active character tokens cannot be ⟨control sequences⟩.
You can conclude that it is a ⟨control sequence⟩.
But you cannot conclude whether the ⟨control sequence⟩ is a ⟨control word token or a ⟨control symbol token or an ⟨active character token.

Not all expandable ⟨control sequences⟩ are macros.

There are expandable ⟨primitives⟩ as well.

Not all non-expandable ⟨control sequences⟩ are ⟨primitives⟩.

There are non-expandable non-primitives as well:

E.g., implicit character tokens, \chardef-tokens, \countdef-tokens, \toksdef-tokens, ...

  • 4
    Sorry for asking, but just curiosity: are you writing everything from your mind?
    – Sigur
    Jan 5, 2019 at 0:33
  • 1
    @Sigur I just thought about it, looked up the quotes and spontaneously typed into the input-field of the TeX-LaTeX-StackExchange-Website shown in my internet-browser. If I had really planned this answer systematically, I would have typed within my favorite editor-software, saved the text as a file and revised it a few times before pasting it from the editor-software to the input-field of the TeX-LaTeX-StackExchange-Website. But I didn't take it all too serious. I just wanted to have fun...;-) Jan 5, 2019 at 1:10
  • 2
    Ulrich, Since TeX doesn't end in an orthographic 's', it's possessive form should be "TeX's" not just "TeX'".
    – Alan Munn
    Jan 5, 2019 at 17:04
  • 2
    @AlanMunn These comments might prevent others from making the same mistakes... ;-) Jan 5, 2019 at 17:41
  • 1
    As I started reading this answer, I just knew you were the author, so distinctive is your extreme thoroughness. Aug 24, 2021 at 19:05

macro programming is a programming style (as distinct from compiled programs) where the operation works by each token being replaced inline by its replacement text. Popular macro programming languages other than TeX include the C language pre-processor and the m4 system.

What macro means in LaTeX?

TeX's main mode of user customisation is via its macro processing language, but of course it requires some built in commands (primitives) that you may use to build up macros.

So commands such as \def, \halign, \count are not macros.

Tex also has some primitives that are classed as expandable and so act pretty much the same as pre-defined macros although technically they are not classed as macros in TeX, a list of these expandable primitives is here:

Is there a list of expandable TeX primitives? LaTeX? e-TeX? others?

A control sequence is a string of characters such as \foobar that references a command (or token, or is undefined) as opposed to a character such as x that just references itself, it may reference tex primitives or macros, depending on the context. Note that being a macro is a property of the meaning of the token, but being a control sequence is a property of its syntax. So by default ~ is a macro but it is an active character token not a control sequence.

In TeX macros are always defined by \def and its variants such as \edef. LaTeX definition commands such as \newcommand are themselves macros that ultimately result in an application of \def to define a macro.


They're used interchangeably because they mean the same thing.

  • A macro is defined as

    a single computer instruction that stands for a sequence of operations

  • The use of command probably stems from the way it's defined in LaTeX via \newcommand and \renewcommand and LaTeX3's xparse via \NewDocumentCommand and \RenewDocumentCommand.

  • There's also control sequence used by DEK in his TeX Book. They all point to the same thing.

  • 9
    I would not say they mean the same thing, tex primitives are not macros. Jan 4, 2019 at 10:12
  • I'm confident the majority of people using (La)TeX use the terminology interchangeably.
    – Werner
    Jan 4, 2019 at 17:32
  • 2
    Certainly some do but that I think leads to confusion (as witnessed by this question) Jan 4, 2019 at 17:35
  • @DavidCarlisle I wish I didn't use them interchangeably, but I find myself doing it. Even in my tokcycle package, where the documentation tries to draw limited attention to the distinction, the directive that absorbs anything cat-0 is called the \Macrodirective. So I fail at this basic level, though \CatZEROdirective would have been too much of a pain to write. Perhaps \Commanddirective would have worked, but folks would be stumbling over the double d. Aug 24, 2021 at 19:10

A lot depends on how you're approaching LaTeX. If you're an author, you don't really care about macros, control sequences, tokens etc. From that perspective, anything that begins with \ and does something is a command. To a lesser degree, you'll worry about lengths and glues (dimens and skips in primitive TeX speak), although given an appropriate document class, an author would be unlikely to use any of these with the possible exception of \linewidth or \baselineskip for scaling purposes of imported graphics.

On the other hand, if you're approaching LaTeX as a developer and creating classes or packages, you'll care a bit more, although expl3 does abstract away a lot of that (albeit occasionally abusing terminology).² Everything is still macros built out of primitives at the bottom, but there's at least a consist terminology there, as long as you're able to get past the three-level archaeology of LaTeX's sources³ in understanding how things work.

  1. It's possible to write an expl3 function that can be assigned to an expl3 value, but this is not the default behavior and expl3 has no inherent concept of return type since it's still, at its heart, macro expansion.

  2. In other languages, if you apply a map to something, you get something of the same class (so, e.g., in Rust, iter.map(|x| x.to_string()) would take the iterator iter on some type and turn it onto an iterator on the string values of that type, and some_optional.map(|x| x*x) would transform the optional value some_optional into a new optional value holding the square of its contents (if present)) while the various _map functions of expl3 instead just iterate on their value but don't actually return a new tl, prop, str, but rather produce their output in situ. Perhaps more concerning is that Expl3 functions in most cases¹ are not what any other language calls a function, but are more properly procedures.

    All this is not to complain (too much). Expl3 is a monumental accomplishment and together with xparse provides a means to make things that were previously difficult much easier to do. TeX is a truly unique programming idiom, the managing of which is akin to playing chess in a lot of ways in that the most direct route often does not yield the desired results.

  3. viz, newer code written with Expl3, legacy⁴ code using private LaTeX commands with @ syntax and finally the lowest level code which employs primitive TeX syntax.

  4. It seems a bit strange to refer to something as legacy when it comprises the bulk of the code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .