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

learn more… | top users | synonyms

0
votes
0answers
60 views

Can you feel the ink on your paper?

While thinking on the question How to flip certain pixels of a QR code? I came up with ideas which would require to test the following: is_something_already_in_my_document_at_position(x,y) which ...
2
votes
1answer
177 views

How to remove LaTeX control sequences from a .tex document using plasTeX?

I need to get just the text and math expressions (ignoring tables, pictures and styling) from a set of LaTeX documents and represent them in html. Looks like plasTeX and MathJaX are enough for this ...
2
votes
1answer
26 views

Test if package with given options can be loaded

I need to introduce in my preamble a conditional structure to load a package if its complete version is installed, load its light version if it exists, or load some standard package otherwise. The ...
5
votes
5answers
149 views

How to write macro with variable amount of text variables

I am trying to make a signature block macro that accepts a variable number of text variables so that I can add or subtract the text without using empty fields "{}" as arguments. ...
1
vote
1answer
39 views

Calculating descriptive statistics

I'm writing a paper that involves many values. In order to be consistent in all the papers, I'm using \def and xint to assign and calculate these values. However, in part of this paper I have to ...
7
votes
2answers
59 views

How to handle syntax errors in a macro?

I would to indicate in the log file that if I use () instead of {} in the line \macro[red,circle]{2/3/a,4/4/b,5/0/c}, an error occurs . What is the best way to do this ? \documentclass{article} ...
14
votes
2answers
346 views

Is there any reason not to use \let to redefine a deprecated control sequence to the currently recommended one?

I understand that \bf and \it are both deprecated in the current version of LaTeX. To the best of my knowledge, the correct control sequences replacing them are \bfseries and \itshape. Is there any ...
3
votes
3answers
45 views

error when using \num command from siunitx package with an array from arrayjob package

I want to use the command \num from the siunitx package with some numerical data stored in an array data structure of the arrayjob package but I get an error message that I understand but I can't ...
12
votes
4answers
418 views

High-order recursive macro to define several similar macro at once does infinite loop

I’m a fan of factorization and hate code repetition. So I was trying to define a macro which defines for me all the common mathematical sets commands (\C, \N, etc.) and made a recursive function ...
7
votes
2answers
108 views

Problem between pgfkeys, tikz and personal macro

The following minimal working example shows the problem. The mainmacro is an example of what I need; here I want to use my keys and keys from tikz (like draw,color,shape). The result is fine only if I ...
12
votes
3answers
210 views

Cyclic permutation of arguments / list of arguments

I work on a triangle ABC and I would like a macro to define IJK the centroid triangle ( I, J and K are the midpoints of the segments BC, AC and AB). The problem is not to get these points but "how" to ...
1
vote
0answers
28 views

Embedding Cmx.io code in LaTex?

This may seem a bit silly, but here goes. There's a project called Cmx.io that allows you to create xkcd-style comics using an HTML markup. I wanted to include comics like these in a book I am ...
2
votes
0answers
62 views

Using For loop in latex to input multiple files in different directories

