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

learn more… | top users | synonyms

2
votes
0answers
15 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. Note: Can you edit this question to create a new tag: "Brainfk"? ...
3
votes
2answers
61 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
74 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 ...
5
votes
1answer
33 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 ...
6
votes
1answer
2k views

Hello World in pdfLaTeX

After many years being silent, TeX can now talk! Almost minimal code below! It should be of particular interest to Physicists and Cosmologists. Need to have Adobe Reader installed. ...
3
votes
2answers
122 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: ...
23
votes
5answers
4k views

Repeat command n times?

Is it possible to define a command, which repeats the following command n-times? Call it for example \Repeat, then \Repeat[4] \command{...} should be equivalent to \command{...} \command{...} ...
4
votes
2answers
1k views

Figure environment not working with included file (extra } or forgotten endgroup)

I've spent hours on this issue. I hope someone can help me. I'm running into some kind of interference when I try to use the figure environment (Likewise for table, might be related to floats). I ...
1
vote
1answer
55 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 ...
20
votes
3answers
239 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} ...
1
vote
0answers
37 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, ...
6
votes
1answer
191 views

How to fix the error when importing EPS images with spaces in their path?

I am using Windows. The objective is to import all images in a sub directory. I divide into 2 categories, for PNG and EPS, separately as follows. For PNG This category works without problem. So you ...
4
votes
3answers
78 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 ...
8
votes
1answer
100 views

How to mimic LINQ's query method for macro's key-value?

Inspired by LINQ's query method, such as deck.Take(randomCount) .Where (card => card.Suit == "Hearts") .Skip(2) .Take(5) .OrderBy (card => card.FaceValue); The deck which is ...
2
votes
2answers
116 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 ...
12
votes
1answer
2k views

Note page showing the next frame

I would like to customise the note pages in Beamer to show: the current frame that they refer to with its number, the next frame of the presentation with its number, the section and subsection, the ...
4
votes
1answer
92 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
174 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
103 views

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

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 ...
20
votes
2answers
321 views

Embed TeX as a typesetting system for an eBook reading application

Are there any projects or information on how to use TeX to typeset texts for screen reading? That is, I want to get the beautiful output of TeX to render in a browser-like desktop application. I want ...
100
votes
3answers
13k views

Where do I start LaTeX programming?

I'm interested in writing packages for TeX/LaTeX/XeLaTeX. I googled around, but all I found was guides or tutorials about how to prepare documents using LaTeX. I want to know how LaTeX works and how ...
2
votes
1answer
353 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 ...
107
votes
5answers
9k 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). ...
5
votes
1answer
92 views

Partial expansion: macro arguments and nothing more

I am in search for a package that would allow me to do write a command of the following sort: \tofile{filename}{One}{Two} FROM HERE here is some nonsensical list of commands, ...
7
votes
4answers
267 views

Removing duplicates from a list

Is there a LaTeX kernel command to remove duplicates from a list? The list has the structure \def\alist{john,mary,george,australia,australia}
23
votes
3answers
470 views

How to compile the same input file for each of LaTeX font packages installed in our machine?

Inspired by my question How to create a PDF presentation for each available Beamer theme automatically?, now I want to compile my input file for each available LaTeX font package installed in my ...
1
vote
1answer
119 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 ...
7
votes
1answer
201 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 ...
6
votes
2answers
100 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
60 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: ...
22
votes
3answers
553 views

How to compute the remaining space on the current page

Is there a way to compute the remaining space on the current page and issue an optional command?
2
votes
1answer
77 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
207 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 ...
44
votes
0answers
858 views

Can TeX generate “heap dumps” to analyze+optimize out-of-memory situations?

As package author of the memory-extensive package pgfplots, I have been asked to analyze some out-of-memory situation. I could identify the "culprit"; it was some call to \pdfmdfivesum in which it ...
48
votes
10answers
5k views

What is the best way to learn TeX?

As opposed to LaTeX, which is addressed in another question. Most of the references I've seen get too complex too quickly. I'm looking for something that gives me a top-down view of the language - ...
4
votes
5answers
177 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
277 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 ...
5
votes
1answer
132 views

How can I use arara to get a graphics file?

In a standard TeX Live distribution Ghostscript is, to my knowledge, present; it is hidden, but it is there. Edit: Yes, it is under \Texlive\2013\tlpkg\tlgs So to my question: How can I use ...
5
votes
0answers
54 views

Good resources to understand how LaTeX is constructed layer after layer? [duplicate]

I have been a user of LaTeX for a couple of years now, and I would like to start to be involved in the writing packages. The problem is that currently, a lot of things appear to me as "black magic". ...
16
votes
6answers
473 views

How to automatically generate a stack diagram for a PostScript expression?

The following figure shows a PostScript expression and its stack diagrams step by step. Is there any package to generate it out of the box? If there is no such a package, how to generate it ...
5
votes
1answer
89 views

TikZ programming/macros, \list construct

TikZ 3.0 manual, on page 83, we have (not complete code): \list{--}{\topsep=2pt\itemsep=0pt\parsep=0pt \parskip=0pt\labelwidth=8pt\leftmargin=8pt \itemindent=0pt\labelsep=2pt} #5 ...
2
votes
0answers
34 views

How can I get a date object in LaTeX? [duplicate]

I want a date object I can just sprinkle throughout my document at any moment. For example, I might type "Today (\date) happens to be quite nice."
1
vote
0answers
167 views

Dynamic programming of cheapest cost in LaTeX

From How can I automate the generation of this dynamic-programming graph?, Jubobs helped develop a foreach scheme to draw the paths. I was wondering if LaTeX can find the cheapest path by ...
11
votes
2answers
769 views

Make an C programming language array in LaTeX

Im wondering if I can do some kind of table in LaTeX in order to show my C array nicely in text? I did something like this in KolourPaint: Tried to do the same with LaTeX tables, but with no ...
5
votes
1answer
70 views

Biblatex field values and comparisons

I would like to change the behavior of printing author names based on the hash field in biblatex. This mwe should demonstrate what I am having difficulty understanding. MWE: \documentclass{article} ...
4
votes
0answers
35 views

Is there a good reason to define helper macros second? [duplicate]

As a mathematician, my training is to define my terms before I use them. As a computer programmer, I recognize that there are sometimes good reasons to call a method/function/procedure before its full ...
5
votes
2answers
129 views

Boolean key value in xkeyval fails

It is possible to hand over a boolean key value stored in a macro to a command such as \edef\SomeKeyValue{true}% \DummyCommand[DummyBooleanKey=\SomeKeyValue]%%% where DummyBooleanKey is a boolean ...
5
votes
1answer
158 views

Tikz Procedure/Function like abstraction? [closed]

I am pretty new to tikz but, so I do understand the basics, however, I am truly confused on what's the best way to create a procedure like constructs: there seems to be so many mechanism, and I cannot ...
7
votes
1answer
111 views

Make the pattern of a \def depend on another macro

I would like to set up a macro defined something like this: \def\processline string: #1.#2\relax{\gdef\errorline{#1}} The catch is that the string should be given by the contents of another macro. ...
26
votes
2answers
834 views

Create a “List of Effective Pages”

I am considering learning Latex in order to more easily maintain a bunch of manuals for my company. One of the requirements is to have a "List of Effective Pages" towards the beginning of the ...