From the documentation:

Scan marks are control sequences set equal to \scan_stop:, hence will never expand in an expansion context and will be (largely) invisible if they are encountered in a typesetting context.

Like quarks, they can be used as delimiters in weird functions and are often safer to use for this purpose. Since they are harmless when executed by TeX in non-expandable contexts, they can be used to mark the end of a set of instructions. This allows to skip to that point if the end of the instructions should not be performed (see l3regex).

The scan marks system is only for internal use by the kernel team in a small number of very specific places. These functions should not be used more generally.

To the last point, where would scan marks be appropriate? Is this 'wherever quarks are inappropriate' by definition? What's the actual distinction? (I understand the TeXnical difference, but I'm asking about use-case.)

  • I would say it’s pretty clear from the context: the kernel team says “never” and there’s no appropriate use case; whether you actually want to use them or not is up to you, and they can’t actually do anything about it ;-) – Arthur Reutenauer May 23 '15 at 3:22
  • @ArthurReutenauer Well, the plan only works if everyone plays by the rules :) TeX has a global namespace and it's a big world out there ;) This Q is partly curiosity as well – I'm not using them in my project (and likely won't), but it's still curious that they exist at all. – Sean Allred May 23 '15 at 4:41

Scan marks were introduced to provide a way of having defined markers that will not cause issues (infinite loops!) if typeset or similar. As such, they overlap with quarks to a good degree: in many places, quarks are used as markers but their special properties are not used (see below). As such, one could imagine using scan marks in many places that quarks are currently used. As we already have quarks and they work in most cases, the reason for keeping scan marks internal is partly to avoid making arbitrary changes. At the same time, the team may rely on having exact control of the namespace here to get the 'right' effects. As such, we've only provided the idea for ourselves.

The special property of quarks is that (in primitive terms)


means that

\ifx\quark\quark TRUE\fi
\ifx\foo\quark   TRUE\fi

gives TRUE twice. This is used to be able to handle values returned in token lists (macros) and to allow rapid testing for these cases. (In the days before a requirement for \pdfstrcmp functionality this was a more important property than it is now, but it is still important.)

  • Simplistically I understood it a bit differently. They are both a matter of convenience and convention. \scan_stop: is a \relax. Use quarks when you need to delimit a macro, especially in recursion. \def\z#1\quark{..do something}. Different types are just conventions. Similar to \@nil and \@@. – Yiannis Lazarides May 24 '15 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.