11

I've seen workarounds for having the spaces recognized within \ExplSyntaxOn... \ExplSyntaxOff. But I wonder why spaces are unrecognized even for (LaTeX3) macros arguments undoubtedly expecting text, e.g. ⟨text⟩ and ⟨more text⟩ in:

\msg_new:nnnn { ⟨module⟩ } { ⟨message⟩ } { ⟨text⟩ } { ⟨more text⟩ }
Denis Bitouzé
  • 9,652
  • 4
  • 27
  • 85

1 Answers1

12

space is given a catcode of ignore so it doesn't make a token at all, use ~ to make a normal space token

\msg_new:nnnn { ⟨module⟩ } { ⟨message⟩ } { ⟨text⟩ } { ⟨more ~ text⟩ }

The alternative would be to do something else, but whatever that was it would likely have the same problems as \verb in that it involves catcode changes and so works at the top level but not within arguments of another command, or it would involve some complicated pre-scan to remove or not space tokens that would mean that sometimes you need to hide white space with % at end of line, which the L3 syntax is designed to avoid.

Note that in this context ~ is not the active character making a non breakable space construct, it is simply a character with the space catcode that makes a space token as if from a space in the document setup.

David Carlisle
  • 757,742
  • 2
    Perhaps note that at one point we did try having a different catcode situation in exactly this context: it was not a good idea! – Joseph Wright Sep 28 '14 at 12:25
  • 1
    @JosephWright — I don't remember it being not a good idea — since \msg_new is only really used in an \outer-like context being able to write the message without ~ did save some effort. But it was inconsistent with everything else in expl3, so there was a good argument for dropping that feature. – Will Robertson Sep 29 '14 at 00:37
  • @WillRobertson That was the 'bad idea' part I was getting at: it wasn't consistent. – Joseph Wright Sep 29 '14 at 05:56
  • @WillRobertson Too bad, especially because ~ is not easy to type on French keyboards (see http://tex.stackexchange.com/q/202859/18401 ;) – Denis Bitouzé Sep 29 '14 at 10:17