{loops} is about looping constructs which allow a programmer to apply the same operation multiple times, each time with possibly different parameters.

learn more… | top users | synonyms (1)

2
votes
1answer
84 views

LaTeX: Different spaces when using readarray, whiledo and value

The answer of the following problem is given in Ulrikes Comment. Thank you very much! I am trying to use external data for similar documents I have to write. The number of these data varies so I ...
3
votes
1answer
104 views

Looping over elements to change font in math mode

I have the following code: \documentclass{article} \newcommand*{\ident}[1]{\texttt{\small #1}} \makeatletter \newcommand\ci[1]{% \def\citmp{}% \@for\reserved:=#1\do{% ...
2
votes
2answers
292 views

TikZ: drawing an evolution of an ellipse to a hyperbola with the same focus

Is there a high speed way to draw the evolution of an ellipse, to a parabola, and then into a few hyperbolas with the same focus? From the picture, we see that we start out with three elliptical ...
10
votes
1answer
88 views

Insert empty pages until certain page number

I have sections which have to start exactly at the predefined page numbers and the potentially unfilled pages between these sections should be filled with empty pages. Is there a for-loop available ...
8
votes
1answer
292 views

TikZ: Automating a process with a for loop instead of coding in each piece

I am positive I could create the incoming hyperbolas and then the deflections by the planet by hand for each one, but how the image is set up conjures up the felling this could be done through ...
3
votes
1answer
254 views

Adding PDF pages with \includegraphics using a loop

I need to include PDF pages with \includegraphics. I know there is the package \usepackage{pdfpages}. So this is what I have: \begin{picture}(0,0)(75,272.5) ...
8
votes
2answers
255 views

StrSubstitute for multiple replacements in a loop?

I am trying to replace multiple keywords using \StrSubstitute inside a loop using foreach - but unable to accumulate all the results. The result of each \StrSubstitute call is getting lost inside the ...
4
votes
1answer
165 views

Running out of main memory when using loops in TikZ

I have a TikZ drawing (namely, pairs of rulers) that I want to replicate 12 times, side by side. I'm using foreach constructs to help me in this process and to draw the 5-cm, 1-cm and 1-mm ticks for ...
7
votes
4answers
109 views

Defining a command to generate a sequence

I'm trying to define a command to make a list of subscripted \varphi characters. Let's call it \phiseq. I want to be able to use \phiseq{1,2,3} in the body of my document to expand to ...
2
votes
1answer
122 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 ...
2
votes
1answer
173 views

How to insert N images using TikZ's \foreach?

I'd like to avoid having to copy & paste the same code 50 times in my input file, so I'm trying to use the automation offered by TikZ's \foreach. I do not know why this code generates 101 errors. ...
6
votes
2answers
239 views

Auto-generate attendance list

I am trying to generate attendance sheets for my class. I need the sheets to have two things: 1) a list of the students in the class with a blank for them to sign their names. 2) a randomized version ...
15
votes
7answers
444 views

Making calculations using counter

I need to use the counter to make some computations inside loops. For instance, I want to write a for loop to get the following: ...
3
votes
0answers
322 views

“No shape named intersection-1 is known” error in TikZ [closed]

I want to draw a circle with arrows ending not perpendicular but straight on the surface. I managed so far to draw the paths I need and I already read about the naming of paths, but I get an error as ...
3
votes
1answer
112 views

How to change list options during a loop?

I currently have a beamer presentation, which, using the forloop package, looks basically like this: \documentclass{beamer} \usepackage{forloop} \begin{document} \newcounter{ctr} \newcounter{gulp} ...
6
votes
1answer
143 views

Macro to create new .tex files

I borrowed from Extracting the contents of text in a specified environment into a new file some code that extracts lines from a .tex file and puts it into a new file. The code works well, but I would ...
3
votes
1answer
306 views

Automated table for excercise points in tikz

