Questions tagged [programming]
{programming} is about how (La)TeX can be used as a programming language.
674 questions
5
votes
2
answers
205
views
Optimization of a function that recursively splits a sequence of tokens
I currently have the following code to recursively split and access a sequence according to a list of separators:
%% -------------------------------- PREAMBLE -------------------------------- %%
\...
3
votes
1
answer
73
views
Provide extra constant arguments to a mapped function
Consider the following code:
\documentclass[10pt]{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\split}{m m}{
\seq_set_split:Nnn \l_tmpa_seq{#2}{#1}
\seq_map_indexed_function:...
2
votes
2
answers
172
views
Odd behavior of regexp in expl3
I want to save the value from some command (e.g. from \title) in an external text file, having cleaned it up from TeX's syntax beforehand. I decided to do it with the help of regular expressions on \...
9
votes
6
answers
534
views
How to create and use an array of strings?
How can I index into an array of "strings" (text to be typeset) in Latex? If I were to write something in Python, it might look like this:
dow = [
"Sunday",
"Monday",
...
9
votes
4
answers
745
views
In LaTeX3, how to iterate on all tokens, including spaces?
In LaTeX3, token lists collapse spaces. Is there a way to avoid that and call a function on all tokens, without collapsing spaces. For example, I would like the following function to display the ...
6
votes
1
answer
201
views
In Tikz, how to make a command that will pave a zone of my page with N*M of the same rectangular node?
Consider that I have a command that produces a Tikz node:
% First parameter: node name
% Second parameter: node width
% Third parameter: node height
\newcommand{\makenode}[3]{
\node (#1) [draw, ...
5
votes
1
answer
215
views
Mapping structure in LaTeX3
I'm developing a LaTeX class for typesetting theses at the University of Trento, aiming to streamline every aspect of the thesis formatting process.
One feature I want to implement is allowing ...
0
votes
1
answer
74
views
Unecessary checks before calling `\cs_if_exist_use:cTF`?
Consider this wrapper as an example:
\prg_new_conditional:Nnn \check_engine:n{p,T,F,TF}{
\tl_trim_spaces_apply:nN{#1}\__check_engine:n
}
\cs_new:Npn \__check_engine:n #1{
\bool_lazy_any:nTF{
...
1
vote
0
answers
109
views
Problem with conditional: TF version working, but not the p version
I reused the code provided as an answer here (I tried to make it a new conditional)
\prg_new_conditional:Npnn \if_font_exist:nnnn #1#2#3#4{p,T,F,TF}{
\group_begin:
\tl_if_empty:nF{#1}{\...
2
votes
1
answer
139
views
tl_trim_spaces and tl_if_blank?
Is there any input for which, once processed with tl_trim_spaces could lead to tl_if_blank being true AND tl_if_empty being false?
1
vote
2
answers
198
views
LaTeX3 version of expandafter-ifx-csname?
I currently have this code from a previous question (link here)
\NewDocumentCommand \IfFontTF {mmmmmm}
{%
\begingroup
\fontencoding{#1}\fontfamily{#2}\fontseries{#3}\fontshape{#4}\try@load@...
2
votes
2
answers
125
views
What does \token_if_expandable:N(TF) actually test?
In LaTeX3 am wondering what \token_if_expandable:N(TF) actually test? The documentation says:
Tests if the ⟨token⟩ is expandable. This test returns ⟨false⟩ for an
undefined token.
but I am guessing ...
0
votes
2
answers
128
views
Understanding expansion patterns related to \exp_args:Ne
I have read tens of pages on expansion, and for whatever reason, I am still missing a clear understanding. To help me understand, I would like to focus on a specific example.
Consider the following ...
5
votes
4
answers
420
views
How to check if a font exists with pdflatex?
When using XeTeX or LuaTex and fontspec, one can use \IfFontExistsTF{font name}{yes code}{no code}. What would be the best way to test if a font exists/can be loaded when fontspec is not available (...
1
vote
1
answer
147
views
Check if an input is a dim or a skip/muskip in an expandable way?
I am wondering how to create efficient expandable functions in LaTeX3:
\check_if_dim:n
\check_if_skip:n
\check_if_muskip:n
that would check if an argument can be parsed as a dimension, a skip or a ...