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

learn more… | top users | synonyms

0
votes
1answer
27 views
+50

Automatically removing, after compilation, parts of text enclosed in certain strings

Is it possible to create a macro, such that everything that is between the string composed of the characters "whitespace", "{", "L" and the string composed of "L", "]", "whitespace" is not displayed, ...
6
votes
5answers
296 views

How can I draw several polygons on the same base line using TikZ?

I want to construct a figure that will be symmetrical polygons on the same base. So, there is an equilateral triangle, a square, a pentagon, a hexagon, etc. one side of all these is the same ...
3
votes
0answers
23 views

Can I force a pre-process action on all commands or environments without having to redefine them all manually?

I am trying to preserve a history of the latex commands and environment initializations I use in a typeset html or pdf file. Is there a way where I can force a pre-process action on all commands ...
3
votes
1answer
37 views

How to randomize comma separated rows to create word arrangement puzzles?

I have an external file named input.txt consisting of comma separated rows as follows. NOTE: The rows may contain Japanese characters as well. i, love, LaTeX, very, much i, am, a, student I want to ...
1
vote
1answer
57 views

Would it be possible to embed the lambda calculus in TeX?

I understand that TeX is Turing-complete. I'm just curious: would it be possible to embed the lambda calculus in TeX using TeX macros to fulfill beta-reduction?
1
vote
0answers
78 views

Is there any programming language similar to TeX? [closed]

I know nothing about programming, so TeXMaker's pseudo-WYSIWYG reminded me of a stereotypical programmer.
1
vote
1answer
58 views

Error when compiling using tikzmath

I am trying to learn how to use Tikz and its library Tikzmath to make graphics. I am trying to practice by drawing a series of circles along a line. My code is as follows: ...
4
votes
3answers
50 views

\forlistloop of etoolbox reference requested

I am having a problem of using the command of \forlistloop of etoolbox unlike the way of typical C program where int a[5] for ( i = 0; i <5; i++) { a[i] } one could access i I am not sure ...
15
votes
6answers
861 views

Loop within another loop in LaTeX

