Linked Questions

79
votes
3answers
3k views

Why isn't everything expandable?

TeX's macro processor does its work in a process called expansion. For an input stream of tokens, the macro processor repeatedly expands them until non-expandable tokens remain. The resulting stream ...
41
votes
4answers
4k views

What do \@firstoftwo and \@secondoftwo do?

The LaTeX kernel uses these two all over the place. For example, apparently the correct way of defining something like \ifeq{\macro 1}{\macro 2}{true}{false} is (note Martin's response: each case ...
38
votes
3answers
2k views

A guide to understanding expandability: when to write protected functions and when not to

I'm having difficulty understanding (and appreciating) the concept of expandability. I'm very murky about understanding when and how expandability impacts me in writing code for my documents. I've ...
18
votes
2answers
789 views

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

According to Christian Hupfer's comment I understood that calculations are possible in a keyval list when the macro is expandable. The macro \numexpr being expandable, calculations are possible. ...
16
votes
4answers
598 views

(Why) Can't we get 'fully expandable' versions of every command?

I'm just starting to figure out what 'expandable' means in LaTeX, and why it is useful to have commands that expand as far as possible. In particular: If you want to \typeout some string to the log ...
14
votes
2answers
1k views

Tricks to make macros expandable

Expandable macros are useful (I find working in the lion's mouth super cool). But they are difficult to write. Can more experienced users give hints that help achieve expandability? For example, we ...
7
votes
2answers
599 views

Fully expand macro argument

I am sure this has been answered already, but I cannot seem to find any answer that explains it in core TeX primitives and that I understand on a token level, e.g. I definitely don't want to get into ...
2
votes
3answers
177 views

\ifthenelse do nothing

I want to define a table as command. Some lines schould only be printed, if there is a value for it. Because of that I am using the \ifthenelse command. Example: \begin{tabularx}{\linewidth}{|l|X|} ...
5
votes
1answer
465 views

How to unprotect a command to expand it?

This is another question about protection and expansion, that I still don't understand well… (and I guess this is my problem here). I read especially How do I "unprotect" an argument?, and ...
1
vote
2answers
134 views

How to return a value from a function in LaTeX3

I have this MWE that tries to return a value from \l_example_foo_int from a function: \documentclass[a4paper]{article} \usepackage{expl3} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\...
2
votes
1answer
99 views

ConTeXt Mark IV: What is the Identifier rule?

What is the restriction on user-defined identifiers in ConTeXt Mark IV? Should it contain Latin alphabet only? What about numbers? What about hyphen and underscores? I can't find the official rules ...
2
votes
2answers
115 views

nested uppercase command not working

I am trying to create a reliable command that turns the first character of it's input to uppercase. So far I have no success, especially since it needs to work when the inputstring contains commands ...
1
vote
1answer
60 views

Continuos lemma: expansion problems using reledmac and xstring

Preface The following problem is part of a rather complex class file. Therefore I tried to make it as simple as possible to show the actual problem (MWE). I did a lot of experiments with \expandafter,...
1
vote
1answer
71 views

Solutions Will Not Compile

I'm trying to make simple integer exercise pages and solution pages. Why does this code not compile? I'm pretty sure the problem is in the \xdef line, but I don't know what the problem is. Any help ...
0
votes
1answer
51 views

what can go inside \directlua{}?

I presume these problems are related. \documentclass[a4paper]{article} \begin{document} \message{\edef\foo{Foo}\foo} % gives %! Undefined control sequence. %l.5 \message{\edef\foo % ...