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 ...
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 ...
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 ...
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. ...
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 ...
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 ...
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 ...
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|} ...
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 ...
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{\...
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 ...
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 ...
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,...