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

learn more… | top users | synonyms

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 ...
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 ...
4
votes
2answers
267 views

Passing parameters to tikz picture?

I wrote a tikz diagram, which resides in its own dedicated file. I would like to include this file several times in my document, each time highlighting a different node in it. I tried defining a macro ...
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 ...
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 ...
0
votes
1answer
143 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 ...
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 ...
13
votes
1answer
289 views

Why does \numexpr integer division round rather than truncate?

In my use of \numexpr's integer division / I have never gotten any advantage from the fact that it rounds rather than truncates. TeX's own \divide truncates. If we were dealing with floating point ...
3
votes
2answers
143 views

Is there another way to avoid name clash in nested multido?

Constraints I want to use the same name for inner and outer loop. I am reluctant to append @ and make use of \makeatletter...\makeatother. Is there any name-spacing construct to use? MWE The ...
5
votes
2answers
128 views

How to buffer the extreme value of f(x) to draw a line representing a range of f(x)?

Please consider the following animation. \documentclass[pstricks,border=12pt]{standalone} \usepackage{pst-plot} \def\f{x^2-x-6} \psset{unit=3,algebraic} \def\Atom#1{% ...
4
votes
1answer
97 views

Why does \includegraphics[\varone]{\vartwo} not compile?

I want to convert each EPS image imported from within the input file to a PDF version and save it with its original name separately. The code below simulates the real condition in which we don't want ...
31
votes
3answers
1k views

Programming Conway's Game of Life in LaTeX

My aim is to program Conway's Game of Life in LaTeX, and make the output into an animated PDF. I intend to use PGF/TikZ for this, especially pgfmath, but I'm stuck at the moment because I need to ...
6
votes
2answers
80 views

Prime as an argument of command

Suppose we are in math-mode and I want to use command \E with the following behaviour. If one or two primes follow the command, i.e. \E' or \E'', then I want to have in these cases certain ...
7
votes
3answers
102 views

How to iterate through all user-defined control-words?

\documentclass[preview,border=12pt,varwidth]{standalone} \usepackage{pgffor} \def\Person#1{% \ifcsname#1\endcsname \else \expandafter\def\csname #1\endcsname{#1}% \fi ...
2
votes
1answer
98 views

Conditional assignment in a loop

Objective: I want to compile the temporary.tex file containing PSTricks code twice. One with -jobname=Rotated and the other one with -jobname=Unrotated. The resulting Rotated.ps will be passed to ...
7
votes
1answer
154 views

Macros with binary trees as arguments

I would like to have some macros which have binary trees as arguments. For the purpose of these macros, a binary tree is either root or it is {branch1}{branch2} for two binary trees branch1 and ...
5
votes
2answers
92 views

How to redeclare $$ or the \[, \] pair

There might be probably many reasons not to do it, but what would be the proper way to redeclare the $$ sequence or the \[,\] pair to open by default some special display math environment, such as ...
5
votes
1answer
89 views

Making uses of cleveref packages standalone

I have used cleveref package for referring to equations, figures, etc in an article. However, I wish to compile my tex file on another system which only has a basic version of tex. I wish to make my ...
1
vote
0answers
62 views

Programing in Latex, if and? [duplicate]

I know about \ifthenelse. Is it possible to programming in LaTeX like in C, with loops and arrays?
4
votes
0answers
3k views

Programmatically generating LaTeX with Python [closed]

I'm fairly new to LaTeX and I want to generate some reports using Python. Here is some code that creates a simple table. After coding this up I began to wonder if there isn't a better way to do ...
8
votes
3answers
210 views

Simple Key Events table

Consider the simple time-line table shown in the image below (extracted from a book). and the MWE below defining it as an environment, \documentclass[twocolumn,10pt]{article} ...
6
votes
2answers
446 views

How to code an auto-increment counter in LaTeX

When typesetting letters is common practice to have a reference such as: XXX-yl-0001 Where the last number is incremented for each successive letter. Normally, I hand-code the number. When ...
3
votes
1answer
80 views

How to begin a package (newbie style)

I am kinda new in LaTeX, but I'm trying to make a "package" to display abstract structs algorithms in beamer. Ex: \binarytree[]{a->b.c, c->e.f} and my plan is to make this visual algorithm to ...
2
votes
1answer
206 views

Hooking in before \documentclass

In the consequence of a previously asked question (Is it possible to hook in after options have been processed in a certain package or class?) I had the idea of a hook that adds code even before ...
3
votes
1answer
59 views

Is it possible to hook in after options have been processed in a certain package or class?

