{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
80 views

array and loop to set frametitle, subsection, and text

In the example below, I store text into three variables (\subTa, \subTb, \subTc), and then use these variables to set the subsection, set the frametitle, and display text on each slide, all using ...
2
votes
0answers
53 views

Using a for loop to loop through sequentially named tex files [closed]

I'd like to loop through all .tex files in a directory using code that looks like the following: \documentclass{article} \usepackage[hmargin=1cm,vmargin=1cm]{geometry} \usepackage{pdflscape} ...
11
votes
1answer
119 views

PGF's `foreach` recognises when there are no list items and doesn't run the code. Is this guaranteed?

The PGF \foreach macro behaves differently when the item list is totally empty than it does when a single item happens to be empty. \documentclass{article} \usepackage{pgffor} \begin{document} ...
2
votes
1answer
180 views

How to loop over R objects OUT OF chunks

I want to typeset with TeX a report based on data from an R object (dataframe). The idea is to print a nice TeX table from each line of a R dataframe. Something like \begin{tabular}{ l c r } A1 ...
8
votes
2answers
419 views

LaTeX Loops in \newcommand

I have used LaTeX for about a year now and every time I write a paper I try to improve on my knowledge so recently I've been creating my own commands to help save time. I am interested if it is ...
6
votes
3answers
243 views

How can I get these two nested \foreach loops to work?

I try to use nested \foreach loops to create edges between many nodes. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node (a) at (0, 1) {}; \node (b) at (0, ...
1
vote
0answers
32 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
170 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
144 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
89 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
173 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
111 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
159 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
92 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
87 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
529 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
528 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
332 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
90 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
131 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
854 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
219 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
74 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
374 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
125 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
101 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
283 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
301 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
181 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
237 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
110 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
318 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
93 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
300 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
333 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
323 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
182 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
114 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
134 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
194 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
275 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
485 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
407 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
125 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
328 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 ...