Questions tagged [token-lists]
The token-lists tag has no usage guidance.
141
questions
4
votes
1
answer
110
views
Understanding expansion in tblr environment
I'm trying to understand how tokens and expansion work in the context of the following problem. I'd like to create a tblr environment from the tabularray package via a command that does some of the ...
2
votes
1
answer
62
views
Replacing placeholder token in token list
I'm trying to write some code that replaces a couple of placeholder tokens in a token list, but am running up against a wall since I am still very new to latex3.
Currently, I get no result and no ...
6
votes
2
answers
219
views
Using expl3 to load geometry parameters from a file
expl3 has defeated me again so I'm relying on the kindness of strangers again.
I think the underlying problem is more about splitting input rather than the file reading.
Context:
I want to load the ...
7
votes
2
answers
210
views
Expansion issues again
I seem to keep encountering the same issue. In my attempt to learn more about expansions I have written a program that starts with a sequence of 1s and then after each step increments it to generate a ...
5
votes
2
answers
504
views
Exercise 8.6 of The TeXbook
Exercise 8.6. Assume that the category codes of plain TEX are in force, except that the characters ^^A, ^^B, ^^C, ^^M belong respectively to categories 0, 7, 10, and 11. What tokens are produced from ...
3
votes
2
answers
188
views
LaTeX3 how to use content/value of predefined command in token list/string?
First of all, I guess that will be a very easy answer for people who are experienced in expl3. But for me its new and I'm very willing to learn that stuff to understand Latex3 better. So I hope for ...
0
votes
2
answers
45
views
Token list given to TikZ scope fails
I want to construct a chain list on the fly and then use it in a tikzpicture, something like this:
\documentclass{article}
\usepackage{tikz}
\usepackage{xstring}
\usetikzlibrary{chains}
\newtoks\...
1
vote
0
answers
51
views
Compare Token List result to a string
I have a command that (beyond my control) evaluate into a token list, and I want to compare it to a given string, I tried to follow this answer and create a variant on \tl_if_eq:
\ExplSyntaxOn
\...
3
votes
1
answer
69
views
Token read/write turns # into ##
When I try to write an input given by a user in a token list to a file, it turns # into ##, so if a users wants to write \def\hello#1{Hello #1!}, instead of writing:
\def\hello#1{Hello #1!}
as ...
0
votes
1
answer
39
views
Manipulating a list and then passing it as an optional argument
I want to remove one key given by #1 and then pass the modified list to \lstinline[<modified list>]$#2$. I am able to remove the element but don't know the syntax of passing the rest to \...
3
votes
1
answer
130
views
Automatic listing of authors in a document
I have a command \by{ } that lets me list authors of an article like this:
\by{
{author 1}{tagline} \\
{author 2}{tagline} \\
{author 3}{tagline} \\
<etc.>
}
I would like to store author 1, ...
0
votes
1
answer
64
views
How to stop converting ^^M into space?
Is it possible to make ^^M visible in the list of tokens? Now it just gets converted to space, but I need it to be visible in tokens. This is the code:
\documentclass{article}
\usepackage{iexec}
\...
7
votes
2
answers
263
views
How to pass the the content from Lua function to a LaTeX3 token list (tl)?
I have a Lua function that generates LaTeX content (a string containing LaTeX commands like "\\textbf{foo}") and it can be successfully outputted with \lua_now:n and tex.print(). Now I'm ...
2
votes
2
answers
43
views
Replacing top-level (i.e. not enclosed in braces) occurrences of a token
I'm trying to replace all top-level occurrences of a token by another in a token list. For example, replacing 0 by 1 in 0{0{0}}0 should yield 1{0{0}}1. I have something that kind of works, but forgets ...
3
votes
1
answer
49
views
Styling character depending on its position
I'm trying to write a funny style writing targeting a young audience. At some point, I would like some words to have "wave" effect on each character according to their position.
I've already ...
1
vote
2
answers
239
views
LaTeX3 convert token list to string
I want to create a LaTeX class with optional parameters using LaTeX3. But I'm having problems converting the token list holding the parameter value to a string. I would like to know how to do this ...
2
votes
1
answer
233
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 ...
0
votes
0
answers
62
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 ...
2
votes
0
answers
70
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 ...
2
votes
1
answer
141
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....
3
votes
3
answers
117
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 ...
0
votes
1
answer
53
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 ...
3
votes
4
answers
178
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 ...
9
votes
1
answer
1k
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{...
0
votes
0
answers
50
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 \...
4
votes
3
answers
660
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 ...
1
vote
2
answers
350
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 ...
3
votes
1
answer
122
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 ...
2
votes
1
answer
75
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 ...
4
votes
2
answers
571
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&...
1
vote
1
answer
33
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 ...
0
votes
1
answer
125
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 ...
4
votes
1
answer
241
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 ...
2
votes
1
answer
53
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 ...
11
votes
1
answer
477
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: '\...
4
votes
2
answers
343
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 ...
4
votes
5
answers
392
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 ...
4
votes
3
answers
532
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
}
\...
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.)
\...
20
votes
2
answers
744
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 ...
6
votes
2
answers
283
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 '\...
10
votes
2
answers
487
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 ...
4
votes
2
answers
319
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 ...
2
votes
3
answers
952
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#...
7
votes
1
answer
2k
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{...
4
votes
3
answers
186
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 ...
10
votes
2
answers
226
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 ...
2
votes
1
answer
135
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 ...
3
votes
3
answers
262
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 ...
2
votes
2
answers
466
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 ...