Questions tagged [token-lists]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
198 views

Why is LaTeX3 method not working with token list argument, contrary to documentation?

I have the following code in which I try to check whether a letter exists in a string: \documentclass{article} \ExplSyntaxOn \begin{document} \str_gset:Nn \ABCstring {ABC} % Setting the test string ...
user avatar
0 votes
0 answers
31 views

tex.runtoks: uniqueness of the <token register>

tex.runtoks can be used to execute instructions immediately. \directlua{ tex.settoks(421,'ABCDE'); tex.runtoks(421) } Here 421 should be replaced by a unique private number, in LaTeX we could ...
user avatar
1 vote
0 answers
54 views

Can you map arbitrary token sequences expandably and unambiguously to numbers or to strings of explicit character tokens of category 12?

How to map arbitrary brace-balanced sequences of non-outer tokens expandably and unambiguously to numbers or to strings consisting exclusively of explicit character tokens of category 12, if possible ...
user avatar
  • 22.9k
2 votes
1 answer
69 views

Passing a token list variable as an argument

The code below parses out a comma-delimited bit of an argument, then passes that bit to a function, as a token list variable. It works, by using \exp_args:Neee, but I suspect that there's a better way....
user avatar
3 votes
3 answers
80 views

No space no caps tokenlist

This took me longer than I'd like to accomplish what should have been a very simple task. I needed a way to turn a tokenlist lowercase and remove the spaces. But str_lowercase:N doesn't exist! And ...
user avatar
  • 1,200
0 votes
1 answer
46 views

Expansion while processing math in lists with xparse

I'm trying to "print" a comma-separated list of strings. The actual use case is more complex, the list being stored as a key-value, but the MWE below shows the problem: when I add math to ...
user avatar
  • 1,944
3 votes
4 answers
161 views

Highlighting token groups inside an expression

What I want to do is replace {...} (token group) by \{...\} (curly braces) at any level of nesting inside an expression. I'm only able to do it for level = 0. There should be an extra curly brace ...
user avatar
  • 1,868
5 votes
1 answer
381 views

LaTeX3 - Check if an argument is empty

