The tag has no wiki summary.

learn more… | top users | synonyms

11
votes
5answers
247 views

Count number of entries with specific value

Assume I have a list with quite a few entries (all integer values, in case it's relevant), e.g., 1 2 4 0 3 1 0 0 2 1 7 1 4 2 3 0 0 6 5 2 1 2 3 0 Can LaTeX somehow count the number of 0's, 1's, ..., ...
0
votes
0answers
37 views

How can I tl_put_right a genuine }

LaTeX3. How can I tl_put_right a genuine } into a token list? All my attempts to expand \c_group_end_token were not successful.
5
votes
2answers
120 views

Difference between tokenlist and raw text in expl3

How to split token list by any char, like a raw document text? For example, i have a code to bold first word in macro argument. Macro is correctly works for direct using from code, like \bfirst{word ...
5
votes
1answer
48 views

Token replacement within a group

A comment below has clarified my problem, it has nothing to do with lua. In the code snippet below: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \cs_new_protected:Npn ...
3
votes
2answers
79 views

How to expand a LaTeX counter when adding to token list

In short: I am trying to append counter values to a token list, but when I print the token list at the end I get the final values of those counters. What I want is the value of the counters at the ...
2
votes
1answer
78 views

Token list with line breaks for writing multiple lines to file

I make use of a package (gnuplottex) that writes contents of an environment to a file, using the \verbatim@start/processline/end commands (by \immediate\write\FileHandle{\the\verbatim@line}). Now I ...
8
votes
1answer
230 views

Expandable, standard TeX only way to compare balanced token lists

Is there a (reasonably) efficient macro that does something similar to \long\def\comparets#1#2{\def\aa{#1}\def\bb{#2}\ifx\aa\bb true\else false\fi} except is expandable (i.e. ...
3
votes
2answers
340 views

Extract first letter of each word in a sentence

I don't know if already exists a question like this, but after 20 minutes I haven't found one. There are similar ones, like How to define a command that bolds the first letter of each word in the ...
7
votes
2answers
124 views

Is it possible to set a particular item of a LaTeX3 seq?

I want to use a seq as an array and then set a particular item of this array by its index. I know that I can access an item via \seq_item:Nn but didn’t find out if there's something like ...
7
votes
2answers
139 views

How to count the frequency of a token in a token list

Is it possible to count the number of a token in a token list? \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \tl_new:N \tobi_list_tl \tl_set:Nn \tobi_list_tl {foo~bar~baz} ...
6
votes
2answers
111 views

How do I get a token list with an end-of-line character in it?

The context of this question is that I have a command defined using xparse that slurps in a verbatim argument which can be long. I want to do a replacement on the resulting token list, but the token ...
3
votes
2answers
86 views

Replace and add a/to a specific sequence of tokens

Is there a way to find a specific sequence of tokens and add after it a command? Or is there a way to find a specific sequence of tokens and replace it with another one? And do it only if the sequence ...
1
vote
2answers
235 views

Spacing depending on optional subscripts and superscripts

I am totally new to LaTeX (use it for 2 days), so I am sorry if this has already been asked, but I spent the last 6 hours searching for a solution, but to no avail. (I stumbled upon a package xpeek ...
11
votes
1answer
561 views

Using \toks registers

I was reading this tutorial for TeX programming: http://pgfplots.sourceforge.net/TeX-programming-notes.pdf recommended in the 2-nd answer here: Where do I start LaTeX programming? It says: ...
41
votes
3answers
1k views

What is a token?

Please forgive such a basic question, but I did some Google searching and looked around on this site, and while there are many threads and online resources that involve tokens, I can't seem to find a ...
4
votes
3answers
267 views

How are space tokens and empty lines processed by long commands (as their potential arguments)?

How are spaces and empty lines processed by long commands (i.e., those that do not accept paragraph breaks inside)? Are there different space tokens aside from " " and an empty line? It appears that ...
5
votes
2answers
189 views

Splitting delimited token list argument

I wrote a little piece of code (function \getfirst:w) that splits its delimited argument at the first embedded :. The code works well if used standalone, but I am unable to place it into the .code:n ...
9
votes
1answer
289 views

Using \typeout behaviour different with \newtoks vs. \def

I feel as I really should know this, but sadly I don't. Why is the output of \typeout{\the\myToken} not the same as having it printed in the PDF as \the\myToken. No problem with a \def, just with ...
3
votes
2answers
248 views

Tokenize and apply command

I have a string separated with commas. On that I want to get each element and apply a command. I have the following, which works. \documentclass[12pt]{article} \usepackage[trim]{tokenizer} ...
5
votes
2answers
129 views

Using Expl3 token-list variables where token lists are called for

The code below illustrates the trouble I’m having. It seems I cannot directly use a token-list variable where a token list is called for, but why, and how can I get the result I want? ...
7
votes
1answer
370 views

Peek ahead for next token not in token-list

This question led to a new package: xpeek I’ve been developing my xpeek package with lots of help from you folks on TeX.SX. It’s intended to help write commands which, like the familiar ...
5
votes
2answers
168 views

Macro for a code translator

Is there an existing macro that "translate" tokens using some code ? For example : \def\code{{{a,b},{b,c},{c,a}}} \translate[\code]{caac} % => would typeset "abba" or even better something like ...
4
votes
2answers
449 views

Passing multiple arguments from ProcessList (xparse) to a macro. Result to be used in tabular

I am making a macro that will take user input of a grading scheme and place it into a tabular environment. I would like the syntax to be as simple as possible and decided on: \tabulate{ eval1,%1 ; ...
15
votes
4answers
495 views

How does one remove material from a token list?

This is a follow-up question to How does one append material to a token list? The macros \prependto and \appendto work nicely to add content to token lists. How would one go about creating macros ...
9
votes
2answers
708 views

\newtoks token seems to have local scope

I want to collect the first line of a quotation to use later. I have used \newtoks for a similar purpose so tried it here, this way: \documentclass[12pt] {article} \newtoks{\qfirstlineinternal} ...
8
votes
2answers
475 views

Improve list parsing command

This question led to part of a new package: menukeys I build a command to iterate over a list with changable seperators and it works like expected but I wonder if there is a faster or more ...
19
votes
5answers
1k views

How does one append material to a token list?

Several times, the floatrow package uses \newtoks which (according to this website) means that a token register is allocated. An example code snippet is ...
3
votes
1answer
185 views

How make Standalone with Subpreambles respect group?

I am trying to use the subpreambles option with the standalone package. My main file is: \documentclass[subpreambles]{standalone} \usepackage{standalone} \newtoks{\MyToken} \MyToken={MainFile} ...
7
votes
4answers
818 views

Search and replace in a verbatim token list

I maintain a package for the R programming language that contains a vignette which gets processed using the Sweave literate programming system. Now, one of the irks about Sweave is that it always ...
7
votes
2answers
1k views

Iterate over space-separated list

I’ll briefly explain the background in case this can be solved simpler but I’d still be interested in an answer to the actual question, too. My chapter titles are very narrow and use a large font so ...
5
votes
1answer
350 views

Removing and storing the head of a token list/\toks

I am given a token list (parameter-less macro) \myTokenList, defined, e.g. by \def\myTokenList{$(x + y)^2$, \ie, \(x^2+y^2+2xy\)} and I want to split it as the first token, and the rest, obtaining ...
9
votes
3answers
437 views

Making register declarations local, Undefining a register (count, toks, etc.)

Is it possible to make \newcount, \newtoks, etc. respect grouping, so that, e.g., \newcount\temp\temp=2{\newcount\temp\temp=1}\showthe\temp gives 2 (instead of 0)? Relatedly, is it possible to ...
27
votes
6answers
4k views

Test whether token list is empty

Is it possible to test whether a token list register is empty without expanding it?
15
votes
3answers
630 views

Will LaTeX3 have proper support for hooks? Does LuaTeX?

Tex has powerful support for extensions triggered by events happen in generating output, by running one of six token lists appropriately: \everycr \everydisplay \everyhbox \everymath \everypar ...