I'm a computer science student. And I write most of my excercises in LaTeX. So I often have to create a table for excercise points, with different numbers of excercises and different amounts of points ...
6
votes
2answers
419 views

How to decrease the counter in tikz foreach loop

I have the following code: \documentclass[11pt]{article} \usepackage[a4paper]{geometry} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{tikz} \usetikzlibrary{positioning} ...
7
votes
2answers
377 views

creating a list of random numbers using a loop

I am trying to write a loop that will generate a set of random variables to be used in the probsoln package. I would like to make a loop to generate A, B, C, etc. This exam will have a lot of ...
2
votes
1answer
170 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} ...
7
votes
2answers
164 views

Repeating frame contents

Supposing that I'll use always two blocks on each frame. Then, I'd like to have a simple way to do the following, without copy/paste procedure: On each frame (except the first one), the first ...
8
votes
2answers
107 views

Getting \let definitions from inside a group, inside a loop

I have the following nested loop situation: \begingroup \def\do##1{% \begingroup \def\do####1{% \csletcs{somemacro@##1@####1}{someothermacro@##1@####1}}% ...
18
votes
4answers
416 views

Comma delimited list - how to obtain the length?

It's simple. I have a list like {0,1,54,1,3} as input argument to a command in making. How can I obtain the length of this list? Something like \length(#1) where #1 is the list.
11
votes
2answers
788 views

varioref: \vref or \vpageref at page boundary (may loop)

Sometimes a have situations, where I'm not able to compile a document, because the varioref package result in a loop. Here is a MWE, which result not in an endless loop, but it demonstrate the issue ...
3
votes
1answer
59 views

How do I create an expandable conditional with a loop inside?

I need to create an expandable conditional that uses a loop (that is, a ..._map_function:). It should either return true from inside the loop, or return false otherwise. In a 'normal' programming ...
3
votes
1answer
167 views

How to escape = in LaTeX's for loop

In user700902's answer to this post, there is the following for-loop: \@for\@tempa:=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z\do{% \expandafter\colorizemath\@tempa{green}} If I want to ...
9
votes
2answers
1k views

LaTeX for loop \@for

In user700902's answer to this thread, a for-loop with the syntax \@for is used. How does this syntax work? I tried searching about for-loops on other websites, but I could only find something like ...
4
votes
1answer
243 views

Continuing a TikZ animation with \onslide after a \foreach loop

I want to produce an animation in a tikzpicture environment in Beamer. The animation consists in a series of slides produced by combining \foreach and \onslide, which works fine. I then want to ...
7
votes
2answers
177 views

Why won't this Metapost while loop terminate?

The following loop fails to terminate and I have no idea why. I've either violated some syntax rule, there's an issue with the self reference in n:= floor (n/2);, or I've missed something ...
5
votes
1answer
103 views

Context - Error creating boxes in loop

The following code creates an array of boxes to represent an array. \startMPinclusions input boxes ; \stopMPinclusions \starttext \startluacode function createGraphic(k,c,indH) local i=1 ...
2
votes
2answers
143 views

What is the correct way to generate notation for a finite set using for loop in Latex?

I am trying to create a command that will take an index n as a parameter, and generate the the expanded form of this {a_1, a_2, a_3,...,a_n}. For my first attempt, I tried to use the syntax suggested ...
29
votes
3answers
1k views

Typesetting the entire Song That Never Ends

I've heard that LaTeX (and for that matter TeX) are Turing-complete, so it should be possible to produce an infinite loop. And indeed, a quick search reveals several questions in which users have ...
5
votes
2answers
259 views

Parallel loop [python-like zip] in Tikz

An easy way to write axis labels in Tikz is: \foreach \x/\xtext in {-1,-0.5,0.5,1} \draw[very thin,gray] (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\xtext$}; Is it possible to have something ...
3
votes
1answer
93 views

using \ForEach to input chapters in a document

