New answers tagged latex3
1
vote
How to detect inner spaces at the document level forwarded to token lists in LaTeX3?
We can implement this task using TeX primitives only.
\catcode`~=12
\def\isinnerspace#1{\expandafter\isinnerA\detokenize{#1}\end}
\def\isinnerA#1\end{\expandafter\isinnerC\expanded{\isinnerB#1~{}} \...
2
votes
Expansion in Latex3 when transforming an input and forwarding it to another function
My examples of directly using TeX primitives should help you to more understand TeX principles and its expansion process. Your given task can be solved:
\def\islowercase #1{%
\def\tmpa{#1}\...
5
votes
Expansion in Latex3 when transforming an input and forwarding it to another function
You don't need xparse, unless you're using a rather old LaTeX kernel.
Your _o conditional cannot work, because you're just expanding \str_lowercase:n one level.
In order to see what happens, I'll add \...
5
votes
Expansion in Latex3 when transforming an input and forwarding it to another function
TeX is a macro expansion language, and although expl3 provides various tools, the underlying 'rules' still apply. That means when you do a single expansion of \str_lowercase:n {#1}, you get exactly ...
0
votes
How to detect inner spaces at the document level forwarded to token lists in LaTeX3?
If it's a simple if-contains test and you want to set it up expandable, you might be interested in the etl package:
\documentclass{article}
\usepackage{etl}
\ExplSyntaxOn
% variant finding spaces ...
0
votes
Check if a predicate is satisfied on all tokens in LateX3 using conditionals
As long as you don't need to crank out implicit character tokens of category 11 (letter), the following might do the trick:
\ExplSyntaxOn
\cs_new:Npn \checkifletters {
\exp_args:Ne \check_if_letters:...
2
votes
Accepted
How to detect inner spaces at the document level forwarded to token lists in LaTeX3?
Unprotected spaces are not treated as items in token lists in LaTeX3.
interface3.pdf says:
A token list (explicit, or stored in a variable) can be seen either as a list of “items”, or a list of “...
1
vote
How to detect inner spaces at the document level forwarded to token lists in LaTeX3?
You can use tl_if_in but as shown here you may need to trim first if you really only care about inner spaces.
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\def\hasspace#1{\tl_if_in:nnTF{#...
1
vote
Accepted
Check if a predicate is satisfied on all tokens in LateX3 using conditionals
Your code cannot work, because you unconditionally issue \prg_return_true:.
You can add a special token at the end of the token list and check for it, so the functions know that the end has been ...
3
votes
Testing if a string is a hexadecimal string in LaTeX3: code review, optimization, expandability, and protection
You asked about optimization of compilation time. So, you can try to use TeX primitive features directly, no via expl3 language. Expl3 is a new language inside TeX language then the result will never ...
6
votes
Accepted
Long and protected macros in LaTeX3
These tests are low-level and check exactly what they say - is this macro say \protected, i.e. defined by
\protected\def
(or \edef equivalent). One would not expect to need to use these low-level ...
3
votes
Accepted
Testing if a string is a hexadecimal string in LaTeX3: code review, optimization, expandability, and protection
You want to define conditionals.
\documentclass[10pt]{article}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\ishexadecimal}{o m m m}
{
\IfNoValueTF {#1}
{% no check on lenght
\vincent_ishex:...
9
votes
Testing if a string is a hexadecimal string in LaTeX3: code review, optimization, expandability, and protection
See below.
Yes, there are functions that should be defined protected in your question, for instance \cs_new:Nn \is_hexadecimal:nnTF (and as a result all functions calling it). The reason that's the ...
7
votes
Accepted
Fast way to test if an argument is an integer in LaTeX3?
The following is evil expl3 code (because it uses two happy :D macros) that implements the check for your regular expression in a pretty fast way. One could turn it even faster by implementing the \...
2
votes
Accepted
Referencing commands in l3keys latex3 expl3
As I said before, you need to read up on the syntax to understand what's going on. expl3 (tries) (sometimes, in some ways) to wear its meaning on its sleeve. If you read the syntax, you immediately ...
3
votes
Accepted
Unable to get l3keys choices conditional to work (latex3)
Your issue is that you put the \tl_if_eq:nnTF inside your \exp_not:n block, as such the values of \l_harry_itemj_ws_tl are not inserted there but instead once your code is actually executed there is a ...
5
votes
Accepted
Using \tl_put_right with grouping from latex3 explsyntax
I'm not entirely sure about the purpose of collecting stuff in a global variable which you don't seem to use, but if you do want to collect it while keeping the options local, as Ulrike Fischer said, ...
5
votes
Using conditionals within \tl_put_right from latex3 explsyntax
Another solution if you need forwarding of * often is to define an argument processor for it such that #1 will contain a star if a star was given and be empty otherwise:
\ExplSyntaxOn
\...
4
votes
Accepted
Using conditionals within \tl_put_right from latex3 explsyntax
You're putting \IfBooleanTF{#1}{\task*}{\task} in the token list and #1 will be evaluated at call time, not at setting time.
\IfBooleanTF{#1}
{
\tl_put_right:Nn \l_tmpa_tl { \task* #2 \\ \textit{...
0
votes
Accepted
Adding additional keys to an environment and maintaining existing keys
Solution using @cfr's comment:
\documentclass{article}
\usepackage{tasks}
\ExplSyntaxOn
\keys_define:nn { harry }
{
cols .int_set:N = \l_harry_cols_int,
cols .initial:n = 1
}
\...
9
votes
Accepted
What are these commands in the code?
These are the L3 programming layer commands (also known as expl3)
\tl_new:N \l_lotomat_input_tl
declares a new token list variable
\seq_new:N \l_lotomat_input_seq
declares a sequence variable
\...
Top 50 recent answers are included
Related Tags
latex3 × 1042expl3 × 424
xparse × 105
macros × 81
expansion × 41
programming × 40
tikz-pgf × 28
token-lists × 28
l3regex × 27
l3keys × 27
tables × 26
conditionals × 25
pdftex × 23
luatex × 20
strings × 20
environments × 19
tex-core × 18
package-writing × 17
key-value × 17
comma-separated-list × 17
xetex × 16
errors × 16
best-practices × 12
overleaf × 11
documentation × 11