Questions tagged [token-lists]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4
votes
3answers
106 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
2answers
73 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
1answer
60 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
1answer
44 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 ...
1
vote
2answers
113 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
1answer
27 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
1answer
52 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 ...
3
votes
1answer
127 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
1answer
41 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 ...
10
votes
1answer
265 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: '\...
3
votes
1answer
166 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
5answers
242 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
3answers
244 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
3answers
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
2answers
464 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
2answers
170 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 '\...
9
votes
2answers
317 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
2answers
189 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
3answers
157 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
1answer
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{...
4
votes
3answers
139 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
2answers
161 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
1answer
84 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
3answers
159 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
2answers
257 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 ...
3
votes
1answer
51 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, ...
9
votes
1answer
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 ...
0
votes
0answers
39 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 ...
2
votes
1answer
64 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 \...
4
votes
2answers
250 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 ...
3
votes
1answer
124 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{...
5
votes
2answers
80 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<} \...
2
votes
5answers
301 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 ...
2
votes
1answer
126 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 ...
3
votes
1answer
73 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. ...
1
vote
1answer
41 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, ...
7
votes
1answer
192 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 ...
5
votes
1answer
132 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, ...
2
votes
1answer
177 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 ...
1
vote
1answer
65 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 ...
2
votes
2answers
296 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 ...
5
votes
2answers
158 views

Latex3 Token-List commands do not work as expected

Let's take a trivial case: getting the head and tail of a token list and reversing the order: \documentclass{article} \usepackage{xparse} \usepackage{expl3} \ExplSyntaxOn \cs_set:Npn \cs_split:n #...
6
votes
1answer
172 views

How can I define a macro with the value of a fully expanded macro?

Related Expansion of macros and box contents Why isn't a command defined by \newcommand with an optional argument expandable? I made some simple macros for lists, but I do not know how ...
3
votes
2answers
71 views

Applying Macro to xth Symbol of String

I would like to define a command that puts a sequence of symbols above the xth symbol of another sequence of symbols. It seems nicer without a separator, but for higher usability a separator may be ...
1
vote
1answer
274 views

How to create a local token list variable in LaTeX3?

The \tl_new:(Nc) functions create a new token list variable globally. Is there a way to create a new token list variable locally?
2
votes
4answers
408 views

How to handle a LaTeX3 token list as a list of tokens rather than as a list of items?

Is there a way to query and manipulate a LaTeX3 token list as a list of tokens rather than as a list of items? For instance, given the token list {a}b is it possible to find out how many tokens it ...
1
vote
2answers
166 views

Q: Loop over all tokens in the body of a macro

I am looking for TeX-code that loops over all tokens in a macro definition. \meaning transforms everything to "other" (catcode 12) characters and is thus not directly suited (with or without \@strip@...
8
votes
1answer
384 views

What are the constituents of a LaTeX3 token list?

I'm trying to understand what a LaTeX3 token list is. Unfortunately, the LaTeX3 documentation is anything but helpful. According to the LaTeX3 Interfaces documentation token lists can be viewed in two ...
5
votes
1answer
235 views

TeX's expansion rules: a case study with a token-list register

I'm trying to figure out TeX's rules of expansion. Consider the following plain TeX manuscript: \toks1{hello}% \toks10{world}% \def\mac{0}% \the\toks1\noexpand\mac% \bye When this manuscript is ...
1
vote
2answers
132 views

Is there a better method for deferring the execution of commands?

The problem I am interested in getting the following result, by not writing it directly in code. \begin{align} T(x) &= ae^{-\frac{(x-b)^2}{2c^2}} \\ \frac{1}{2} < a &\leq 1 \label{...