{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
1answer
48 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
106 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} ...
6
votes
5answers
298 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
42 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
24 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: ...
6
votes
1answer
123 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 ...
2
votes
1answer
20 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
158 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
150 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
50 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
45 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
48 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} ...
3
votes
1answer
27 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
265 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
88 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} ...
1
vote
1answer
25 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
38 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
24 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
159 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
86 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
51 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
262 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
47 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
245 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
82 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
111 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
204 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} ...
2
votes
1answer
133 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
738 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
47 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) % ...
5
votes
1answer
139 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} ...
6
votes
2answers
191 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
192 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
89 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
39 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
114 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
54 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
381 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 ...
4
votes
2answers
119 views

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

I would like to generate an autmatic 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 accessing ...
1
vote
2answers
54 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
26 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
29 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
92 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} ...
3
votes
1answer
102 views

Programmatically expand my image in TikZ

I've got an image made of a number of slowly expanding arcs. Now I want to add another 10 wedges, over the same total angle (so each arc will be ~14º). I'm trying to use the following code, but I'm ...
4
votes
0answers
72 views

TikZ: \foreach loop not executing expected number of iterations [duplicate]

I am trying to draw a Bézier curve defined by five control points following the algorithm discussed here. I generate the points of the curve with a \foreach loop: one point per iteration (also, from ...
3
votes
1answer
134 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 ...
0
votes
0answers
35 views

How to load input file with given starting string but unknown end?

In the directory of my latex source there are input files: input_01.tex, input_02.tex, etc. It is very easy to load them with a for cycle. But how to load them if their names are: ...
23
votes
3answers
910 views

Make fireworks with only text

For the holidays, I wanted to follow up to the question about making fireworks with tikz (How can we display fireworks?): How can we make fireworks with only text? I have made a crude attempt below. ...
2
votes
1answer
105 views

How to make Loop?

I need to make for loop analog in LaTeX. My code has following form \documentclass[9pt]{article} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[scale=1.2, font=\tiny] ...
8
votes
2answers
83 views

Loop until the end of a page

I want to fill a page with a single word or phrase repeated over and over and over again. I will then print out this page. For example, \documentclass[12pt]{article} ...