\documentclass{minimal} \usepackage{chngcntr} \usepackage{pgffor} \newcounter{question} \newcounter{answer} \setcounter{question}{0} \setcounter{answer}{0} \newcommand\Que[1]{ ...
29
votes
8answers
7k 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{...} ...
3
votes
1answer
47 views

How to use active characters to create hyperlinks with hyperref inside a PDF?

I want to create links inside a pdf and actually I use \hypertarget{label}{target caption} and \hyperlink{label}{link caption} with the package hyperref. Perhaps it's possible to use something like ...
2
votes
0answers
41 views

Figure/animation creation in LaTeX [closed]

What is one of the most complex/difficult figures that was created entirely in LaTeX? Is it possible to draw the globe figure that one can see here on TEX in the background just above the "Ask ...
10
votes
1answer
292 views

querying whether a font feature has been activated via a fontspec command

A LaTeX package I'm currently writing makes use of -- and definitely requires -- some of the power of LuaLaTeX. I would like to make my package's user interface -- in particular, the options that need ...
5
votes
2answers
79 views

Using multline or equation based on a boolean flag

I am trying to define a new environment myeq which can either be an equation or a multline. My use case is that in the preamble, I will define myeq to be either replicate the functionaly of equation ...
10
votes
1answer
104 views

How to get around a problem with \usetikzlibrary{babel}?

I am currently working on an update of tkz-euclide and new documentation but I just met the following problem. If I compile this code with pdflatex or lualatex and pgf 2.1 (The library babel does not ...
2
votes
0answers
57 views

search for and highlight words/numbers in pdfpages while only printing highlighted pages

I have a project where it would be very helpful to be able to include pdf pages with certain text and or number highlighted, and in addition limit the pages output to those which have the highlighted ...
0
votes
0answers
55 views

What language is TeXLive written in? [duplicate]

I read that TeX was written in SAIL and re-writen in Pascal. Do we still use that version today? In my Linux distribution, I use TeX-Live. Does that also use the Pascal version? Wikipedia says the ...
2
votes
2answers
93 views

How to append data to a global string variable?

Here is a minimal non-working example: \documentclass{article} \begin{document} \let\@var\@empty \newcommand{\append}[1]{ \xdef\@var{\@var #1} } \append{1} \append{2} \append{3} \@var ...
22
votes
3answers
400 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
3answers
731 views

\rand inside \forloop creates identical values

I try to create a table with random entries... By browsing the random tag, I found some help on random number generators and I tried using lcg. Surprisingly I seem to create the same random number ...
2
votes
1answer
35 views

Doing case analysis on an argument of a macro

Background: As has been discussed here, there appears to be no widely accepted typographical standard for logical quantifiers. To address this I defined in my paper the following macro: ...
2
votes
1answer
98 views

Need help with macro-driven tables and expantion

This is a project I have been working on for a while now and I am stuck on implementing this new function, cell coloring. My function works by taking in an unknown amount of data called 'weapons' and ...
3
votes
2answers
40 views

How to process only tokens containing a lower case letter?

The goal is to have a macro with single argument, that looks at all tokens in turn and if it sees a lower-case letter it is wrapped in \texttt{<token>}. All other tokens are passed through ...
4
votes
1answer
122 views

How to make a list of environments?

I know that LaTeX/TeX is a complete programming language, but I can not find any topic about making list or vectors, as it is in C# or C++. My goal is to make a list, where I store names of my ...
17
votes
1answer
6k views

How do you say Happy New Year with LaTeX?

Title says it all. How do you wish "Happy New Year" to a TeXie? Compile the code below with pdfLaTeX, view it with "PDF Reader" or "Adobe Acrobat Pro" and press the "Happy New Year" button on the ...
5
votes
2answers
2k views

How can one get a list of the available functions in Lua(La)TeX

Is there a list or method to determine a list of the lua functions available/installed? Sofar I could only find the lua source files. Maybe I should write something that search through all the ...
11
votes
2answers
245 views

Extract source code on the fly to a file?

I'm trying to create a programming text to use for my students. My goal is to have an environment (say, "code", for instance), so, if I type the following in my .tex file: \begin{code}{Sample script} ...
6
votes
2answers
93 views

How to perform lexicographic sort on list of coordinates in LaTeX?

I need to sort a list of TikZ coordinates, first by increasing X coordinate and then by increasing Y coordinate. At the moment I do this by invoking an external Python shell, but it would be nicer to ...
4
votes
1answer
66 views

How to prevent XeLaTeX from dynamically enlarging or shrinking space after comma?

See the following output. Question How to prevent XeLaTeX from dynamically enlarging or shrinking space after comma? force XeLaTeX to break long sentences automatically without having to ...
2
votes
1answer
77 views

Is there a way to have xesearch search and replace a term and have the replacement compiled as LaTeX command?

I have used the package xesearch https://www.ctan.org/pkg/xesearch?lang=en xesearch in my header to automatically replace shorthand notations: \usepackage{xesearch} \SearchList{list1}{Very Long ...
2
votes
1answer
59 views

My \Render that attempts to iterate a list and invoke macros dynamically produces errors

My \Render that attempts to iterate a list and invoke macros dynamically produces errors. The given MWE with detailed comments tells what my objective is. How to fix it? I have no more idea how to fix ...
1
vote
1answer
44 views

How to iterate a list and do something for each element? [duplicate]

For an illustration, see the following MWE. MWE \documentclass{article} \usepackage{etoolbox} \newcommand\Push[1]{\gappto\Array{#1}} \newcommand\NewItem[2]{% ...
0
votes
2answers
19 views

How to dynamically create, set, and use conditional?

It is better if I give an illustration as follows. A statically created and invoked macro \newcommand{\mymacro}{test} \mymacro A dynamically created and invoked macro \expandafter\csname ...
1
vote
2answers
39 views

How to create a dynamically created macro with optional argument?

The following MWE does not compile (unfortunately). The objective is to create a dynamically created macro, for example, \Newton with an optional argument. If \Newton is invoked, $F=ma$ will be ...
1
vote
0answers
259 views

LaTeX for automatic report generation

I accept that this question might be a bit outside the scope of this page, but please bear with me! At work I'm going to set up a framework for generating some pretty basic reports, which could be on ...
3
votes
1answer
61 views

What makes my array-like macro get contaminated

The following MWE is the simplified version of my project. \CreateMacro is used to create macros representing vocabularies. For example, \CreateMacro{Newton}{$F=ma$} creates \Newton with body $F=ma$. ...
1
vote
3answers
74 views

Insertion fails when invoked in \chapter

Here is the simplified version of my project. I have a macro named \CreateMacro which takes 2 inputs, i.e., the macro name to create and its body. For example, invoking \CreateMacro{Newton}{$F=ma$.} ...
0
votes
0answers
44 views

Why this fatal error occurs? (trying to align a text in tikzpicture) [duplicate]

I would like to print a code in my document in the format that is very common to see online in many websites like this: But when I try to compile, a fatal error occurs. The problem is in the ...
10
votes
2answers
144 views

Ignore expansion in edef

I would like to populate a tabular environment programmatically using an edef. For simplicity, I brought a simple example: \let\\=\relax \let\hline=\relax \edef\mmm{\hline A & B\\} ...
25
votes
4answers
476 views

Expandable (quick) sort array macro?

I'm trying to implement a (quick) sort algorithm. Here is what I can do : \documentclass[preview, border=7mm]{standalone} \usepackage{pgffor} % \push{xs}{\i} add \i in the array \xs ...
4
votes
1answer
142 views

is it possible to write a function ( programming language) with latex

I am writing out equations and a lot of my equations have parameters changed but the basic structure is repeated. I have reduced the problem to a hypothetical example as follows. if (condition ==2) ...
2
votes
1answer
20 views

How to define global macros on the fly across multiple enumerate environments?

I want to create macros defined right after \item of enumerate environment. Those macros must be global in such a way that redefining the same macros in another enumerate must produce error. I failed ...
0
votes
1answer
215 views

Document management system [closed]

Is there any free / open source DMS for latex documents , which is simple to install and manage, not bulky (enterprize grade), help search the document and has revision control if possible? (I've ...
132
votes
4answers
19k 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 ...
5
votes
0answers
72 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". ...
1
vote
1answer
65 views

Read a text file by delimiter not by line break

I would like to populate a table, which I created in my LaTeX document, using iterating over cells of a text file. In order to read the text file I use this code. \newread\data \openin\data = data ...