{recursion} is the self-referral operation such that particular steps in a program depend on solutions to instances of the same program (as opposed to iteration).

learn more… | top users | synonyms

40
votes
5answers
2k views

Amusing exercise - ouroboros file - Output of TeX includes itself recursively ad infinitum

Clarification: The question may be related to the the quine fun question, but IMHO it is quite distinct. The question here to write an "ouroboros" in TeX, i.e., a file that includes itself as a ...
0
votes
1answer
38 views

Compilation of several projects at once

I search a way to (re)compile several different projects at once (all assumed to be compile individually without error). Here, I present the context and the problem. The context: I have a topic, ...
4
votes
2answers
56 views

Plotting a recursive defined set of functions with conditional base function

I'm trying to visualize the construction of B-Spline functions by showing step by step how the curve is created. This involves painting curves similar to these: The function that creates the curve, ...
15
votes
3answers
641 views

Recursive Stern-Brocot tree definition

I am trying to build a Stern-Brocot tree (enumeration of rationals). The result is nearly acceptable, but I am still dissatisfied with the following points. The edge from the parents goes to the ...
12
votes
4answers
425 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 ...
8
votes
2answers
262 views

Recursive use of \renewcommand: How to make it work?

I am trying to define a command that is able to store the content of a section and accumulate it as new sections are created. My current attempt is the following: \documentclass{article} ...
8
votes
2answers
137 views

Building table dynamically with `\edef`, `\noexpand` or whatever

Consider the following table: \begin{tabular}{ll} a & A\\ b & B\\ c & C\\ \end{tabular} I would like to define commands \addtableline{...}{...} and \printtable in order to build this ...
0
votes
1answer
69 views

Passing arguments to latex file

I have a pgfplots main.tex file which plots a graph from an input file. I would like to run it on 100 input files and automate creating 100 PDF pictures. How can I do that? The files are named as ...
1
vote
1answer
40 views

Recursive Itemization Macro Output & \@ifnextchar Weirdness

I'm encountering some rather unusual behavior from a macro I've defined. The specific goal of this macro, ultimately, is to set up something easy to call that produces itemized lists to my liking ...
4
votes
1answer
75 views

Creating a Droste Effect

Is there any way to achieve a Droste effect in LaTeX? For instance, I'd like to generate a floating figure that contains a rendering of the page it is included in.
6
votes
3answers
270 views

How do I make a list of items in Latex using recursion

I was trying to use recursion in LaTeX to create a list of items. I don't have much experience with LaTeX so kindly explain any uncommon commands used. Here's my code for the same. \makeatletter ...
5
votes
2answers
76 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} ...
4
votes
4answers
129 views

Recursive String Parsing

I have been working on writing a recursive stream processor in latex that converts a shorthand version of a set of highly used commands into a much longer form. The code below represents what I had ...
1
vote
1answer
121 views

cryptic plain TeX: Twelve days of Christmas

Many years ago, probably in TUGboat, I saw a shortish piece of \TeX\ that immediately deploys catcodes and very quickly becomes completely unreadable, but when typeset produces the old "twelve days ...
5
votes
3answers
154 views

using a macro to define the body of a tabular / & separator problem

I'd like to create a macro that can create and fill a multiline tabular with 4 entries per line from something like \bidding{3H,4S,5C,X,XX,-} where the number of entries is of course dynamic. I have ...
2
votes
0answers
117 views

How to use sed to comment some lines in tex files (has “%” a particular meaning for sed ?)

I've been reading something in Most useful sed one-liners for TeX users which is related to my problem, but albeit interesting, it is not what I need. I have many tex (beamer class) files in ...
25
votes
5answers
2k views

TikZ - Recursive Arc Drawing

I'm trying to make Farey diagrams similar to those seen here (click) or the screenshot as follows, Namely, I'd like an example of the one seen on the top of page 6. From there I hope I can figure ...
9
votes
2answers
272 views

recursive multiple subscript and superscript with xparse

How can I define a new command with xparse, something like this: \NewDocumentCommand\tensorkor{ m >{\SplitList{,}}o >{\SplitList{,}}o } { ????? } that i can execute $ ...
4
votes
0answers
296 views

How to draw this 3D H-layout recursive tree with Tikz? [closed]

Background: This is an extension problem from my last post How to draw the recursive H-Layout tree using Tikz?. The (2D) H-layout tree is actually from the VLSI layout problem in computer science. I ...
11
votes
2answers
521 views

How to draw the recursive H-Layout tree using Tikz?

The following image shows a recursive H-Layout tree. It is called H-Layout because of its H unit consisting of 7 nodes. My problem is: How to draw such tree in a recursive manner instead of ...
7
votes
1answer
179 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 ...
12
votes
4answers
1k views