In other words: Is it possible to scan the input stream of a .sty or .cls file (without using Perl) for \ProcessOptions\relax and nest some given code afterwords? (The filehook or etoolbox package ...
5
votes
1answer
204 views

Special daily calendar for whole year needed

I need to print out a special daily calendar sheet for every day of 2014. The solution here: Page a day calendar problems no longer is available, the link to mattjy.me is dead. The whole daily sheet I ...
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 ...
2
votes
1answer
550 views

How to render LaTeX in programs?

Recently I'm writing a calc program, on android. As a frequent LaTeX user, it comes to be compelling to use LaTeX rendering in displaying the inputs and outputs. Is there any possibilities to use a ...
3
votes
1answer
86 views

Extracting commands from environment

In Automatic scaling of tikz images in floatrow I was asking how to scale several images in one row to the same height and to scale the resulting row to linewidth. I would like to automate the ...
1
vote
0answers
34 views

Is there a way to use a previous TikZ picture? [duplicate]

Let's say I spend some time drawing this picture: And after a few paragraphs I want to draw the same picture plus some "spices". Of course I could just copy-and-paste the code, then edit the few ...
14
votes
1answer
213 views

What practices are there regarding the use or avoidance of “internal” TeX or LaTeX commands?

What practices are there regarding the use or avoidance of "internal" TeX or LaTeX commands? (About "command" vs "macro", there is some discussion in this TeX.SX answer, though I don't know whether ...
2
votes
1answer
66 views

Conditional compilation failed

I think you can understand the scenario of the following code only by reading it. % compile with pdflatex -shell-escape \documentclass{article} \usepackage{filecontents} ...
21
votes
3answers
612 views

Best way to illustrate Keplers 2nd law with tikz

I am trying to visualize Keplers second law of planetary motion with tikz. I managed to do the following: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} ...
29
votes
1answer
2k views

How to generate “You can't use \unskip in vertical mode”?

We all know (or believe so) that \unskip is not possible in main vertical mode and this statement can be found in various answers on the site. And yes LaTeX does a lot of gymnastics in \addvspace or ...
30
votes
2answers
2k views

TeX assistance in writing hidden acrostics

Here's a fun challenge. Try to come up with (and code) techniques through which (La)TeX can help authors to incorporate acrostics in their writing. The definition from Wikipedia: An acrostic is a ...
8
votes
1answer
98 views

How do the \xx_case: functions work?

In the process of answering expl3 switch for booleans: Is there a \bool_case:Nnn?, I tried to make sense of the various \xx_case: functions Expl3 provides. Here, for example, is \tl_case:Npn: ...
2
votes
1answer
149 views

Shuffle numbers in a loop

I want to have a document, where the exact same page will be printed for a certain number of pages and on every page there should be a unique number. I know how to do so with a loop, but I don't ...
7
votes
2answers
514 views

Expand command read from file

I have a file, that contains a list of latex commands each command per line. Now I want to read this file line per line and execute/expand the macros automatically. I tried the following but this only ...
8
votes
2answers
167 views

Can I store sequences in sequences with expl3

The documentation for l3seq states LaTeX3 implements a “sequence” data type, which contain an ordered list of entries which may contain any balanced text . but for many programming tasks it ...
2
votes
2answers
204 views

How to apply a macro to each row of a table

This is similar to the question about cells, but with whole rows, and hopefully will help me to implement an answer to this question. Given a macro \RowMacro, how can I define the mytable environment ...
19
votes
2answers
339 views

Difficulty with macro expansion

I'm not getting the output I want from my LaTeX code, and I think the problem is that I'm not expanding things at the right times. Code \documentclass{article} \usepackage{tikz} ...
41
votes
5answers
2k views

How to print the permutation of {s,u,v,a,t} with LaTeX?

I want to use LaTeX to print the permutation of a set {s,u,v,a,t}. The output looks like the following. suvat suvta suavt suatv ... There are 120 rows in total that must be generated on the fly. ...
2
votes
0answers
47 views

How to throw an error and abort the compilation for the following scenario? [duplicate]

Objectives: I want to throw exceptions (or error messages) when the following illegal code is invoked. \const[c,any]{temp}{\f[\i]} \const[others]{temp}{\f[\i]} Minimal Working Example: I cannot ...
7
votes
2answers
191 views

How to parse optional arguments without keyval?

The current implementation only supports rounding with the specified digits in the optional arguments. \documentclass{beamer} \usepackage{multido} \usepackage{pstricks} \usepackage[nomessages]{fp} % ...
1
vote
1answer
133 views

What causes this error? [closed]

After seeing Herbert's answer, apparently this problem should not occur if I realized the first row of the following code should be \documentclass{beamer}. Problems often come from not knowing what I ...
4
votes
1answer
112 views

How to implement a constant declarating macro to behave differently in preamble and pspicture?

The example below is extremely trivial just to illustrate the problem in the simplest way. \documentclass{beamer} \usepackage[nomessages]{fp} % constants declarator \def\LoadConstants{}% to load ...
6
votes
2answers
256 views

How to make the following recursive macro work?

For positive values less than 3 the following MWE works. \documentclass[pstricks,border=12pt]{standalone} \SpecialCoor \psset{showpoints=true} \def\Triangle#1{% \ifnum#1=1\relax ...
4
votes
2answers
132 views

Can't generate a tikz matrix, using expl3

Suppose, I want to generate a matrix of nodes: \documentclass{article} \usepackage{expl3} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \matrix [ row ...
3
votes
1answer
117 views

How to use a macro inside \tl_set:Nx

This code works: \documentclass{article} \usepackage{expl3} \usepackage{color} \setlength\parindent{0pt} \begin{document} \ExplSyntaxOn \tl_new:N \_text \tl_set:Nn \text {1} \tl_set:Nx \text ...
19
votes
2answers
4k views

How to generate a table of trigonometric functions that can be broken across pages?

Consider the following screenshot. The features I want to have are: I can shrink the page size and the table is allowed to break across pages. The background of odd rows must be different from ...