Questions tagged [programming]

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

Filter by
Sorted by
Tagged with
3 votes
1 answer
129 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,257
0 votes
3 answers
53 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,257
6 votes
2 answers
353 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,257
2 votes
1 answer
188 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,460
3 votes
3 answers
643 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
360 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,257
4 votes
2 answers
87 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,257
5 votes
3 answers
228 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,257
0 votes
0 answers
95 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,257
0 votes
2 answers
107 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,257
0 votes
1 answer
62 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,257
0 votes
1 answer
94 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,257
1 vote
0 answers
85 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,257
4 votes
3 answers
148 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,257
5 votes
4 answers
317 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,257
1 vote
2 answers
68 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,257
1 vote
1 answer
36 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,257
3 votes
1 answer
51 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,257
3 votes
1 answer
129 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,257
24 votes
4 answers
9k 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
35 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
73 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 ...
Jonatán O. Perren's user avatar
5 votes
4 answers
421 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
148 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
76 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
84 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
55 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
77 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,257
0 votes
0 answers
46 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
53 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
116 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
73 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
413 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
  • 867
4 votes
1 answer
114 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
  • 938
4 votes
1 answer
99 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
  • 938
1 vote
1 answer
41 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
  • 938
2 votes
1 answer
124 views

Remove extra space in abbreviated journal title with jabbrv?

I would like to abbreviate journal titles in my bibliography. One method employs the jabbrv package (https://tex.stackexchange.com/a/66821/293248), in particular with files from this Overleaf template ...
Anzhou He's user avatar
0 votes
0 answers
50 views

Does anyone have an idea to recreate this code format using listing or with another option?

I tried to recreate this code format with \usepackage{listingsutf8}. I made this code using Inkscape. My code in LaTex is: \documentclass{article} \usepackage{listingsutf8} \usepackage{xcolor} \...
Caleb Franco's user avatar
0 votes
0 answers
94 views

Using external dependencies in my Latex main file

I'm using the package "snapshot" to generate a list of external dependencies of my filename.tex file. This list's result is stored in a filename.dep file. The goal would be to use this ...
Christophe's user avatar
3 votes
3 answers
216 views

Why use \msg_error:nn(nnnnn) in expl3?

expl3 has several kinds of error/warning types that can be issued during execution, in particular: \msg_fatal:nn(nnnn) halts the execution; \msg_critical:nn(nnnn) stops scanning the current file; \...
desio's user avatar
  • 43
1 vote
0 answers
32 views

Dynamically changing document language [duplicate]

The problem may appear silly to some, but it has some applications. For the last two years, I have been updating my CV in two languages: LANG1 and LANG2. The task has proven particularly problematic ...
qarabala's user avatar
  • 202
2 votes
1 answer
166 views

What is the difference between \cs_new_eq:NN and \cs_gset_eq:NN?

What is the difference between \cs_new_eq:NN and \cs_gset_eq:NN, defined in section "Copying control sequences" of The LaTeX3 Interfaces manual (which is section 4.3.4 on p. 19 of the ...
Evan Aad's user avatar
  • 11.1k
3 votes
2 answers
303 views

Why don't c- and f-type expansions respect protected commands?

According to this answer, all functions without a star are (or at least should be) \protected, this way they don't expand on x or e type expansion or when written to a file. f and c type expansion ...
Evan Aad's user avatar
  • 11.1k
9 votes
2 answers
312 views

Difference between the V function parameter specifier and the o specifier in LaTeX3 programming

In LaTeX3 programming, how does the V function parameter specifier differ from the o specifier? How is the o specifier meant to be used in contrast to the V specifier? A related question: V vs. x
Evan Aad's user avatar
  • 11.1k
1 vote
1 answer
128 views

How can I add "dots" between the nodes of this Latex neural network in the input and hidden layer? I want 5 nodes in the input layer not 12

% latexdraw.com % 21/02/2021 at 22:20 \documentclass[border = 0.2cm]{standalone} % Required package \usepackage{tikz} \begin {document} % Input layer neurons'number \newcommand{\inputnum}{12} % ...
Zmkan3's user avatar
  • 13
2 votes
1 answer
123 views

How to make the simplest and most efficient (expandable) Chess960 starting position generator

Chess960 (also known as Fischer Random Chess, unfortunately not named after @UlrikeFischer, the author of xskak) is a chess variant where the non-pawn pieces are shuffled randomly, but where their ...
Gaussler's user avatar
  • 12.8k
1 vote
0 answers
35 views

Is there a program that automates the use of a standardized Tex document?

I have a standardized LaTex document that contains two letters and several pages of documentation. This is to be sent to each and every customer we have, for every order we deliver. The document stays ...
Fridtjof85's user avatar
0 votes
1 answer
38 views

Small number of programming instructions [duplicate]

I am writing an article and I need to insert a small number of code instructions for a topic related to computer science. I know the existence of many packages, such as Listing, Algorithmic and so on, ...
Ospite007's user avatar
0 votes
1 answer
79 views

Tikz does not always calculate equations

The attached code attempts to print the first letter of the English alphabet using the alphalph package and f_1 by simple arithmetic. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{...
oppe3782's user avatar

1
2 3 4 5
13