I have several chapters in the folder /Chapters and I have the following LaTeX code: \newcommand\chapnames{Chap1, Chap2, Chap3, Chap4, Chap5, Chap6} \ForEach {,} {\input{./Chapters/\thislevelitem}} ...
5
votes
1answer
721 views

Loop for includegraphics

I try to make multiple slides in beamer with 3 figures on each slide and the title. I would like to loop through the list/array of figures and set the frame title. The name of the figure files and the ...
3
votes
1answer
268 views

how to use \loop … \repeat to generate an arbitrary number of rows in a table [duplicate]

Possible Duplicate: Copy table row n times The code below is intended to produce a table with 3 columns and 3 rows (one heading and two empty rows) but it can be seen that it doesn't work. ...
10
votes
2answers
182 views

Is there a better formatting option for an alternated enumerated/itemized list?

I'm making a questions/answers page where answer follows the question. The questions are enumerated while the answers are not. Questions are using one color while answers using another one. In order ...
1
vote
0answers
46 views

Loop to include multiple files [duplicate]

Possible Duplicate: How to iterate through the name of files in a folder I would like to include all the *.tex files from a directory in a document. To avoid me having to add manually the ...
4
votes
1answer
418 views

Adjusting font size for fake perspective

I'd like to add text on the paths on the left side with font size continuously adjusted from \Huge to \tiny to achieve a perspective like effect. The font size steps shouldn't be \Huge, \huge, \LARGE, ...
6
votes
3answers
138 views

Expansion issue when adding to CSV list from within a \foreach

Another expansion issue that I am unable to guess at the correct combination of \edef/\expandafters to get to work. Background: Below I have defined \AddToCommaSeparateList which uses \g@addto@macro ...
8
votes
5answers
357 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): ...
7
votes
3answers
424 views

Function to define how many lines to be displayed

I have just made a command in my own document class wherein if I type: \mline it would automatically output 5 lines only. My problem would be producing lines by just defining how many lines I want to ...
4
votes
2answers
104 views

Using a previously defined command in a loop

I have the following defined: \newcommand{\pl}{\ensuremath{p^L}\xspace} \newcommand{\pr}{\ensuremath{p^R}\xspace} \newcommand{\xx}{\ensuremath{_{XX}}\xspace} ...
7
votes
3answers
154 views

Defining commands using two loops

I would like to define a series of command using two loops. For instance I want to create a series of variables that can have YY or NN as subscripts. I would like to define commands \yy and \nn that ...
6
votes
1answer
573 views

Passing a variable from TeX to R in Sweave

I know it is possible to use \Sexpr to pass information from an R chunk to LaTeX. For example, <<echo=F,results=hide>>= a = 7 @ 42 is the answer to 6 x \Sexpr{a} Is there an ...
4
votes
1answer
169 views

How to make tabularx columns using \whiledo?

My question is similar to that discussed in How to programmatically make tabular rows using `\whiledo` ?. The difference is that I want to produce columns rather than rows with using \whiledo. ...
3
votes
2answers
215 views

having problems using arrayjobx with tikz - how can i use arrays in tikz?

I need the help of some smart people ;) I want to draw a picture with TikZ, which is heavily based on randomization and I want to make it quite parametrized. It's actually a graph of n nodes where ...
3
votes
1answer
140 views

datatool repeat row

I intend to create a document where parts of the text are read from the entries of a .csv file using the package datatool (version 2012/09/25 v2.11., updated manually under debian). Everything works ...
3
votes
1answer
202 views

A macro for looping through a pgfplotstable set by cell

Hi following on from the following question on multi-line headers with pgfplotstable, the solution was to set each affected cell individually. I decided to throw together a command to do that but keep ...
9
votes
1answer
121 views

Create a document looping through images

I have about a hundred images named 001.png to 123.png. I want to create a document which includes each image in center of a page. i.e. a 123 page document with each image on a single page. I know ...