What is the best way to translate the following code into expl3? \documentclass[12pt]{article} \newcommand\test[1]{% \if\relax\detokenize{#1}\relax EMPTY\else FILLED\fi% } \begin{document} \test{...
user avatar
  • 11.4k
0 votes
0 answers
41 views

Apply \cs_if_exist to the head of a tl variable

Consider the following command definition: \NewDocumentCommand{\reportexpansion}{ m }{ \bgroup \tl_set:Nn \l_tmpa_tl { #1 } { \ttfamily \tl_to_str:V \l_tmpa_tl } \space is \space \exp_args:No \...
user avatar
  • 2,855
4 votes
3 answers
195 views

The puzzling thing about \newtoks and the token list

The code is: \documentclass{article} \newtoks \test \begin{document} \test={123} \test=\test{666} \test=\test{hhh} \the\test \end{document} and the result is: 666 hhh 123, as ...
user avatar
1 vote
2 answers
161 views

How to find unicode characters represented via \string command

I'm using PDFLaTex compiler and want to produce PDF/A-1b format file. I'm using the package \usepackage[utf8]{inputenc}. I'm having problem with the unicode encoding for PDF meta-data. I want to use ...
user avatar
3 votes
1 answer
83 views

How do I add the value of a token list with braces in LaTeX?

In my LaTeX3 code, I frequently find myself wanting to add the value of one token list (or other variable) to another but surrounded by braces (a common use case is where I'm constructing a command to ...
user avatar
2 votes
1 answer
70 views

Including references in a tokenlist using expl3

I am trying to create a document with math exercises, for each math exercise one or more hints are given that should be show in a later section. From the inserted hints it should be possible to jump ...
user avatar
  • 1,663
1 vote
2 answers
266 views

expl3 - how can you pass the content of a token-list-variable as argument to another "function"?

I looked at interface3.pdf for learning about expl31. Assume one uses the scratch-token-list-variable \l_tmpa_tl. How can you pass the content of this variable as argument to another "function&...
user avatar
1 vote
1 answer
28 views

I want to have access inside the body not to the \arg[n] list but with \A[n] if I call \MAT{A, 1, 2, 3, 4}?

I would like to set matrices using the code: \newcommand{\MAT}[1]{ \setsepchar{,} \readlist\arg{#1} \arg[1]= \begin{pmatrix} \arg[2]& \arg[3] \\ \arg[4]& \arg[5] \end{pmatrix} } and inside ...
user avatar
0 votes
1 answer
74 views

LaTeX3: Get a token list var via its name

Assume I have a function that takes a tl var as an argument: \module_myfunc:N \l_module_tlvar_tl But what I have at hand is not the tl var but the name of the tl var: \l_module_tlvarname_tl How do I ...
user avatar
  • 597
4 votes
1 answer
160 views

LaTeX3: Braces and spaces

I don't quite understand how braces and spaces are treated in LaTeX3. For example: The documentation uses the following convention for N parameters: \my_func:N \my_tl And for n parameters: \my_func:n ...
user avatar
  • 597
2 votes
1 answer
44 views

Property reusability

I'm trying to create a command that will allow me to create multiple item for a game. My main problem comes from re-usability of that command. The fact that I have more than 9 arguments for some of ...
user avatar
11 votes
1 answer
403 views

What happened to expl3's case changing functions? (e.g. \tl_upper_case:n and \tl_lower_case:n)

I had some expl3 code which relied on \tl_upper_case:n to do some expandable case changing. However today I updated my TeX distribution and the code now throws an error: ! LaTeX3 Error: '\...
user avatar
3 votes
2 answers
248 views

In LaTeX3, what is the best data type for storing, parsing and outputting free user input?

I'm working on a mini-parser that takes free user input and interprets certain inputs as commands. For example, the parser interprets + as \oplus or [ as "start a pre-configured array with the bracket ...
user avatar
4 votes
5 answers
298 views

Prevent hash doubling with \message

Assume a token sequence: Token 1: Explicit hash character of category code 6. Token 2: Explicit 1 of category code 12. Token 3: Explicit hash character of category code 6. Token 4: Control word token ...
user avatar
4 votes
3 answers
404 views

How to iterate through a token list to make characters uppercase, while preserving spaces?

The following (classical, I assume) "iterator" definition would be examined here: \def\zEnd{\zEnd} \def\zzIterator#1{% \ifx#1\zEnd \else #1% \expandafter\zzIterator \fi } \...
user avatar
  • 3,616
27 votes
3 answers
1k views

Unbalanced dollar signs

I'm curious: why do the following two examples behave differently? Example 1: (Works, displays xyz in displaymath mode.) \newcommand\weird{$$xyz$} \weird$ Example 2: (Error, missing $ inserted.) \...
user avatar
  • 477
20 votes
2 answers
542 views

Expandable test for an empty token list—methods, performance, and robustness

With ε-TeX, the go-to method for testing if a <token-list> is empty is the following test: \if\relax\detokenize{<token-list>}\relax % empty \else % not empty \fi The method ...
user avatar
6 votes
2 answers
218 views

How to use \cs_generate_variant:Nn to compare token lists?

I want to deal with this question by my method. The example below is some codes from interface3.pdf; But throws the error:  ! LaTeX3 Error: Variant form 'VV' deprecated for base form '\...
user avatar
  • 573
10 votes
2 answers
388 views

When to use \tl_to_str:V and when \tl_to_str:N?

According to the interface3 documentation \tl_to_str:N expects a “tl var”, which I believe might be e.g. \g_temp_tl. \tl_to_str:V should, if I got it right, expect an argument representing a control ...
user avatar
4 votes
2 answers
237 views

What is the difference between `put` and `gput` in `\tl_new:N` token lists?

Why is there one function to define (globally) e.g. a token list \tl_new:N, but there are two functions to put an element into it: \tl_put_left:Nn and \tl_gput_left:nN What does this g at the ...
user avatar
2 votes
3 answers
415 views

How to check if the argument to a macro is a specific string?

I need to be able to pass [ ] (brackets with space in between) to a \def and check whether the \def's parameter contains [ ] (rather than something else). \begin{document} \def\bptoks{[ ]} \def\bpdef#...
user avatar
  • 3,616
7 votes
1 answer
1k views

what \relax command means?

I'm trying to compile this .tex file from ArXiVe.org in WinEdt 9.0 but some tokens are underlined with a solid line and preceeded by a strange command \relax command in WVP.aux: \relax \citation{...
user avatar
  • 1,838
4 votes
3 answers
161 views

fully expand toks and save for later (appendix with exact copies of tables from the main text)

I have a document with some complex tables, defined by a command called \Rule with named parameters (using the keyval package). The individual rows of the table are first stored into a token list ...
user avatar
  • 333
10 votes
2 answers
190 views

Understanding Implicit Delimiters/Terminators

[I encourage you to check out Phelype's impressive approach] I hear about macros that do things like "expand until they reach an unexpandable token" and this question may (or may not) be related to ...
user avatar
2 votes
1 answer
107 views

How can I strip the percent char of a number read by csvsimple?

I have a CSV table containing some numbers in percent with the percent char explictily written in the CSV data (that can’t be changes). Is there a (LaTeX3) way to strip the percent char and preceding ...
user avatar
  • 53.2k
3 votes
3 answers
199 views

Expl3' tl variable storing the result of a \seq_map_inline: OK in article's title but not in beamer's title

As pointed out by the following MCE, an expl3' token list variable storing the result of a \seq_map_inline: used in \title's argument: works like a charm with the article class, doesn't work with the ...
user avatar
2 votes
2 answers
331 views

How to properly store the current value of int variable into a token list?

I have an volatile integer variable (counter) and at some point I wish to save its value to a token list (saved_counter). If I save it with just \tl_set, as soon as counter changes the value, this ...
user avatar
  • 289
3 votes
1 answer
55 views

Lines (rules) and \multicolumn in tabular content built with token lists

Building on the MWE in my first ever question here (Extra space in cells when using token lists to build tabular content), I would like to add multicolumn content and \toprule (\midrule, \bottomrule, ...
user avatar
9 votes
1 answer
122 views

Extra space in cells when using token lists to build tabular content

What part of my code is causing the misalignment of the first column? The extra space seems to increase with the number of rows. (Part of my code is from How do I use the ampersand (&) inside a ...
user avatar
0 votes
0 answers
42 views

Customize chapters in table of contents from "1", "2", ... to "Chapter 1:", "Chapter 2:", ... using \@starttoc

I need to use this template for my thesis and having troubles modifying the labeling of chapters/sections in the table of contents. The way it is implemented right now is: "1 blah 1.1 blah-blah 1.2 ...
user avatar
  • 153
2 votes
1 answer
82 views

How to use the token list variable from \prop_get

Here is a MWE. I use a token list, and I can get 10 and October in the final pdf file. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \tl_new:N \l_my_tl \prop_new:N \l_my_prop \...
user avatar
  • 275
4 votes
2 answers
364 views

Convert token to string in LaTeX3

While trying to answer another question on this site, I was experimenting with \peek_after:Nw and \l_peek_token. I can set \l_peek_token OK, but then I want to test if this token is one of several ...
user avatar
  • 23.6k
3 votes
1 answer
181 views

How to pop (right) a token list with expl3?

The expl3 package provides \tl_put_right which enables us to append tokens to the right side of the current content of a token list variable: \documentclass{article} \usepackage{xparse} \begin{...
user avatar
5 votes
2 answers
95 views

Store tokens with unbalanced braces in token register

First of all, this question is not part of a real-world problem, it's just to see whether the following is possible with TeX or not. Consider this short code: \begingroup \toks0={\def\foo<} \...
user avatar
  • 12.8k
2 votes
5 answers
379 views

How can I condition on the last token?

I would like to write a command \foo which, for the sake of simplicity, does just one thing, which is make sure its argument ends with a dot. Thus both foo{hello world} and foo{hello world.} expand to ...
user avatar
  • 11.3k
2 votes
1 answer
158 views

expl3 read a comma list from file

I am using expl3 now, I want to read data from file, and store them in a comma list, then use the comma list one by one. I don't have any code, I just know exp13 have these function, so need someone ...
user avatar
  • 405
3 votes
1 answer
76 views

Latex3: multicolumn at the beginning of a token list produces an error

I'm not sure if using token list is a good approach to generating table data. Anyway, here is a weird result. It works well in all other cases except when the first item in token list is multicolumn. ...
user avatar
1 vote
1 answer
45 views

Generate a list of paragraph and page number for specific labels

I was wondering if anyone could help me with this: I've got this report for which I show the paragraph numbers. The paragraph number is then used as part of the label so I can extract it later on, ...
user avatar
7 votes
2 answers
240 views

How can I implement a \futurelet that ignores spaces?

This is a question about token processing in TeX. What am I doing wrong when implementing \FutureLetNoSpace? The book TEX in Practice: Volume III: Tokens, Macros, by Stephan v. Bechtolsheim, really ...
user avatar
5 votes
1 answer
151 views

expl3 -- sort a token list

L A TEX3 comes with a facility to sort list variables (sequences, token lists, or comma-lists) according to some user-defined comparison. I try to adapt the interface3 manuel example to a token list, ...
user avatar
  • 16.3k
2 votes
1 answer
218 views

Building up and joining "internal" lists

How can I append to a pgfkeys-style comma-separated list? Or, alternatively, how can I define a macro to join an etoolbox list with a delimiter? For an environment I'm designing, I want to accumulate ...
user avatar
  • 195
1 vote
1 answer
70 views

LaTeX output local lists on root document

This is a followup question for this question, where Christian Hupfer provided me a great solution for a certain problem: I wanted to list the occurrences of special commands within a section at the ...
user avatar
  • 631
2 votes
2 answers
329 views

Why "Missing Control Sequence Inserted" using Pop Function on Token Register?

When using the \Pop macro from from TeX by Topic chapter "Operations on token lists: stack macros", I get Missing control sequence inserted. Why? I copied it exactly as is! Was there a typographical ...
user avatar