add tag
निरंजन
I am trying something like following:

```
\documentclass{article}

\begin{document}
\ExplSyntaxOn
\cs_new_protected:Npn \tmp_begin:w #1\q_stop {
  \textsc{#1}
}

\cs_gset_eq:NN \tmpbegin \tmp_begin:w
\cs_gset_eq:NN \tmpend   \q_stop
\ExplSyntaxOff

\tmpbegin hello world\tmpend
\end{document}
```

(Warning: I might be using incorrect terminology ahead, please bear with me.)

The `\q_stop` is inside the macro `\tmpend`. I want `\tmpend` to expand once, but not further so that `\q_stop` is not expanded. The above code doesn't compile. An easy fix to it is to use `\tmpend` in the definition itself (i.e., `\cs_new_protected:Npn \tmp_begin:w #1\tmpend`), but I am trying to understand what can one do in order to stop grabbing the argument at `\tmpend` which is defined as a quark. In a general sense, when TeX reads `\tmpbegin` and starts grabbing the argument, what kind of expansion does it perform? If I understand correctly, `\tmpend` and `\q_stop` are `\ifx`-equivalents, then why does TeX produce Runaway argument error?
Top Answer
frougon
Delimited arguments require delimiter tokens to have the same *shape* in definition and usage(\*). `\tmpend` and `\q_stop` may be `\ifx`-equivalent, they don't have the same shape. Using `\tmpend` in the definition is fine IMHO if this is for user code (for expl3 macro code, just use `\q_stop`). You can define `\tmpend` as a quark to prevent incorrect usage.

Another important point is that when TeX grabs macro arguments (as part of the macro expansion process), it doesn't expand anything. There are functions defined with expl3 that perform some form of expansion on grabbed arguments (most notably `o`, `e`, `x`, `f` and `V` variants) but ultimately, they are built from TeX “building blocks”, among which the macros don't (some primitives such as `\expanded` obviously do). In particular, token sequences used as argument delimiters are never expanded.

(\*) In general, two tokens have the same *shape* if they are either both control sequences with the same name, or both character tokens with the same (character code, category code) pair. TeX being what it is, there are a few *very special* exceptions mentioned in [The LaTeX3 interfaces](https://mirrors.ctan.org/macros/latex/required/l3kernel/interface3.pdf) §24.7, *Description of all possible tokens*.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.