Skip to main content

Questions tagged [programming]

{programming} is about how (La)TeX can be used as a programming language.

Filter by
Sorted by
Tagged with
4 votes
3 answers
177 views

Expansion in Latex3 when transforming an input and forwarding it to another function

There are still a lot of mystery around expansion in LaTeX for me, but even given that, there is something I don't understand in LaTeX3. Let's say (just for the example), that I want to test whether ...
Vincent's user avatar
  • 5,583
0 votes
4 answers
93 views

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. If I have some argument coming from the document/user level, and I would like to detect if this argument have an inner protected ...
Vincent's user avatar
  • 5,583
0 votes
2 answers
45 views

Check if a predicate is satisfied on all tokens in LateX3 using conditionals

I am trying to write an expandable conditional that test if a condition is satisfied and it does not seem to work as expected. Currently here is my approach (with \token_if_letter_p as an example of a ...
Vincent's user avatar
  • 5,583
6 votes
1 answer
155 views

Long and protected macros in LaTeX3

I have questions about the following functions in LaTeX3: \token_if_macro_p:N \token_if_long_macro_p:N \token_if_protected_macro_p:N \token_if_protected_long_macro_p:N How do they behave with the ...
Vincent's user avatar
  • 5,583
3 votes
3 answers
279 views

Testing if a string is a hexadecimal string in LaTeX3: code review, optimization, expandability, and protection

Consider the code in LaTeX3. It tests whether a string is a hexadecimal string (optionally also testing the length of that string) (a string where every character is either 0-9 or A-F). \documentclass[...
Vincent's user avatar
  • 5,583
0 votes
0 answers
59 views

Fast way to test if an argument is a HTML color-code in LaTeX3?

I recently asked how to test if an argument is an integer using LaTeX3 (here). I am wondering how to use the same approach to test if a string correspond to a HTML color-code. Currently, I use the ...
Vincent's user avatar
  • 5,583
3 votes
1 answer
99 views

Branching on whether a color is defined using xcolor or xcolor-material?

I am trying to branch on whether a color (defined in xcolor or xcolor-material or using the utilities provided by these packages) has a name that can be used in the \color command (from the xcolor ...
Vincent's user avatar
  • 5,583
0 votes
0 answers
46 views

Splitting and forwarding to bool_lazy_any in LaTeX3?

I currently have a function which does the following: \NewDocumentCommand{\myfunction}{m m m}{ \str_if_eq:eeTF{\c_sys_engine_str}{#1}{#2}{#3} } which allows me to do something as: \myfunction{...
Vincent's user avatar
  • 5,583
2 votes
2 answers
139 views

Build a new command "newsymbol" with NewDocumentCommand

I want to create a new command \newsymbol, which functions like \newcommand, but with the difference that math is ensured. I also have another reason, why I want to define this new command, namely so ...
Make42's user avatar
  • 1,822
4 votes
1 answer
113 views

Why \IfPackageAtLeastTF{⟨package⟩}{⟨date⟩}{\PassOptionsToPackage{⟨option⟩}{⟨package⟩}}{} doesn't pass ⟨option⟩ to ⟨package⟩?

My current version of parskip is 2021-03-14 so: \IfPackageAtLeastTF{parskip}{2018-08-24}{\PassOptionsToPackage{indent}{parskip}}{} \usepackage{parskip} should pass the indent option to parskip. But ...
Denis Bitouzé's user avatar
0 votes
0 answers
24 views

How can I adjust the spacing between the number and the title of each level in TOC to create automatically a nested list?

In this code, I have defined custom sectioning formats using the titlesec package. However, I'm having trouble adjusting the spacing between the section numbers and titles, especially when the section ...
Antonio Maria Di Mauro's user avatar
3 votes
2 answers
146 views

Best Practices for Integrating Computer Algebra Systems (CAS) into LaTeX Documents

I am currently working on enhancing my LaTeX documents to involve complex mathematical equations. Managing these equations manually often leads to errors, especially when changing dependent equations ...
Foad's user avatar
  • 1,005
2 votes
1 answer
57 views

How to trim spaces without expanding what is inside in expl3?

Consider the following pattern: \NewDocumentCommand{\mycommand}{m}{ \myinternalcommand:n{#1} } \cs_new:Nn \myinternalcommand:n{ \tl_if_single:nTF{#1}{TRUE}{FALSE} } and let's say that I want ...
Vincent's user avatar
  • 5,583
3 votes
1 answer
148 views

LaTeX3 regex not working

I have a very strange bug and I guess I am not using LaTeX3 regexes as they are supposed to be used. My current document looks like this: \documentclass{standalone} \ExplSyntaxOn \regex_new:N{\...
Vincent's user avatar
  • 5,583
1 vote
3 answers
63 views

In Latex3, how to test if all tokens in the input verify a test (for example \token_if_letter or \token_if_space)?

In Latex3, I would like to write a function that checks if every token of an input verify a predicate. Basically I would like the multitoken version of this command: \NewDocumentCommand{\mychecksingle}...
Vincent's user avatar
  • 5,583
6 votes
2 answers
363 views

if_exist macros in LaTeX 3: what are they doing if they do not check the type of things they are supposed to check?

In the documentation of interface3, for several macros with the pattern xxxx_if_exist for xxxx being bool, str, seq and many others the following appear: Tests whether the <boolean> is ...
Vincent's user avatar
  • 5,583
1 vote
1 answer
219 views

Is LaTeX a programming framework of TeX?

My take from What is the difference between TeX and LaTeX? is that TeX is the programming language that renders the document. LaTeX is a well-known macro package for TeX with the aim to make the ...
Ooker's user avatar
  • 1,520
3 votes
3 answers
659 views

Put many images into multiple pages programmatically

I have many images, for example image01.jpg image02.jpg ... image80.jpg I want to put those images into a document, 8 images per page, 4 rows and 2 columns (assume they will fit into one page that ...
Lu Xu's user avatar
  • 137
10 votes
1 answer
400 views

Moving from pgfkeys to latex3 key-val system to handle package options

I have been advised in this question to move from pgfopts to latex3 to handle package options. I would like to do that but I must admit that I am a little lost. Examples with the patterns I'm using ...
Vincent's user avatar
  • 5,583
4 votes
2 answers
102 views

Difference betwen .is family and .cd in pgfkeys in the context of package writing?

I am using pgfopts to create my own packages and handle options. .family and .cd can be used to group the package options together, but I am not sure to understand the pros and cons of each approach, ...
Vincent's user avatar
  • 5,583
5 votes
3 answers
239 views

Counting the number of occurences of specific characters in a string in an expandable way

This question shows how to count the number of occurrences of a specific character in a string. I would like to do it in an expandable way, and for a list (not only one) of specific characters. \...
Vincent's user avatar
  • 5,583
0 votes
0 answers
99 views

Detect if something is a length?

Is there a way in LaTeX to detect if something is a length with a function of the form: \NewDocumentCommand\iflength{m m m}{%CODE HERE%} where: the first parameter is the thing to be tested the ...
Vincent's user avatar
  • 5,583
0 votes
2 answers
119 views

A macro to check command expandability

I would like to create a command that checks whether an expression is fully expandable, and crashes if not (ideally printing an error message). I would like to do that without a specific TeX engine in ...
Vincent's user avatar
  • 5,583
0 votes
1 answer
66 views

Branch to something when an expression cannot be evaluated by fpeval

I would like to design a \comparator expandable command that relies on fpeval that has 3 branches: true branch when the comparison is equal to 1 false branch when the comparison is equal to zero ...
Vincent's user avatar
  • 5,583
0 votes
1 answer
98 views

In expl3, how to test if something, once fully expanded, contains any character belonging to classes 11 or 12?

I am wondering in expl3 syntax (not using the most recent additions, let's say additions posteriors to 2018 [nothing special about 2018, it's just an arbitrary date to say not too recent]) how to test ...
Vincent's user avatar
  • 5,583
1 vote
0 answers
93 views

Design a generic numeric comparator function using expl3 working for strings, counters, numexpr, dimexpr

I would like to design a generic compare function between numbers, ideally expandable with the following signature: \NewExpandableDocumentCommand{\compare}{r[] m m m m m}{%CODE HERE%} that would be ...
Vincent's user avatar
  • 5,583
4 votes
3 answers
149 views

Problem with a command that prefixes words only if needed when the arguments are provided through macros

Consider the following code coming from this answer, where it adds a prefix to a word, only if the prefix is missing. \documentclass[border=6pt,varwidth]{standalone} \ExplSyntaxOn \...
Vincent's user avatar
  • 5,583
5 votes
4 answers
327 views

An expandable command that adds a string to an argument if the string is missing

I would like to write and expandable command which adds a string S1 at the beginning of another string S2 if S2 does not start with S1 in order to ensure that my string always start by S1. I currently ...
Vincent's user avatar
  • 5,583
1 vote
2 answers
77 views

Macros to change pgfkeys package options on the fly and define custom sets of options

Consider the following code for a package : % Preamble \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{mypackage}[2024/01/01 MyPackage] \makeatletter % Dependencies \RequirePackage{pgfopts} \...
Vincent's user avatar
  • 5,583
1 vote
1 answer
38 views

Command color not working with the name of a color built through macros

Consider the following code and especially the command \nicecolorname which builds the name of a color following the pattern ["nice"][shade][hue]. In its current name, the command \color is ...
Vincent's user avatar
  • 5,583
3 votes
1 answer
61 views

ifmtarg testing a macro that is empty?

The following code works as expected: \NewDocumentCommand{\checker}{m}{\@ifmtarg{#1}{empty}{not empty}} \checker{} % Prints "empty" \checker{x} % Prints "not empty" However, how ...
Vincent's user avatar
  • 5,583
3 votes
1 answer
135 views

Parse every character and transform it into a table column

I am trying to produce an array that will output most ascii characters in a given LaTex font. Currently, I have the following awful code that works: \documentclass{standalone} \usepackage[utf8]{...
Vincent's user avatar
  • 5,583
30 votes
4 answers
14k views

LaTeX v.s. Typst: What is TeX Community's Future Plan? [closed]

Recently I have become increasingly anxious about LaTeX being (possibly) surpassed by Typst due to its simplicity. This answer shows several edges of Typst over LaTeX. I have been arguing with one of ...
Teddy van Jerry's user avatar
0 votes
1 answer
40 views

Help with bar chart

I need to make a graph similar to the photo. I have the beginning of the code in LATEX, but it does not work correctly, you also need to add inscriptions like in the photo, you can write in your own ...
benderrr's user avatar
2 votes
2 answers
82 views

LaTeX does not finish compiling (infinite loop, maybe) when I place multiple \tl_use commands inside the \bool_until_do loop

I am trying to retrieve data from a .aux file using expl3. I want to ignore the first line because it serves a different purpose (hence the \ior_str_get:NN \l_seccion_lista_ior \l_tmpa_tl). The ...
gxono's user avatar
  • 528
5 votes
4 answers
486 views

how can I write an inline hexadecimal value? [duplicate]

How do I write an inline "\0x" without having LaTeX put each value on a new line? "\0x" in C programing identifies a hexadecimal value. I would like to write an inline string of ...
j0h's user avatar
  • 171
0 votes
1 answer
203 views

Is there an alternative to using yap.exe for rendering dvi files within MikTeX?

I have used MiKTeX and the book document class for mathematics layout for more than 10 years with little trouble. The "build" command always runs successfully but, just recently, the "...
keith77777's user avatar
0 votes
1 answer
83 views

Descriptions of m o D for \NewDocumentCommand

Where can I find documentation for m, o ,and D for \NewDocumentCommand as I cannot find them in interface3.pdf. \NewDocumentCommand{\newconject}{momoD(){black}}
Veak's user avatar
  • 1
0 votes
0 answers
111 views

Minted Assembly code indentation problems

I want to align the code as in the source code (image 1), because as you can see in the output (image 2) it comes out completely different. \documentclass[12pt, a4paper]{article} % Language setting % ...
Davide's user avatar
  • 1
1 vote
1 answer
76 views

Beamer: Show frame if it is defined

When constructing larger presentations with beamer, I often split them into several files on which I work individually. For the sake of an MWE, it might look something like this: \documentclass{...
Frunobulax's user avatar
  • 2,228
1 vote
3 answers
82 views

Branch over number of characters of an argument provided to a macro

I currently have the following command: \newcommand*{\setfontshape}[1]{\@ifnotmtarg{#1}{\csname#1shape\endcsname}} that helps me produce the command: \scshape from text sc. I would like to modify my ...
Vincent's user avatar
  • 5,583
0 votes
0 answers
58 views

Automatically calculate years of experience from provided start/end dates

I'm very very new to LaTeX and not even sure if this is possible. \resumeSubheading {Undergraduate Research Assistant} {6 Years \& 3 Months} % 1 <---------------...
Aagam Sheth's user avatar
16 votes
4 answers
2k views

Evaluating TeX output in competitive programming

Online Judges are platforms used in competitive programming. Participants write code that solves a problem. Competitors submit their programs to the online judge, which runs all pieces of code in the ...
wh8658's user avatar
  • 163
0 votes
0 answers
95 views

lstlisting: Configuring it to support Julia type code

I was writing my report, which uses notations from Julia, specifically Catlab.jl. This contains a lot of category theory related symbols. I read the documentation for lstlisting and it does not ...
Nikit's user avatar
  • 1
5 votes
2 answers
117 views

Writing a tex package for better auto brackets

The automatic brackets sizing provided by \left ... \right really often produces too large brackets. I want some package that for a given formula finds the right bracket size selected from \big, \Big, ...
Nicolas's user avatar
  • 161
1 vote
1 answer
92 views

How to prevent .initial:n from setting keys before \ProcessKeysOptions is called?

I am writing myself a package and I want to use imakeidx as a dependency. However, I don't want to make it a hard dependency, and so I was going to add a package option to disable to automatic loading ...
WBob's user avatar
  • 115
4 votes
2 answers
572 views

How to skip a value in a \foreach in TikZ?

Sorry to ask an extremely "entry-level" question, but after googling to get a description of how to do conditional logic in TikZ, I don't see a straight and simple answer. I see a bunch of ...
Addem's user avatar
  • 879
4 votes
1 answer
138 views

Reseting the TotalCount (totcount) each section

I am trying to set-up a system where I can total a counter for each section and print this, then reset each section. MWE: \documentclass{article} \usepackage{xparse} \usepackage{ifthen} \usepackage{...
Harry's user avatar
  • 1,070
4 votes
1 answer
101 views

System to avoid doubling up of spacing after a custom environment

Below is a very simplified example to illustrate a problem with spacing before and after environments: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{amsthm} \usepackage{amsmath} \...
Harry's user avatar
  • 1,070
1 vote
1 answer
50 views

Removing spacing between adjacent sections and subsections (titlesec)

I am building out sections and subsections. The beforesep on subsections is desirable generally, but not if a subsection is invoked directly following a section. Is there any way to take care of this? ...
Harry's user avatar
  • 1,070

1
2 3 4 5
14