11k views

### What are the differences between \def, \edef, \gdef and \xdef? [duplicate]

I am a LaTeX guy, slowly working into the miracles of TeX. Can anybody tell me the differences between \def, \edef, \gdef and \xdef? Where shall I use which, what are the pros and cons? Or is it ...
15k views

### What is the difference between \let and \edef?

When you write \edef\a{\b} \let\a\b the results are often identical. What is the difference between these two commands? When do they behave the same? When do they not? (The question isn't for me; ...
3k views

### How can I specify a long list of math operators?

The preambles of my LaTeX documents often include many many lines of \DeclareMathOperator instructions, e.g. \DeclareMathOperator{\Rep}{Rep} \DeclareMathOperator{\Tet}{Tet} \DeclareMathOperator{\Maps}...
2k views

### How to properly smuggle (with or even without TikZ)?

I am seeking to find something that allows me to "broadcast" macros outside a group. Concrete examples include paths and scopes in tizpictures. Here is an M(N)WE. \documentclass[tikz,border=3.14mm]{...
2k views

### Does \noexpand have to be a primitive?

Background: I'm trying to deepen my understanding of TeX and how the intricacies work (spurred a little by this place, I should say, and hoping one day to not be a "Cargo Cult Programmer" - see When ...
1k views

### What does “expanding” mean in (La)TeX?

You can often read about expanding a macro or when a macro does expand, sometimes about expansion. But what does this mean - in English?
6k views

### Re-using the title of the previous Beamer slide

Is there a way to reference the title of the previous Beamer slide? Often, a sequence of slides have the same title, and I'd like to avoid having to repeat the title. I could define a macro for the ...
2k views

### How to understand and write LaTeX code?

LaTeX is like a language. In order to write LaTeX code I have to understand the "word" and the "sentences structure". I have searched on wiki, some LaTeX books, but they just give the LaTeX command, ...
753 views

### How can I know the number of expandafters when appending to a csname macro?

I am looking for an informative answer here. If I want to append to a macro, I have a couple of options, each depending on whether I want the items fully expanded, partially expanded (a certain number ...
1k views

### I'm a cargo cult programmer …

... because I don't know why this works \def\my@addextraoption#1{% \xdef\my@extraoptions{% \@ifundefined{my@extraoptions}\@empty\my@extraoptions,% \zap@space#1 \@empty}} \...
495 views

### Expansion of first token in a tabular cell

Background I currently do some work on the collcell package which collects the content of a tabular/array cell and provides it to a user defined macro, e.g. using >{\collectcell\mymacro}c<{\...
922 views

### Expand a macro with parameters in tabular head

My eventual goal is to create my own tabular-like environment in which all entries are in math-mode by default, let's call it fancytable. (One requirement is that the first column be separated from ...
1k views

### \expandafter, \csname issue related to test for macro being defined

Just when I think I starting to understand \expandafter I run into this problem where I am trying to test if \ConditionG, \ConditionH, etc are defined in a loop. I tried all the combinations I could ...