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

learn more… | top users | synonyms

4
votes
2answers
148 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
52 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
342 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
40 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
106 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
40 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
82 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
85 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
39 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 ...
4
votes
0answers
142 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
69 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
85 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
38 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
130 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
58 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
52 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, ...
20
votes
3answers
247 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
82 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
103 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
182 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
121 views

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

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
122 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
128 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
114 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
65 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
202 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
79 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
213 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
692 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
182 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
281 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
55 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". ...
5
votes
1answer
101 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
179 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 ...
20
votes
2answers
328 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 ...
11
votes
2answers
779 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
78 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
36 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 ...
7
votes
1answer
115 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. ...
7
votes
1answer
100 views

Include ALL pdf graphics in document

I have several plots saved as .pdf in a folder and I would like to know if there is a way of adding all of them in a document at once, without typing the path to each file.
7
votes
2answers
101 views

Break line within a macro while writing to a file

I am trying to use (La)TeX as a macro pre-processor for a programming language. My idea is to use the VerbatimOut environment from the fancyvrb package to output essentially verbatim text, but using @ ...
12
votes
4answers
480 views

Condition within condition

Consider the following logical satatements: If \conditionA != 100 and \conditionB != 100 do ``Something~A'' If \conditionA != 100 and \conditionB = 100 do ``Something~B'' If \conditionA = 100 and ...
17
votes
6answers
490 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 ...
7
votes
2answers
287 views

What are other programming languages with APIs for drawing graphs?

My apologies if this is not the right place to ask this question. If so, I would appreciate it if it could be told to me where I should post it instead. Recently I came across a question which I ...
6
votes
1answer
383 views

How to write a bounding box information in PostScript to an external file and read it in TeX at the second compilation?

Scenario I want to create a new environment, e.g., pscanvas that does not need any size specification but just a unique filename. It can contain any graphic objects that pspicture can contain. Thus ...
5
votes
1answer
396 views

Creating a simple list of symbols

Inspired by this great answer I tried to manually create a glossary-style environment for a simple list of symbols. Basically I wanted to create a command newsymbol that can be executed from anywhere ...
0
votes
0answers
88 views

Software/Programm: latex-based math trainer

I need some help, because I searched the internet for quite a long time, but I wasn't successfull in getting a solution: I'm looking for a program/software, which helps me to practice math, which is ...
10
votes
0answers
103 views

create list of thumbnails for each section [closed]

I want to create a cooking book. There I want to define for each receipe a thumbnail image. At the beginning of each chapter I want to show instead of a TOC a gallery of thumbnails of each subsection ...