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

learn more… | top users | synonyms

0
votes
0answers
52 views

Packages for programming documentation [on hold]

I am writing an exercise in school in which I've done some programming. I need to document and explain my design choices in my programming. Aren't there any suitable packages to create some kind of ...
8
votes
5answers
314 views

A more elegant version of the \ifnot macro

A TUGboat article of 15 years ago mentions an \ifnot macro by David Kastrup whose implementation is: \def\ifnot#1{#1\else \expandafter\expandafter\fi \iffalse\iftrue\fi} However, this macro ...
4
votes
1answer
40 views

Extract the last word from a sentence stored in a variable

I want to extract the last word of a sentence stored in a variable, e.g. \thevariable. Here is the minimal example. \documentclass{article} % Function to extract the last word of a sentence ...
5
votes
2answers
55 views

How to determine if a macro argument contains the macro itself?

I would like to have a way to detect if a particular macro's argument contains that particular macro itself. Consider the following MNWE: \documentclass{article} \usepackage{etoolbox} ...
0
votes
1answer
26 views

Names on certificates [duplicate]

I have to make some certificates. The main problem is not the certificate itself but to change names between pages. Can I create a list of names, each of appears once for page?
3
votes
3answers
65 views

Find the number of elements in a list that occurs most often

First: This is similar to "Count the number of elements of each size in a list" and "Position of largest element in a list" but it's not the same. Code + question: \documentclass{beamer} ...
3
votes
2answers
103 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 ...
6
votes
2answers
180 views

How can I use a list stored in aux and insert its output into a tikz node?

# Update 2015-03-19 Better Answer Found This question is part of a trail of questions. The goal mine was to use this list inside of a tikz node, but I removed that from previous questions in the ...
2
votes
1answer
57 views

The text instead of chapter number

I just get some code from Pretty Table of Contents and modify it for my purpose)). But I need some variable text parameter or command for using instead of chapter number in the Table of Contents. ...
12
votes
3answers
390 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} ...
3
votes
2answers
180 views

How can I loop thru a list of inputs that come after \maketitle, yet use that list as part of the \maketitle command?

Multilingual Document Question I would like to follow the principle of "don't repeat yourself" and create a single list of inputs, which are actually various versions of the same document in ...
3
votes
3answers
168 views

How can I create a list as a variable that can be appended and eventually typeset?

Question In languages such as Python, you can define a list like so: example_list = ['apples'] I can append this list like so: example_list.append('oranges') I can print this list using print ...
6
votes
2answers
87 views

Iterator-like command, where each use expands to an item from list defined earlier

What is the simplest way to create an iterator-like macro (in the functional programming sense) in pdfLaTeX? I'd like to predefine a list of elements (to simplify we can assume that it is plain ...
1
vote
0answers
67 views

What is the core of TeX as a programming language? [closed]

Tex (and LaTeX) mix programming elements with typesetting ones. It's often confusing to a beginner to tell them apart. Could anyone show me a list of the very core commands of TeX (and perhaps LaTeX) ...
1
vote
1answer
56 views

How does one create a counted command (e.g. TODO) for use in a list?

Pretext: I am aware of packages such as todonotes, todo, and fixme, but this is more of a task for learning LaTeX programming. Therefore, the use of additional packages downloaded from CTAN is ...
0
votes
0answers
38 views

Command showing note page of the next frame

This question is based when I read the answer of... Note page showing the next frame I was wondering if it is possible just to define a command like \insertslideintonotes{<scale>} which then ...
5
votes
1answer
42 views

How to deduplicate and sort a list of \pagerefs?

I have a document comprised of three large, multi-page tables, all of which have links to items in a list of figures at the end. By generating md5 labels when I generate the latex for the tables, I ...
4
votes
2answers
49 views

Change location of increasing text length

I have a very specific question and I hope someone can give me the benefit of their experience. I have around 17000 lines of text. I am printing this text onto somewhere around 80 double sided pages, ...
3
votes
2answers
157 views

Deleting duplicates from a comma-separated list of strings

This is a followup to Difference in compilation time between two slightly different versions. As became obvious when asking that question, the speed of that compilation is seriously affected by the ...
5
votes
2answers
209 views

Is it possible to insert C++ code into LaTeX?

I mean C++ doing some calculation not inserting the code as a text.
6
votes
1answer
62 views

Delimited \def's and expansion

I try to understand how work the macro named \separator in MWE . \documentclass[]{article} \def\separator#1\separator#2{% \unexpanded{#1}% \ifx*#2% \else , \expandafter\separator\expandafter#2% \fi ...
4
votes
2answers
363 views

Is it a convenient way to write longer program codes in LaTeX?

Before I only used ifthenelse and for loops, but not complicated data structures. I don't know what is the convenient way to write longer codes. As an example I would like to generate a random ...
1
vote
1answer
61 views

How to write totally expanded macro to file (with LaTeX kernel)

I want to write value of the macro \@authortofile to a file. Inside the macro it is another macro which is defined as separator between some words: \def\@separator{\def\@separator{, }} When I try ...
3
votes
2answers
126 views

Separator between author names (with LaTeX kernel programming)

I try to make my own macro for a typesetting an authors block instead of using package authblk. How can I suppress separator near the fist author of the article. Main condition is to use only LaTeX ...
0
votes
0answers
54 views

modify files and convert them to pdf

Say I have a bunch of word documents, powerpoint and excel files. I have some cover photo. I want to convert the files to pdf, add the cover photo and footer to the bottom of each page hello world ...
3
votes
1answer
114 views

Write/Read values of the LaTeX commands (like \title, \ author etc) in file using Lua

This problem relate with other my question here . I found a solution with pdfpages package thanks to TX.SX: \documentclass[]{scrbook} \usepackage{authblk} \usepackage{pdfpages} ...
0
votes
0answers
222 views

