{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)

3
votes
2answers
342 views

\DTLdeletedb (from datatool package) has no effect within \foreach

This question led to a new feature in a package: datatool \DTLgdeletedb is available in (v2.13) and later. I am trying to use a \foreach loop to iterate over a few items. For each iteration of ...
3
votes
4answers
293 views

What is the TeX equivalent for the following C# nested loop?

I need a nested loop to animate PSTricks diagrams. In C# or C or C++, I usually write as follows. int N=6; for(int x=0; x<N; x++) for(int y=x+1; y<N; y++) Console.WriteLine("({0}, {...
3
votes
2answers
123 views

Writing a recursive matrix pattern

Consider the following matrix \begin{equation} \begin{pmatrix} B_{0,0} & B_{0,1} \\ B_{1,0} & B_{1,1} \end{pmatrix} \end{equation} The next matrix in the iteration is going to ...
3
votes
3answers
232 views

question in using \foreach to iterate over lists

I am learning \foreach to see if it will work for what I want to do. I can't figure why the following does not generate the expected output. MWE \documentclass[12pt,titlepage]{article} \usepackage{...
3
votes
1answer
197 views

Beamer and a for each loop

I'm using the beamer presentation package and trying to combine the examples from this post How to iterate over a comma separated list? with the beamer package. In modifying the top example, chaning ...
3
votes
1answer
195 views

How do I add a for loop to a class file function?

I'm using this XeLaTeX class file to write my resume. One of the features is for section headings it colors the first 3 letters: \section{experience} This is hardcoded to the first 3 letters, and I'...
3
votes
1answer
73 views

Is there any way to draw the same shapes at different positions efficiently, for example \foreach?

I know there is a similar question, but I do not think it gave the best solution. Here is my code: \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \clip(-0.5,-1) ...
3
votes
2answers
197 views

Loop to create new counters

I want to create counters in a loop like this (with the packages multido, totcount) : \newcounter{compteurChi}% first counter \regtotcounter{compteurChi}% define the first counter as a ...
3
votes
3answers
271 views

Declaring variables and writing loops

My exam template includes a table listing the point values for each problem in the exam. Is there a way to declare the point values of each problem as variables within latex and write code to ...
3
votes
1answer
439 views

Latex - figures side by side using loop

