Questions tagged [expl3]
{expl3} is the programming "language" written for the LaTeX3 project. It is a library of common functions for storing and manipulating data and performing higher-level logical tasks than commonly provided for in TeX and LaTeX.
353
questions
20
votes
2
answers
766
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 ...
35
votes
3
answers
78k
views
File l3backend-pdfmode.def not found when loading expl3
I updated my TeXlive distribution a couple times in the past week, and now I get this error when I include package expl3 (or any other package that includes it, such as fontspec).
Before the updates ...
6
votes
2
answers
759
views
Keyboard TAB character in argument v (xparse)
I'm trying to understand how the TAB character of the keyboard behaves within verbatim. I have defined a new command using the v argument of the xparse, but, I get errors and a rather strange output ...
75
votes
2
answers
9k
views
What do ExplSyntaxOn and ExplSyntaxOff do?
Related to the question What do \makeatletter and \makeatother do? for LaTeX2e, here related to LaTeX3
What do \ExplSyntaxOn and \ExplSyntaxOff do?
4
votes
1
answer
292
views
Extending xparse for new arguments
I was looking for a way of grabbing sub and superscripts as optional arguments to a command in xparse. That is, \foo_{a}^{b} would receive a as an optional argument and b as another optional argument. ...
11
votes
1
answer
595
views
TL2018 (MacTeX) and TikZ calligraphy library
Under MacTeX 2018 the following TeX file:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\tikz\draw[decorate,decoration={...
27
votes
6
answers
1k
views
How do I get a value out of a group?
I've just recovered from my first real foray into LaTeX3 programming. It was ... an experience. Not a completely unpleasant one and once I'd gotten used to the syntax then I found it a lot easier ...
27
votes
2
answers
1k
views
How do I insert a tie (~, non-breaking space, tilde) under expl3 syntax?
I need to define a token list of the form
\tl_new:N \g_silly_tl
\tl_set:Nn \g_silly_tl { Text ~ and ~ a ~ tie:?? }
How do I do this?
More generally, is there a reference where one can see how to ...
22
votes
1
answer
2k
views
Where I can find introduction to programming in expl3?
Is there an introduction to programming in expl3?
I saw http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/l3kernel/expl3.pdf
but it doesn't discuss control structures (For example does ...
45
votes
2
answers
2k
views
Moving to LaTeX3 for package authors
I would like to write a package using as much of LaTeX3 stuff as possible (in particular expl3, xparse and xtemplate).
What should I read to learn these?
In particular: I know that there are good ...
22
votes
2
answers
3k
views
Where can I find the LaTeX3 manual?
Few month ago I saw a big pdf-manual of all LaTeX3-packages and the new syntax. I think it was bigger than 300 pages. I can't find it on the web.
Does anyone have a link?
16
votes
1
answer
238
views
Avoid @ hackery: How can I preserve spaces in a format specification when processing the specification with expl3 and PGF/TikZ?
This is a simplified version of part of the code I've been using in answers based on chronos, an attempt to create something somewhat like a substitute for the problematic chronosys.
This code works ...
14
votes
5
answers
1k
views
Sorting a comma-separated list with LaTeX?
Is there a simple way to sort a comma separated list alphabetically in LaTeX? I tried to write a macro (\sortlist{World, Hello} → "Hello, World") using the l3sort documentation example but it ...
3
votes
2
answers
374
views
Misplaced alignment tab character &. with tabularray and expl3
I'm trying to pass as a parameter a list of rows in tabularray. (the same list will be used a 2nd time)
With Showing `\_tl` variables that contain `&` and `\hline` tokens
I tried to use this code ...
156
votes
6
answers
14k
views
LaTeX3 versus pure Lua
Reading this site for the last nearly two years I've learned a lot about LaTeX3 (which I had previously understood to be a defunct pipe dream) and LuaTeX (of which I was previously totally unaware). ...
20
votes
3
answers
17k
views
Mismatched LaTeX support files detected
I just updated my TeXLive installation on my iMac and got the following error message:
/usr/local/texlive/2020/texmf-dist/tex/latex/l3kernel/expl3.sty:77: LaTeX3 Error:
Mismatched LaTeX ...
20
votes
3
answers
1k
views
How to \let an xparse defined command?
Let \example be an xparse defined command, which takes one optional and one mandatory argument. The definition of \example cannot be modified (e.g. because it comes from a third-party package).
The ...
13
votes
1
answer
1k
views
LuaLaTeX stopped after updating expl3 package
After the latest TeX Live updates I keep getting these errors:
LaTeX Warning: You have requested, on input line 26, version
`2018/02/21' of package expl3,
but only version
...
13
votes
2
answers
741
views
Write LaTeX3 variable to aux file and recover it
I was wondering how to write a LaTeX3 variable to an aux file and read it in at the very beginning of a document. The motivation of this problem is that I would like to get rid of my LaTeX2 counters ...
8
votes
1
answer
704
views
How can I set the PDF TrimBox dynamically (with a macro) and compiler independent?
Introduction
At the moment I’m preparing a custom class which is likely to be compiled with XeTeX or LuaTeX. It is for a book layout that should be professionally printed and therefor I want to set ...
8
votes
1
answer
3k
views
Latest MiKTeX-Update broke XeLaTeX with fontspec
I updated MiKTeX a few days ago and since then I cannot compile XeLaTeX with fontspec anymore.
\documentclass{article}
\usepackage{fontspec}
\begin{document}
Hello world!
\end{document}
When I try ...
5
votes
3
answers
349
views
expl3 function for fixed number of expansion steps
In expl3, say we want to assign a value to a token list variable \l_foo_tl while expanding the value a certain number of times. For a single expansion the easiest way is
\tl_set:No \l_foo_tl { ... }
...
1
vote
2
answers
322
views
How can I read the whole file content verbatim into a (expl3) string variable?
Problem Description
As in the title.
MWE:
\documentclass{article}
\begin{document}
% first write some file content for demo...
\begin{filecontents*}{test test.txt}
line 1 !?#\xyz
line 2
\end{...
36
votes
6
answers
4k
views
Reducing Fractions Automatically Using LaTeX3
Consider the following code:
\documentclass{article}
\begin{document}
\noindent
Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip]
For example, I would like the fraction
\[ \frac{...
15
votes
5
answers
691
views
\tl_replace_all:Nnn recurse subgroups
Suppose I had a token list variable containing abc{ab{abc}c}. I want to replace every occurrence of b with d. As you can see there are subgroups containing b which I also want to have replaced, so ...
8
votes
1
answer
483
views
SplitArgument on colon doesn't work under expl3 syntax
\documentclass{article}
\usepackage{xparse}
\DeclareDocumentCommand\TestA{>{\SplitArgument{1}{:}}m}{%
\Example #1
}
\ExplSyntaxOn
\DeclareDocumentCommand\TestB{>{\SplitArgument{1}{:}}m}{
\...
5
votes
1
answer
331
views
Avoid passing an empty [optional argument] an environment (with verbatim content) using xparse?
this query is related to How to pass an optional argument to an environment with verbatim content? (whose solution did not work in my case) and with Emulating @ifnextchar in expl3 (which is the one I'...
4
votes
1
answer
243
views
How can I have (or emulate) 'normal' behavior with \ParallelPar when working across pages (on a spread)?
The parallel package is able to set parallel columns and align them at \ParallelPar tokens:
\documentclass{article}
\usepackage{parallel}
\usepackage{mwe}
\begin{document}
\begin{Parallel}[c]{.45\...
4
votes
2
answers
356
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
1
answer
320
views
Automatic theorem list
In the accepted answer to Code between \begin{environment} and \end{environment} stored in an array it's shown how to create an automatic list of theorems using expl3 syntax. However the \...
2
votes
2
answers
176
views
expl3 - An environment to explain the calculation of an expected value (finite case)
I would like to automate the production of the following output (the formatting is not so good but I will do a better one later).
This picture has been obtained using this code :
\documentclass[12pt,...
1
vote
1
answer
101
views
expl3 - Left pop a list - How to split a temp var coming from a \seq_pop_left?
I would like to split a multiline content regarding \\ and then split each item regarding . .
Then I would like to iterate over each list in parallel such as to print their items together suchas to ...
57
votes
7
answers
3k
views
LaTeX3-sensitive editors
I'm starting to embed LaTeX3 code in my custom classes and packages -- and enjoying it more the further I learn about it --, but at least to me it would make for an even better experience if, as it is ...
19
votes
1
answer
2k
views
What's the correct way to define package options in expl3?
For writing a package it's usually important to be able to define package options. Since the package I'm writing is in expl3 I wondered whether there's a l3ish way of defining key-value-package-...
16
votes
1
answer
934
views
Comparing LaTeX3 token list to string
Is there a way to compare a LaTeX3 token list to string without having to create a temporary token list? I though I'd use \tl_use:N to get the contents of the token list for the comparison, but that ...
14
votes
2
answers
641
views
aliasing vs variants --- preferred practices?
This is somewhat related to a question I asked earlier here.
I'm trying to split a token using a delimiter. However, the delimiter is stored in a token. Looking at the most recent documentation, I ...
12
votes
1
answer
2k
views
Using of \usetikzlibrary in an expl3 package fails
In the example below I provided a small test package mytestpackage.sty which uses the syntax of expl3.
If I use the command \usetikzlibrary inside the package I will get the error:
Runaway argument?
...
11
votes
1
answer
481
views
Querying the state of a boolean from lua
I can query and use the states of counts in lua without problem. But now I'm wondering how to at best do it with booleans. I have been looking at the token library but it seems not to allow to get and ...
11
votes
4
answers
1k
views
Position of largest element in a list
Consider the following:
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
\def\valueA{7}
\def\valueB{19}
\def\valueC{41}
\def\valueD{31}
\def\...
11
votes
2
answers
724
views
Workaround how to use expl3 functionality in tikz
What I want to do
I want to create a command \planfigur{<edges>}{<angles>} which draws a triangle using TikZ. \planfigur should have 2 mandatory arguments, which let me specify edges and/...
11
votes
1
answer
483
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: '\...
11
votes
1
answer
303
views
Undefined sequence error with calligraphy tikz library
The following MWE is from calligraphy's manual (p.9) with Joseph Wright's workaround for the library's use of obsolete functions:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{...
10
votes
3
answers
522
views
How to document a expl3 macro using dtx
I am writing the documentation to a package implemented in expl3 using ltxdoc, and the relevant part would look like
% \begin{macro}{\conteq_args_once}
% Some explanation
%
% \begin{macrocode}
\...
7
votes
3
answers
598
views
mhchem vs expl3 bug
Does anybody know how to fix this problem with mhchem package?
! Undefined control sequence.
<argument> \l__mhchem_cg_isScript_bool
Recently I've found this part of mhchem.sty code:
\...
6
votes
2
answers
3k
views
latex3 complaining about Undefined control sequence. But it is defined!
I've tried pairing this down, but each time I do that I'm either correcting my mistake or something. So here's a slightly unwieldy MWE.
In a nutshell, what I'm trying to do is....
I'm writing a ...
5
votes
1
answer
2k
views
Custom points table for exam
I'm trying to create a custom points table for exams. Currently, the instructors in our department write these exams in MS Word, so to ease the growing pains, I'd like to emulate the old design as ...
5
votes
1
answer
328
views
What is the maximum limit of elements in a list (expl3/xparse)?
I have a query with the maximum number of items that can be saved in an expl3 list. Thanks to the response that @egreg gave me in Avoid passing an empty [optional argument] an environment (with ...
5
votes
1
answer
374
views
Expl3 syntax: graceful handing of conditional/undefined arguments
In this thread, writing newcommands, user interface advice request, some of you taught me how to write a function that can generate an elaborate header.
In that case, my problem was complicated ...
4
votes
2
answers
296
views
Extra line in a tabular using expl3 syntax
I'm having trouble using (the amazing) expl3 package with a tabular environment. Specifically, I'm getting a full extra row in my tabulars when creating rows using \seq_map_inline. I can avoid this ...
3
votes
2
answers
359
views
Count the number of elements of each size in a list
Comment: The following question is somewhat similar to "Position of largest element in a list" but I'm (unfortunately) not familiar what LaTeX 3 programming so I'm forced to ask. :(
Code: Consider ...