Creating a Multiple Choice Math Test with LaTeX and Automating It

I have decided to write an application which can manage test questions related to Mathematics. This application will use LaTeX as an intermediate format between questions and PDF output. Questions ...
0
votes
0answers
70 views

New header for moderncv classic style

I would like to achive a header like this for the moderncv classic style. Edit: For convenience I modified the header from the link to be in english. The thing on the left is a header with a table ...
7
votes
1answer
186 views

Brainf**k Interpreter in LaTeX

Is there a way to build an interpreter for LaTeX to Brainf**k? A short introduction on how to tackle the task would be appreciated.
3
votes
2answers
97 views

“Runaway argument?” error with \NewEnviron

I have two files. Basically, the main file just loads the environ package and inputs the secondary file. The secondary file creates an environment that basically does nothing, and creates one instance ...
3
votes
3answers
110 views

Beamer - writing a macro to uncover only item i of a enumerate in a frame

I would like to repeat a certain frame at multiple locations in my talk. However, at each time, I want either all the items to be uncovered or only item i to be uncovered. How do I define a macro ...
4
votes
1answer
52 views

Weird tipx error

Just for fun I wrote a converter for decimal numbers that prints them in bases < 37: \documentclass{article} \usepackage{fixltx2e,hyperref,ifthen} \usepackage{tipx} \makeatletter \newcount\mod ...
3
votes
2answers
151 views

Compute the difference between two time points on different dates

This is a follow-up question to How to compute the difference between two time points (e.g., 11:30 am and 01:20 pm => 110 min)?. Consider the code from David's excellent answer here: ...
1
vote
1answer
60 views

Default spaces between letters in math-mode

Question for TeX-gurus. Sometimes I find that the default spaces between letters in the math TeX-mode is to short. Say, I would prefer to have slightly increased spaces between abc in $abc$. On the ...
1
vote
0answers
80 views

How to make listing program ConTeXt at LaTeX ?

I want make listing program Context at LaTeX, my MWE like this : \documentclass[]{article} \usepackage{listings} \usepackage[dvipsnames]{xcolor} \lstset { frame=single, framesep=\fboxsep, ...
21
votes
3answers
266 views

How to access the last line of a paragraph with LuaTeX

Consider the following code, using traditional TeX programming that through a series of boxing and unboxing, grabs the last line of a paragraph and centers it. \documentclass{article} ...
4
votes
3answers
86 views

Claim Check Set From A List of Clients

I don't know that this fits here, but here's my question: I'd like to make a set of claim checks from a list of clients so that they can all be printed together within the same PDF. I'm looking for ...
4
votes
1answer
130 views

How to merge two rows of 2 columns into a single row of 4 columns without modifying the data entry?

At the beginning I designed a table with a huge number of rows of acronyms. The table has two columns and occupies \textwidth, as follows. \documentclass{article} ...
15
votes
2answers
194 views

\expandafter with \uppercase ordering

As I understand it, the behavior of \expandafter is such that if \a and \b are macros, then \expandafter\a\b will first expand \b then \a. But my understanding must be wrong, because I don't ...
3
votes
0answers
149 views

How can I programmatically draw a nonlinear writing system with automatic graph relaxation? [closed]

Alex Fink & I have a non-linear written language, UNLWS. Maintaining its grammar document in Google Docs is growing excessively cumbersome, however, because of how much time it takes to load each ...
2
votes
2answers
135 views

LaTeX3: If next in input stream is command X or environment X, do Y else Z

Because I write my own document class (okay, I try to ...), this question bothers me for weeks as there are many situation, in which I need something like this. Is there a way to test, if the next ...
1
vote
1answer
142 views

How to open AdobeReader with arara?

... strange question you will think and you are right, but there are some features, that are not shown in the PDF-Viewer from TeXworks, tooltips for example. I tried this rule, which executes an ...
6
votes
2answers
136 views

Reading number from file into variable — How to put a number into my document that increments with every compilation?

I am not that much into TeX/LaTex programming ... but what I want to do is the following: How to put a number into my document that increments with every compilation My ideas so far are: use a ...
3
votes
1answer
69 views

Conditional structure based on \rand value comparison

I have a simple code that inserts a complex layout for figures and I would like to randomly alternate the position options (for instance, alternating between top and bottom positioning: ...
7
votes
1answer
204 views

How can I optimize the arara password program?

I have written the following (runable) arara-program, which creates a password-locked pdf with adjustable prohibited access rights: secure.yaml !config # GhostScript-ps2pdf password-security rule ...
2
votes
1answer
87 views

The inputenc package slows down LaTeX compilation

When using packages inputenc and fontenc I observed that the inputenc package strongly slows the compilation speed. The situation is as follows. Let we have \usepackage[cp1251]{inputenc} ...
6
votes
4answers
228 views

Multiply fine tuning with a thinspace \,

What I want is a redefinition of command \, to the version \,[N] for given integer N \, % standard usage \,[2] % the same as \,\, \,[3] % the same as \,\,\, and so on The usage of \hspace instead ...
2
votes
1answer
2k views

Three dots instead of \ldots

When writing the TeX-codes we often use the 6-symbols \ldots command. It should be more comfortable to type merely three dots ... instead. Just the same as for TeX-parsing the minus symbols - or -- or ...
4
votes
5answers
184 views

macros, category codes, how to pass stuff with cat codes inside?

The original question is below (it was a bad simplification of the problem I had and also before being edited, it also contained major syntax errors). The problem that originated the question is why ...
4
votes
2answers
298 views

Parsing and programming in TikZ

Background: I'be been reading the PGF manual (keys section) and today the TeX Book just arrived in the mail and just started reading chapter 7 (How TeX reads what you type) -- feeling like Mickey ...