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

learn more… | top users | synonyms

5
votes
1answer
158 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
649 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
248 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 ...
2
votes
1answer
69 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
33 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 ...
13
votes
1answer
180 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
53 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
497 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
915 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
1k 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
86 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
121 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 ...
6
votes
2answers
305 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
137 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 ...
1
vote
2answers
150 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 ...
18
votes
2answers
315 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} ...
40
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
43 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
166 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
118 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
85 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
212 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
120 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
91 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
2k 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 ...
2
votes
1answer
169 views

Compare two comma separated lists

Hi I would like to compare two comma separated lists. \documentclass[a4paper]{article} \usepackage{comment} \usepackage{ifthen} \usepackage{xargs} \usepackage{xkeyval} \usepackage{xfor} ...
6
votes
3answers
336 views

How to use data structures in TikZ?

I created a foreach statement, using expl3 and TikZ/pgf: \documentclass{article} \usepackage{tikz} \setlength{\parindent}{0cm} \usepackage{expl3} \ExplSyntaxOn \cs_new:Npn \Counter #1 \Stopper { ...
9
votes
3answers
162 views

How to use \toks with \foreach

I would like to use \foreach to replace the next code : \def\x{0} \edef\y{\x} \xdef\z{(b\y)} \def\x{1} \edef\y{\x} \xdef\w{\z(b\y)} \def\x{2} \edef\y{\x} \xdef\z{\w(b\y)} ...
24
votes
1answer
393 views

Bad interaction between fontspec and some lua code that performs string-related search and replace operations

Update 2013/05/28: The selnolig package is now on the CTAN. Comments and critiques always welcome! If you wish to contact me about any aspects of the package, please use the email address that's given ...
11
votes
1answer
371 views

Using \toks registers

I was reading this tutorial for TeX programming: http://pgfplots.sourceforge.net/TeX-programming-notes.pdf recommended in the 2-nd answer here: Where do I start LaTeX programming? It says: ...
24
votes
0answers
397 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 ...
11
votes
1answer
172 views

Loading latex from tex

I decided venture into the very basics of the world of TeX and LaTeX. I have been playing around with tex, pdftex and latex and after paying close attention to the binaries and not being able to ...
3
votes
0answers
130 views

Optimizing tikz code for less redundancies [closed]

I don't use tikz very often. When I do, I'm usually pretty happy with the result (and with how useful that manual is). But I always think the code I produced to get there could be optimized, as in the ...
4
votes
1answer
254 views

Is it possible to make LaTeX read the sectioning in reverse direction?

I want to make a note (for internal use only) while I am reading a book. For the sake of convenience, I want to put a note about the current topic I am reading on the first page of the PDF output to ...
3
votes
1answer
50 views

How to select all occurrences of a specified word in a string and append another word to each of them?

When using infix-RPN package, we can use \infixtoRPN to convert infix expression to RPN expression. The output of the conversion can be retrieved by invoking \RPN. \infixtoRPN{cos(x)+sin(x)}, for ...
14
votes
2answers
323 views

LaTeX3: How to get reliable control over the level of expansion?

Say you want to write LaTeX3 code that manages user data. Sometimes you want to process that data, but other times you just want to store it, move it around and return it unchanged (when developing a ...
12
votes
3answers
240 views

Gobbling an argument if it starts with #

My problem comes from pandoc and markdown, but it is not directly related with these tools, but instead with "customizing" the resulting pdf via some tex macro programming, so I think it is on topic. ...
3
votes
2answers
202 views

Toggle visibility of solutions in LaTeX output for exams

So I have my own layout for my exams based on scrartcl and to prevent anomalies during some changes I want to have only one file per exam which holds both questions/excercises and solutions. Yet I ...
7
votes
2answers
215 views

How can I store variables in lists and make use of them?

This question is clearly related to How can I store variables and iterate over them?. I'm sorry to ask such a close one, but I really don't understand the answer in plain TeX by David Carlisle. ...
31
votes
2answers
1k views

What language is TeX implemented in?

I read on Wikipedia that the first version of TeX was written in SAIL. However, does anyone know what language later versions (i.e the current one) are implemented in?
7
votes
3answers
203 views

When to use or avoid grouping?

For writing my own TeX code, grouping (\begingroup, \endgroup) helps on automatically saving and restoring TeX "variables". (La)TeX "variables" are either macros or registers. The registers can ...
15
votes
2answers
208 views

Macro Improvements

I am looking to simplify and improve on the code below: \documentclass{article} \usepackage{filecontents} \begin{filecontents}{test.txt} a an and the this by on of \end{filecontents} ...
17
votes
2answers
294 views

Defining a dimension with or without @

If I am writing a TeX package (as one can find such on CTAN), there are following approaches to define a new dimension length that should be changeable by a user of that package. Approach A: Define ...
10
votes
2answers
188 views

How to make the last word in a sequence the first?

I am looking for a macro that would take a string (better to say -- a sequence of words) and output the last word at the fist place before remaning part of the sequence. I want to put this macro into ...
1
vote
0answers
143 views

Writing simple LaTeX workspace [closed]

I have this project in which I need to write something like a workspace for LaTeX. Basically I need to make split window. In one you would write the TeX code and in the other you would see the live ...
2
votes
0answers
62 views

How do I get my comma back (C++ lstlisting section) [duplicate]

Possible Duplicate: Comma inside \texttt{} does’nt show up I've been writing code in my book and just noticed that the comma has gone. I've been moving between machines so I don't know if ...
14
votes
2answers
262 views

Get number of elements in enumerate

Suppose, I have the following code: \documentclass{article} \begin{document} We have totally 7 columns, describing the user: \begin{enumerate} \item ID --- users.name \item Forename --- ...
1
vote
1answer
40 views

modifying PrintDescribeMacro of doc.sty

I would like to redefine the command PrintDescribeMacroof doc.sty in order to create a label that I can link to using hyperref. However whenever I add a label to the command I get an error ...
6
votes
1answer
284 views

Programming with pgf arrays : how to create an array?

I am trying to do some automatic drawing in tikz. The point is I want to be able to provide the minimal quantity of information to my macro, and still have it work. More precisely (but without ...
5
votes
2answers
132 views

How to write an environment wrapping document environment

I'm working on wrapping up some patterns used in my research group for creating posters. Since we're using beamer and beamerposter to make these, all documents go essentially like this: ...