Thumbnails of other frames in beamer

I would like to make a presentation with beamer, and have a few frames (at the start or the end) containing thumbnails of the other frames, hyperlinked to them, with something like 4x3 or 5x4 ...
4
votes
4answers
714 views

Recursive drawing, command flow

I am trying to recursively draw Ck x Ck, where Ck is the k-th iteration of a Cantor set. I have a command which recursively calls itself four times. If I pass N as parameter #6, the output ...
2
votes
1answer
203 views

Modifying \title without recursion problem

EDIT: Much shorter problem definition Having defined a title by \title[short]{long} how can I later add something to the title? The simple assumption \title[\insertshorttitle]{\inserttitle plus ...
4
votes
1answer
149 views

Stack overflow / endless recursion when using menukeys

since I've upgraded from TeX Live 2012 to TeX Live 2013, I have some trouble with a custom package. The package provides some commands that are intended to be used either as standalone commands or ...
8
votes
1answer
119 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: ...
11
votes
3answers
6k views

Commands that may take a variable number of arguments

I have a situation where I want to define a command that takes a variable number of arguments, where the number of arguments is known programmatically via a \count, and process the parameters in some ...
3
votes
1answer
131 views

Recursive Multiple subscripts and superscripts with xparse (Modified Version)

How can I modify the command below to obtain a version (of the question: recursive multiple subscript and superscript with xparse) which does not stack the sub/superscripts horizontally but moves all ...
8
votes
2answers
566 views

Drawing iterations of a recursive structure in TikZ / using node names defined in a loop

This is my first time using TikZ, and I'm trying to draw something related to the Hilbert space-filling curve, based on a recent popular article (HTML, PDF). Specifically, I'm trying to draw the first ...
7
votes
2answers
243 views

Making a lattice with numbers on vertices

Anyone who is familiar with the problem of counting up/right going paths in a rectangle from bottom left corner to upper right corner knows that one way of doing this is doing it by recursion. I want ...
50
votes
5answers
3k views

Self-replicating (La)TeX document

Since TeX and LaTeX can print out any text, it should be possible to write a self-replicating document, i.e., a document that is typeset as a PDF/DVI of itself. Have you seen something like that?
11
votes
4answers
1k views

How to make a recursive Latex macro with comma separated argument list

I would like to make a macro that takes two arguments, the second of which is a comma separated list and then produces a nested commutator of argument1 with each entry of argument2. I've been ...
5
votes
1answer
507 views

How to configure latexmk to work recursively? (PDF Thumbnails)

I'm writing a book which will include and explain a handful of different memoir page layouts. Setting the scene In the book, I want to imbed thumbnails of pages from PDFs generated with the page ...
8
votes
5answers
449 views

Define a command (possibly recursively) to wrap text in a command n times

I'm trying to define a new command \multiboxed in LaTeX so that I can put n boxes around an equation without having to manually nest \boxed commands. So far I have (using the pgffor package): ...
5
votes
2answers
941 views

Recursively defined macros in TeX

After receiving a nice answer to a previous question, I got enthousiastic and tried to create a macro \sum such that \sum<1+2+3> would be expanded into 6. My idea was to work recursively, using ...
6
votes
2answers
371 views

How can I define a macro that adds a row to a table that has not yet been printed?

I want to generate a list of technical abbreviations and acronyms that I use. Currently, I'm defining all acronyms with a macro I have designed. Now, I want the macro to call another macro, called ...
0
votes
2answers
90 views

How do I add a static number to \recurselevel?

I currently have: \dorecurse{8}{ \startcombination[3*3] {\externalfigure[confcard.pdf][page=\recurselevel, width=98mm]}} {\externalfigure[confcard.pdf][page=\recurselevel+2, width=98mm]}{} ...
3
votes
2answers
695 views

How to make a recursive macro in (La)TeX?

The following MWE is the code of my attempt translating my working algorithm in C# to (La)TeX. I don't understand why it does not work. Can you probe the source of problem? Remarks: #1 is a list of ...
3
votes
1answer
241 views

Recursion - splitting a group.

I've been trying to understand the notion of recursion in TeX - not easy given that my background is the high-level stuff in LaTeX. The only examples I can (just about) understand are very basic ...
6
votes
1answer
8k views

Recursive algorithms with the »algorithms« package?

I need to write a recursive algorithm, using the algorithms package. I thought of writing something like this: \begin{algorithmic} \IF {$x=1} \RETURN 1 \ELSE \RETURN recurse$(x-1)$ \ENDIF ...
7
votes
3answers
494 views

Strange recursive macro output

Strange recursive macro output The code that follows describes a macro that can iterate recursively (i.e, a forloop) and uses e-TeX numexpr. It is based on an example found in the e-TeX manual (page ...