{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
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 ...
6
votes
1answer
110 views

\foreach dimension too big

I want to create an animation of satellites. I am using the code below. However I'd like it to run smoothly so I want to produce many frames. It turns out the maximum number of frames I can create via ...
1
vote
0answers
20 views

Looping through elements in a sequence [duplicate]

In a follow up of Highlighting words only the first time they appear it was suggested to use \seq_use:Nn to display the content of a sequence. It works really nice but it concatenates the items with a ...
2
votes
4answers
136 views

TikZ's \foreach \x/\y in… the set of running indices being a macro

Please look at this minimal example which contains my question: \documentclass[english]{article} \usepackage{tikz,ifthen,listings} \newcommand\IndexListOne{1,2,3} \newcommand\IndexListTwo{One,Two,...
1
vote
1answer
70 views

Permuting an index list; and creating an index list of 0's and 1's

I want to run the steps of a loop in random order and also save the order in which the iterations were carried out: \documentclass[english]{article} \usepackage{tikz} \newcommand\...
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 ...
9
votes
4answers
283 views

drawing music staves with \rule loop

I want to draw blank music staves using nothing but \rule in a loop. (I know there is MusiXTeX and Lilypond, not to mention Tikz, but really, I just want some horizontal lines.) In this example, the ...
2
votes
1answer
149 views

Print iteration counter in for loop

I am new using for loops in latex, and not sure if the following is possible. This is basically what I am trying to achieve: \documentclass{article} \begin{document} \foreach \x in {a,b,c} { \...
7
votes
1answer
138 views

How can I get different colors in each element of double loop

This is my code \documentclass[tikz]{standalone} \usetikzlibrary{calc} \usetikzlibrary{intersections} \usetikzlibrary{arrows} \usetikzlibrary{decorations.pathmorphing,decorations.pathreplacing,...
6
votes
5answers
663 views

How can I draw several polygons on the same base line using TikZ?

I want to construct a figure that will be symmetrical polygons on the same base. So, there is an equilateral triangle, a square, a pentagon, a hexagon, etc. one side of all these is the same ...
4
votes
1answer
59 views

Beamer successive overlay actions in reverse order

I try to make this macro work in reverse order, I mean the display is made from the left in a stared version instead from the right, ex : ...=8 , ...=2*2*2=8 , 2^2=2*2*2=8 I can't imagine how to do ...
0
votes
1answer
29 views

Automatically rotate through image files?

Note: this is NOT about rotating the image itself. In my book I have a bunch of decorative vignettes like this: , , and so on.... And I created a command for it: \newcommand*\vignette{\begin{...
6
votes
1answer
148 views

Why does \loop behave differently depending on order of its contents?

Just a question out of curiosity. I tested the code below, and first two {\loop...\repeat} commands returned \TeX!\quad six times, and others returned it five times. Why do only first two {\loop...\...
2
votes
1answer
82 views

How to output text value of counter in for loop

Consider following code: \documentclass[12pt]{article} \usepackage{amsmath} \usepackage{forloop} \begin{document} \newcounter{i} \forloop{i}{0}{\value{i} < 3} { % trying to get the text of ...
6
votes
2answers
305 views

Generate the n-th letter of the alphabet in a tikz loop [duplicate]

The following code draws 10 nodes, labelled from 0 to 9. \documentclass[a4paper,10pt,landscape]{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \i in {0,...,9}{ ...
2
votes
2answers
171 views

Accessing value in forloop

This code is not compiling and creates an error "Missing number, treated as zero". \newcounter{x} \forloop{x}{0}{\value{x} < 5}{ value is \value{x} \\ } How can the value of x be printed ...
4
votes
3answers
106 views

\forlistloop of etoolbox reference requested

I am having a problem of using the command of \forlistloop of etoolbox unlike the way of typical C program where int a[5] for ( i = 0; i <5; i++) { a[i] } one could access i I am not sure ...
5
votes
1answer
106 views

Tikz Intersecion doesn't recognize path named with name path

I have problems with using path names defined even in the same loop. the following code produces error message: ! Package tikz Error: I do not know the path named `ab6'. Perhaps you misspelt it. ...
2
votes
0answers
192 views

Iterating through a character/string array in LaTeX

I have an array of strings, and am trying to output each element into LaTeX. I am able to achieve that using the following code: \documentclass[12pt,english,nohyper]{tufte-handout} \usepackage[T1]{...
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, ...
7
votes
2answers
437 views

How to repeat over all characters in a string?

I have a command that formats a single character, let's call it \d{}. (In my case, \d{} adds a dot under a Chinese character, as this is the custom to emphasize Chinese texts). I want to define a ...
3
votes
3answers
233 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{...
1
vote
1answer
40 views

\ForEachX and string concatenation

I'm writing a class where I have an arbitrary number of strings that I'd like to concatenate, then loop over and typeset using \ForEachX from the forarray package. If I define a command to add to a ...
1
vote
2answers
48 views

Tables and equations in a 2 column paper

I am trying to write a paper with 2 columns and I need to insert tables and formulas in it, however, they are not fitting. Is there a way how to make these shrink to fit the page size? MWE: WIC is ...
2
votes
1answer
38 views

pgffor `foreach` loop over databib macro-generated list

The databib package from the datatool bundle allows one to import BibTeX databases and work with them from within LaTeX. The author field can be accessed as \DTLbibfield{Author}, which returns data ...
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
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 ...
2
votes
1answer
101 views

Problem using macro with TikZ foreach

I am using a simple macro adapted from an answer to the following SO question: http://stackoverflow.com/questions/3951392/latex-space-after-every-letter The modified macro simply takes a string and ...
11
votes
3answers
287 views

3n arguments in a macro (n is an even number) for curves whose thicknesses increase or decrease

For some mathematical figures it's nice to be able to vary curve thickness smoothly along a path, to reproduce hand drawn mathematical figures made with inking liners for instance. One way to do it ...
0
votes
0answers
90 views

Take input from csv file and use it to create a custom-made table in tikz

I have a csv file that looks like this: Scott, William, Todd,Esben, Martin, Jesper, Alexander W.L Right now, the names are written this line \aebuildtable{20}{Scott,William,Todd,Esben, Martin, ...
3
votes
3answers
260 views

Using loops with chains?

Is there a smarter way to achieve the same result as the one from the following MWE: 1) by using some kind of loop instead of hand typing every node, 2) by drawing the arrows with tikz instead of ...
1
vote
1answer
368 views

In-line graphics in text to represent a loading bar for language skills in a CV

I would like to add my language skills to my CV in the following manner: I could of course create an image in Inkscape for every language, and put it in in a most straightforward way, maybe as ...
1
vote
1answer
162 views

Text on rectangular spiral with automatic sizing to fill page

I'm wondering how this could be done in TeX: This is along the lines of Text spirals with TikZ but in a rectangle, with all text the same size, and all text should be at right angles (unlike the ...
6
votes
5answers
375 views

How to get the number of occurrences of characters in a string

How to get the number of occurrences of characters in a string? \documentclass[14pt]{extarticle} \usepackage{xstring} \usepackage{forloop} \usepackage{ifthen} \usepackage{pgfkeys} \newcommand{\fios}{...
2
votes
1answer
237 views

Vertical Bubble (Loop) Diagrams with FeynMF

I want to produce the following Feynman diagram with FeynMF; the problems is how to render the loops (particle-hole bubble) in the vertical direction; furthermore, how to fill a vertical bubble with ...
12
votes
6answers
956 views

command for writing a sequence of numbers

While writing a document with many sequences of numbers (and various lower and upper boundaries), I would like to define a command such as \myscale{1}{6} that would produce: 1 2 3 4 5 6 What ...
1
vote
1answer
56 views

How to building on pstricks the flowchart shape?

I need to building several flowcharts with pstricks and I have problems to get the symbol as the below. Can somebody help me? \newcommand\psBucler[3]{% \pspolygon(-1,0.1)(1.2,0.1)(1.2,1)(-1,1) % \...
7
votes
1answer
524 views

Repeating the same column type

I'm using package numprint to create a table which automatically formats its columns. However, the table has many columns. Right now, my table definition looks like this: \begin{tabular}{l n{2}{3} n{...
6
votes
2answers
201 views

How can I use a list stored in aux and insert its output into a tikz node?

# Update 2015-03-19 Better Answer Found This question is part of a trail of questions. The goal mine was to use this list inside of a tikz node, but I removed that from previous questions in the ...
3
votes
2answers
207 views

How can I loop thru a list of inputs that come after \maketitle, yet use that list as part of the \maketitle command?

Multilingual Document Question I would like to follow the principle of "don't repeat yourself" and create a single list of inputs, which are actually various versions of the same document in ...
2
votes
1answer
161 views

Fill line with asterisks [duplicate]

I want to fill a line with asterisks just like as with \cdots or \ldots that can be used in tables, \leaders solution doesn't work well. I'm working in a fixed columns width table, where at the end ...
1
vote
2answers
69 views

Loop over a list with delimiter different from comma

I am trying to iterate over a list, the delimiter of which is not a comma. The reason for not using commas as delimiters is that they are part of the payload. Is there a way to iterate over a list in ...
2
votes
1answer
208 views

Frontispiece for thesis UK

I am writing the title page of my thesis, but the frontispizo package described elsewhere on this website doesn't really suit my needs. I am sure the frontispiece I require below can be easily ...
4
votes
2answers
67 views

Redefining a Command in a Loop Over a Comma Separated List

I want to redefine the glossaries package’s \gls commands to include an index entry and an optional argument for formatting the index entry. However, there are so many variants of this command (\gls, \...
4
votes
2answers
445 views

Is it a convenient way to write longer program codes in LaTeX?

Before I only used ifthenelse and for loops, but not complicated data structures. I don't know what is the convenient way to write longer codes. As an example I would like to generate a random ...
5
votes
3answers
170 views

loop in tabular that uses \the\count to access current line number

I would like to generate an automatic table using loop. As suggested here before, it is best to first generate the lines in a toks and then pass them to tabular. However, I have problems with ...
1
vote
2answers
58 views

Converting a number into a character and then using it in a filename

I am trying to create a loop that will print out a list of image files. All of these image files have a filename like this: fa-x.jpg (where x is a character from a - h). I've made a loop, but the ...
4
votes
1answer
33 views

How do I define an excludecomment environment in a for loop?

I'm using the forloop and comment packages to define environments prob1 through prob5 that exclude portions of my document. Here's a MWE: \documentclass[12pt]{article} \usepackage{comment} \...
0
votes
0answers
35 views

How to cite this in revtex4-1?

I have trouble to achieve the following citation style: Tam, K. C. , M. L. Farmer , R. D. Jenkins , and D. R. Bassett It's not standard APA or MLA styles.
2
votes
1answer
119 views

Why this loop with “evaluate” does not work?

\documentclass[margin=5pt]{standalone} \usepackage{tikz} \usetikzlibrary{shapes,calc} \begin{document} \begin{tikzpicture} \foreach \x [evaluate=\x as \name using \x*20] in{0,0.05,0.1,0.15,...,5} \...