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

1
vote
0answers
31 views

Label of figure in a for loop

I am adding figures to my TeX file using the following code: \foreach \paramA in {a,b,c} { \foreach \paramB in {1,2,3} { \begin{figure} \addOneImage{pathToImage/imageName_\paramA_batch\paramB.png} ...
5
votes
2answers
166 views

How to get the number of elements in a \foreach loop?

Does the PGF command \foreach provide a simple possibility to get the number of elements iterated? It has a parameter count to hold the current element number, so a workaround is to iterate the list ...
6
votes
2answers
141 views

Can I automatically draw my cards from a list?

So, I've made a format to print cards out (Shown below). Is it possible for me to fill each card environment from some sort of list, instead of having to write out \cards{foo} for each card? I could ...
3
votes
2answers
88 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. ...
10
votes
2answers
164 views

Dynamically define commands

I have some latex code that goes a bit like this: % Sp defines a generic command for an arbitrary space, % and all of the others just delegate the bulk of their % work to it so that when I decide to ...
3
votes
1answer
107 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: ...
10
votes
4answers
110 views

Results of xfor loop failing with numerical arguments

I am trying to write a macro that selects an item from a comma separated list, \select{2}{A,B,C,D,E} results in B. I am using the xfor package to process the list, but would try etoolbox if that ...
5
votes
1answer
155 views

Three loop diagram

I want to make a three loop diagram such as the one on the left. I use the following script \fmfleft{i}\fmfright{o} \fmf{boson}{i,v1}\fmf{boson}{v2,o} ...
2
votes
1answer
88 views

Conditional assignment in a loop

Objective: I want to compile the temporary.tex file containing PSTricks code twice. One with -jobname=Rotated and the other one with -jobname=Unrotated. The resulting Rotated.ps will be passed to ...
6
votes
2answers
86 views

Extra row appearing in table assembled in pgf for loop

I'm constructing a table one line at time inside a \pgfplotsforeachungrouped. An unwanted line appears after the \hline at the end of the last round of the loop as evidenced by the lone decimal point ...
6
votes
1answer
492 views

TikZ Self Loops Style Question

I have a question on how to "style" the self loops in my diagram. Here is my preamble: \documentclass[letterpaper]{tufte-handout} % Additional LaTeX Packages \usepackage{amsmath} ...
5
votes
3answers
472 views

Nested lists in \foreach loop in TikZ

I want to draw a bunch of nodes with different styles (a, b, ...) at different points (named 00, 01, ...). I am using the following code: \foreach \n/\lst in { a/{00, 14, 20, 34}, b/{01, 11, 23, ...
27
votes
2answers
325 views

What's the difference between the various methods for producing for loops?

I've been wondering about the various methods available for looping over a comma separated list and the like. In particular, I was wondering about their various strengths and weaknesses. In other ...
4
votes
1answer
84 views

Loop Multi-Contingency using etoolbox

I want to use the etoolbox package to manage some loop contingencies over a counting index. In particular, I'd like to do something different on the first and last times through the loop. Now I can ...
0
votes
0answers
17 views

Figures in latex using loop [duplicate]

To put maximum of 6 figures in 3 rows & 2 columns in a A4 page using loop, I tried like: \foreach \x in {1,2,3,4,5,6,7,8,9,10,11,12} { \begin{figure}[h] \caption{This is the caption.} ...
10
votes
3answers
129 views

Looping Through a Nested List

I have a hunk of data like so: { { {AA},{AB}, ... {AZ} }, { {BA}, {BB}, ... {BZ} }, ... ... { {ZA}, {ZB}, ... {ZZ} } } defined in a macro called \clebschdata. Each term XX is a list of eleven ...
30
votes
2answers
851 views

Color all vowels differently in a LaTeX document

Is it possible to give the letters a,e,i,o,u,y a different color in a piece of text? For instance, color all the a's red, the e's blue, the i's green, etc. EDIT: Without doing it manually of course.
15
votes
3answers
217 views

Printing the first N terms from a telescoping series

I would like to produce a LaTeX document that generates the first N terms of the telescoping series sum(1/k-1/(1+k)) where k=1,2,3...,N, such that it displays at least the first 10 terms. I want the ...
8
votes
1answer
72 views

Splitting file into lines and lines into parts

I'm working on a song book using LaTeX. It's early in the project, and the songs aren't all picked out yet, but I thought I'd fix the inner workings of it in the meantime. Since many people will ...
6
votes
2answers
340 views

Problems using \addlegendentry in a loop with pgfplots

I have some spectra to plot, which I exported from the Siemens Xray toolbox, which works nicely with pgfplots. Since these are multiple files that look the same I think I can do it with a for loop, ...
3
votes
1answer
123 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
1answer
95 views

Why do the following nested loops spin beyond my expectation?

Let's consider the following code that reflects my simplified scenario. I want to show a distinct integer for each slides. Of course the real scenario is not to do such a silly thing. ...
6
votes
2answers
97 views

Separators for author group (IF conditon)

I am new to LaTeX, just a beginner, basically a Perl developer. I have created a LaTeX file \begin{document} \cont{\iname{\isurname{Name1}\ifname{K. C. G.}}\iname{\isurname{Name11}\ifname{Y. ...
5
votes
2answers
281 views

How can I label TikZ-graphs on four vertices with a loop?

I need to draw all these simple labelled graphs on four vertices. Anyway, can I do this in a quick manner with a loop? And put them in an array? I have already drawn all unlabelled simple graphs on ...
10
votes
1answer
288 views

XeTeX UNICODE Table

I would like to try to write a minimal XeTeX source that generates a comprehensive UNICODE table, substituting in local fonts as required by the current plane. I made the attached code as an MWE for ...
3
votes
1answer
175 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 ...
5
votes
1answer
228 views

Package PGF Math Error: Sorry, an internal routine of the floating point unit

This type of error (! Package PGF Math Error: Sorry, an internal routine of the floating point unit got an ill-formatted floating point number ...) arises when trying to use a predefined list for the ...
2
votes
1answer
99 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
109 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
313 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
90 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
297 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
329 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
310 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
180 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
113 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
129 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
190 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
267 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
478 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
393 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 ...
4
votes
1answer
124 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
145 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
324 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
494 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
393 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
177 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
183 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
114 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
449 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.