I am trying to create a loop within another loop using some of the constructs in etoolbox but I am not sure how to create that. I want to get the output like in C. pseudo code for (i in the list) { ...
2
votes
2answers
64 views

list environment where some items don't start new paragraph

I want to use a list-like environment, but I need to put some short items on the same line. The user interface will be something like: \begin{enumerate} \item First very long element \item* shrot ...
1
vote
1answer
24 views

Generating array with arrayjob and store values for further analysis

In a two-dimensional array I want to store some calculated values. However, for example for a 2 on 2 matrix I get identical values for [1,2] and [2,1]. What am I am doing wrong? ...
4
votes
3answers
200 views

Sorting according to absolute page height from pdf extensions

I'm unsure how to present the question, so I'll just go with something and edit if it is deemed necessary. The PDF extensions currently extend the basic TeX macros with at least the following three ...
4
votes
1answer
185 views

Calculate the hash (MD5 or otherwise) of a string

I'm trying to cache the results of a macro, similar to that question, but the argument of the macro can contain arbitrary characters and it's not suitable to be inside \csname ... \endcsname. So, I'm ...
2
votes
1answer
23 views

How can I include external macros for every line of the source code?

An answer to my last question gave a solution for hooking a small command onto line breaks in the TeX source. \documentclass{memoir} \usepackage[spacing, tracking]{microtype} \usepackage{libertine} ...
2
votes
1answer
71 views

Is there a formal grammar for *Equations* in TeX/LaTeX?

I've looked at this and this and understand there is no grammar of TeX as a whole. I am wondering if there is a grammar just for equations. They are relatively easy to identify in an amsmath file ...
13
votes
3answers
1k views

Hooking every line of the source code

I've been considering a more radical solution to the problem k.t.hagen posed a while back. Would it be possible (perhaps by catcode hijacking) to put hooks on individual lines of the source code? ...
3
votes
3answers
168 views

How to divide two values in LaTex [duplicate]

I need to divide two values in LaTex, \newcommand{\x}{30} \newcommand{\y}{10} Is there a simple way to do this? i.e x / y = 3 Preferably not using external packages, or a long winded ...
1
vote
3answers
154 views

How to inject a color into boxed objects?

Consider the following MWE. I want to give a color (red) to the boxed object (Hello). Unfortunately, it does not work as expected as if the boxed objects are shielded. How to remove such a shield? ...
2
votes
1answer
108 views

Perl, Python, Lua or just Latex/Xetex [closed]

Recently I finished my thesis in LyX and this was my first steps into latex (even indirect steps). Even though LyX does a lot of thing automatically, when you want to do something yourself, then ...
3
votes
1answer
62 views

Is there any method available to automatically show the ruby when writing sentences with Japanese Kanji?

I want to write a note for my study on Japanese Language with LaTeX. So far I have to write the ruby (furigana) for each Kanji manually such as \ruby{天}{てん}. It seems to be tedious and makes my input ...
4
votes
2answers
129 views

Count number of elements in a list

This question is somewhat similar to Count the number of elements of each size in a list. It should actually be simpler but I nevertheless can't figure out how to do it without using the same code as ...
7
votes
0answers
69 views

Table of contents with xtemplate (expl3)

Every time I typeset some book or articles, I start to renew sectioning commands (\part, \section, some \@-commands and so on), \maketitle, \tableofcontents commands by copy-pasting it to my class and ...
5
votes
1answer
68 views

Text formating depending on conditions

I have some conditions which are stored in boolean variables, such as \bool_new:N \l_word_numbered_bool \bool_new:N \l_word_lowercase_bool \bool_new:N \l_word_centering_bool I need to format words ...
0
votes
0answers
100 views

Are there any tools for Image -> LaTeX?

Are there any existing tools which take as input: TypeSet Math Formula output: LaTeX code which produces something similar to the existing math formula? Googling "inverse LaTex" gets answers about ...
2
votes
2answers
54 views

Being able to define headers by hand in each part/chapter of a book

Consider the following code inspired from egreg's answer to this topic: \documentclass[11pt,a4paper]{book} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[french]{babel} ...
1
vote
0answers
55 views

How to Extract Elements?

I could not find the right answer on the following question: If we have finite vector (a_{1},a_{2},...,a_{n}), how to extract any element from it, for example a_{5}? To say more clearly, I need an ...
0
votes
1answer
77 views

How to use Programming possibilities of LaTeX [closed]

How do \newcommand, \newcommand*, \renewcommand, \renewcommand*, \newenvironment, \newenvironment*, \renewenvironment, \newenvironment* work and what is difference between them?
1
vote
0answers
30 views

How may I program the following with Python? [closed]

please help me do the following with python create a directory - say - dir_01. open a file - say - file_01 and write "hello - 01" into that file and close the file. run the command (on a Linux ...
8
votes
5answers
357 views

A more elegant version of the \ifnot macro

A TUGboat article of 15 years ago mentions an \ifnot macro by David Kastrup whose implementation is: \def\ifnot#1{#1\else \expandafter\expandafter\fi \iffalse\iftrue\fi} However, this macro ...
4
votes
1answer
76 views

Extract the last word from a sentence stored in a variable

I want to extract the last word of a sentence stored in a variable, e.g. \thevariable. Here is the minimal example. \documentclass{article} % Function to extract the last word of a sentence ...
5
votes
2answers
64 views

How to determine if a macro argument contains the macro itself?

I would like to have a way to detect if a particular macro's argument contains that particular macro itself. Consider the following MNWE: \documentclass{article} \usepackage{etoolbox} ...
0
votes
1answer
28 views

Names on certificates [duplicate]

I have to make some certificates. The main problem is not the certificate itself but to change names between pages. Can I create a list of names, each of appears once for page?
3
votes
3answers
75 views

Find the number of elements in a list that occurs most often

First: This is similar to "Count the number of elements of each size in a list" and "Position of largest element in a list" but it's not the same. Code + question: \documentclass{beamer} ...
3
votes
2answers
128 views

Count the number of elements of each size in a list

Comment: The following question is somewhat similar to "Position of largest element in a list" but I'm (unfortunately) not familiar what LaTeX 3 programming so I'm forced to ask. :( Code: Consider ...
6
votes
2answers
191 views

How can I use a list stored in aux and insert its output into a tikz node?

# Update 2015-03-19 Better Answer Found This question is part of a trail of questions. The goal mine was to use this list inside of a tikz node, but I removed that from previous questions in the ...
2
votes
1answer
97 views

The text instead of chapter number

I just get some code from Pretty Table of Contents and modify it for my purpose)). But I need some variable text parameter or command for using instead of chapter number in the Table of Contents. ...
12
votes
3answers
420 views

Position of largest element in a list

Consider the following: \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff \def\valueA{7} \def\valueB{19} \def\valueC{41} \def\valueD{31} ...
3
votes
2answers
192 views

How can I loop thru a list of inputs that come after \maketitle, yet use that list as part of the \maketitle command?

Multilingual Document Question I would like to follow the principle of "don't repeat yourself" and create a single list of inputs, which are actually various versions of the same document in ...
3
votes
3answers
202 views

How can I create a list as a variable that can be appended and eventually typeset?

Question In languages such as Python, you can define a list like so: example_list = ['apples'] I can append this list like so: example_list.append('oranges') I can print this list using print ...
6
votes
2answers
100 views

Iterator-like command, where each use expands to an item from list defined earlier

What is the simplest way to create an iterator-like macro (in the functional programming sense) in pdfLaTeX? I'd like to predefine a list of elements (to simplify we can assume that it is plain ...
1
vote
0answers
91 views

What is the core of TeX as a programming language? [closed]

Tex (and LaTeX) mix programming elements with typesetting ones. It's often confusing to a beginner to tell them apart. Could anyone show me a list of the very core commands of TeX (and perhaps LaTeX) ...
1
vote
1answer
59 views

How does one create a counted command (e.g. TODO) for use in a list?

Pretext: I am aware of packages such as todonotes, todo, and fixme, but this is more of a task for learning LaTeX programming. Therefore, the use of additional packages downloaded from CTAN is ...
0
votes
0answers
59 views

Command showing note page of the next frame

This question is based when I read the answer of... Note page showing the next frame I was wondering if it is possible just to define a command like \insertslideintonotes{<scale>} which then ...
5
votes
1answer
49 views

How to deduplicate and sort a list of \pagerefs?

I have a document comprised of three large, multi-page tables, all of which have links to items in a list of figures at the end. By generating md5 labels when I generate the latex for the tables, I ...
4
votes
2answers
78 views

Change location of increasing text length

I have a very specific question and I hope someone can give me the benefit of their experience. I have around 17000 lines of text. I am printing this text onto somewhere around 80 double sided pages, ...
3
votes
2answers
195 views

Deleting duplicates from a comma-separated list of strings

This is a followup to Difference in compilation time between two slightly different versions. As became obvious when asking that question, the speed of that compilation is seriously affected by the ...
6
votes
2answers
292 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
75 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
377 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
86 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 ...