I am trying to put 6 figures in 3rows & 2 columns: \foreach \x in {1,2,3,4,5,6,7,8,9,10,11,12} { \begin{figure}[h] \caption{This is the caption.} \vspace{0.0cm} \centering \includegraphics[height ...
3
votes
1answer
135 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}} {...
3
votes
1answer
2k views

How do I add parfor in algorithmic environment?

I want to have a parfor loop in my algorithm listing (it should work exactly as standard for loop works). How to either change the displayed name of for loop or add my own loop which will keep the ...
3
votes
1answer
55 views

TikZ > Is it possible to use the identifier of coordinates as string?

I am drawing pictures with TikZ using loops, for instance \foreach \point in {(i),(j),(k)} {...}. Is it possible to use the name of the coordinates as string to label a node? I'd like to use \node at ...
3
votes
3answers
67 views

Create and use macro names dynamically within a loop for redefining lowercase greek letters

This is follow-up question to this one. My aim is to let greek letters behave the same like normal latin letters, when it comes to get them upright. At the moment I'm using \mathrm to get letters ...
3
votes
2answers
126 views

How can I remove hardcoded numbers from this TikZ algorithm for drawing a circle of circles?

I have some TikZ code for drawing a circle of little circle images (for showing pictures of a team of people). The number of people shown can vary, so I'm trying to remove hardcoded numbers to make it ...
3
votes
2answers
111 views

How do I create different math problems and their answers?

(How to extract elements from a loop in an array?) I'm trying to create "n" versions of a homework and their answers in the last page changing or increasing each variable every loop. So far I can ...
3
votes
1answer
250 views

Nested CSV with csvsimple

I have two csv files. I want to use the first (countries.csv) to generate sections, and then filter the second (bottles.csv) by the name of the section. Below is an MWE - you can see that the nested ...
3
votes
1answer
91 views

tabular environment: incrementing the headings

Is it possible to let LaTeX increment the headings in a table environment? If so, how could I do this? For example, I would like to have 7 columns and 7 rows where the columns except the first are ...
3
votes
1answer
132 views

making multiple tables with for loop

I have a following problem: I need to create a multipage document, containing single table on each page. The table is same for all pages, pages differ from each other by page number only. To make the ...
3
votes
1answer
127 views

makeidx, xstring, forloop and utf8 conflict

I'm using Danish characters in strings that I split with \StrCut from the ×string package and use within a \forLoop from the forloop package. The result is not good. Consider this small example: \...
3
votes
1answer
661 views

Dynamic table column generation

I want to generate table columns dynamically but I have no clue how to tell LaTeX to accept or evaluate & as a column separator. As you can see in the attached code, the problem is with \@for \el:...
3
votes
1answer
182 views

How to put a series of figures in annex

I want to put 51 figures , with names 0001.png ,....., until 0051.png, in annex ans I'm wondering if I can do something similar to this in latex . for i series_of_figures; put figure in annex , with ...
3
votes
2answers
432 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
175 views

forarray's \ForEach isn't robust

\ForEach and related commands of forarray package aren't robust. They can't deal with lists whose separators are active (e.g., active comma). Also any trailing space after the list item is retained ...
3
votes
1answer
56 views

Import several parts of file at once

As a follow up to this Question Situation I would like to create an excerpt from a script that I have TeX'ed as a compendium of the most important statements (theorems & definitions). I seek ...
3
votes
2answers
46 views

Error in foreach loop when number range defined with a macro

I am having problems to implement a loop that runs over the months of the year and the days of each month. A simple representative example of my current approach is shown below. \documentclass{...
3
votes
1answer
57 views

LaTeX3 loop expanding to repeated {}s

I’m using the ExPex package for vertically aligned linguistics glosses. For various reasons I have some stuff that looks like this: \ex \begingl \gla \rlap{thisisaverylongword} @ {} @ {} @ {} @ ...
3
votes
2answers
141 views

Loops and Tables

I'm trying to use LaTex to produce our family diary for next year. It's a page per week with a column for each person. I have the basic layout working: \documentclass[10pt]{article} \usepackage[utf8]...
3
votes
1answer
155 views

Loops in dot2tex. Or easely draw complex graphs

My original question : Is it possible to use loops in dot2tex? I would like to type something like: \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{arrows,shapes,snakes,automata,...
3
votes
1answer
239 views

Iterate over pages and set variable

I am looking for a way to take the output of a pageref, iterating through, and assigning a property to each of those pages. Specifically, I want to take this: \documentclass{article} \usepackage[...
3
votes
2answers
164 views

highlighting vowels using a background color [duplicate]

Is it possible to give the letters a,e,i,o,u,y a different background color in a piece of text by using a loop or package? For instance, give the a's a red background, the e's a blue background, etc. ...
3
votes
1answer
177 views

Xparse macro with optional parameter breaks value for PGF foreach

I write a document class and want to execute something a certain number of times, depending on a user-defined quantity. So I thought I'd use a foreach loop from PGF together with accessor macros: \...
3
votes
1answer
387 views

Creating a list of 'stacks' leads to 'Argument of \@firstoftwo has an extra }'

the title may be confusing, but I'm not sure how to name it better. This current question is the result of my other ones, and the hints I got from users in this board. Steven B. Segletes helped me ...
3
votes
1answer
127 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{% \protected@...
3
votes
1answer
434 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 ...
3
votes
1answer
389 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 ...
3
votes
1answer
305 views

How to translate this scenario to LaTeX looping macro?

I want to slice an image into 8 parts, i.e., 2 rows by 4 columns. Each part is on a single page as follows. The gray frame is the Acrobat Reader background, so don't think it is a part of the output I ...
3
votes
1answer
639 views

How to include multiple images inside a TikZ loop

I have a case, where my files are named images_001.png .... images_011.png. I tried to put them like this: \def\filelists{1/{"t0_01"},2/{"038"}, 3/{"050"},4/{"060"}} \foreach \i\element in \...
3
votes
1answer
37 views

Tex csname index off by one inside loop

I'm trying to write a write a simple implementation of a list of notation (more as a technical exercise than for actual use). I've run into a rather strange issue with numberings. The following is my ...
3
votes
1answer
43 views

TeX \@for loop within a section title

I am creating a macro for turning a list of files into a comma-separated list of monospaced file names, and using it as a heading. I have written a short script for doing so: MWE: \documentclass[...
3
votes
2answers
53 views

write tokens to external files / loop unless ifeof does not work for me

I'm trying to write lines including tokens to an external file and read them again in a different document. I face two prolblems: (1) Is there a way around the ugly \unexpanded{} when calling my \...
3
votes
1answer
67 views

Automate importing pages from PDF file and add text to some of these

I'm trying to use LaTeX for lecture notes, but am having trouble implementing it the way I want to. For each lecture I will have access to a PDF file with presentation slides, where one slide ...
3
votes
1answer
47 views

Within the .tex file, a loop to compile to multiple PDFs recycling content according to language

I bet there are lots of loops using external processing, but I was hoping to get a preamble hack that would pdflatex out three outputs - suffixed according to Language selected - of the following MWE:...
3
votes
1answer
148 views

conditional loop printing text and icon

I'm new in the Latex world. I'm writing a little guide and I've choose Latex, in particular Texmaker for writing it. I'm trying to do a loop for printing some instruction as File -> Save as -> Ok. ...
3
votes
1answer
339 views

Using \pgfplotsinvokeforeach in foreach loop

I am trying to run a \pgfplotsinvokeforeach loop in a \foreach loop to plot the variables var1_roll1 - var1_roll10 in one plot and var2_roll1 - var2_roll10 in another. Both loops work fine ...
3
votes
1answer
78 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
610 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. \...
3
votes
1answer
207 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
615 views

CV/resume entry

I would like to create a "command" that does this for me: \cventry{jobtitle}{organisation}{date}{description}{bulletpoint...} such as: \cventry{Potato peeler}{TESCO}{1999 -- to date}{ Responsible ...
3
votes
1answer
32 views

Bad linebreak with tabulars in loop

I have built arrays (with csnames) containing contact information, and I would like to print out all the contacts in tabular format, using a loop. But when the tabulars overflow the \textwidth, ...