TeX - LaTeX Asked by Sean Allred on May 14, 2021
I need to define a token list of the form
tl_new:N g_silly_tl
tl_set:Nn g_silly_tl { Text ~ and ~ a ~ tie:?? }
How do I do this?
More generally, is there a reference where one can see how to input characters ‘normally’ under expl3 syntax?
This question has two distinct parts, one of which is easier than the other!
The specific issue here is (presumably) not inserting a tilde but rather inserting a non-breaking space in some 'fixed' text stores as within a LaTeX3 tl
variable. While a tilde is a convenient shortcut for this at the document level, here I think I would simply use the macro nobreakspace
.
tl_set:Nn l_silly_tl { Text ~ and ~ a nobreakspace tie:?? }
(Note that at present there is no expl3
code-level 'non-breaking space' function.)
On the wider issue of 'inserting non-standard catcode characters', the expandable function char_generate:nn
is available to create tokens of (almost) all reasonable category codes
tl_set:Nx l_silly_tl
{
char_generate:nn { `a } { 4 }
}
There are a few cases that are not covered by this approach. For example, with older expl3
releases we couldn't do active characters and you'd need to use the regex engine:
RequirePackage{expl3}
ExplSyntaxOn
tl_clear:N l_tmpa_tl
regex_replace_all:nnN { } { cA~ } l_tmpa_tl
More recent versions of expl3
can do this using char_generate:nn
, so it's more of a historical note.
The second option is stick to the 'traditional' lowercase
trick, using expl3
naming of course
group_begin:
char_set_catcode_active:n { `@ }
char_set_lccode:nn { `@ } { `~ }
tex_lowercase:D
{
group_end:
tl_set:Nn l_silly_tl { Text ~ and ~ a @ tie:?? }
}
(Notice that there is no public interface to lowercase
beyond the saved-primitive.)
Correct answer by Joseph Wright on May 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP