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

2
votes
1answer
197 views

Dynamic table column generation

I'm trying hard in finding a way to streamline my table generation. As you can see in the attached code, the problem is related with the code "\@for \el:=#1\do{\textbf{\el} &}", where "&" ...
2
votes
1answer
515 views

conditional inside a pgfplotsinvokeforeach loop

I'm using \pgfplotsinvokeforeach to do mathematical computations inside the \addplot options. Now I need a conditional to decide whether to plot a line or not depending on the current index of the ...
2
votes
1answer
344 views

looping in tabular

I am curious to know why the following failed. A similar thread is on comp.text.tex unanswered. Of course, other manipulations of \whileexpr work, but why does this fail? \documentclass{article} ...
2
votes
1answer
78 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} ...
2
votes
2answers
48 views

Undefined Control Sequence \For, \state, or \EndFor

I want to write this algorithm but the error Undefined Control Sequence \For, \state, or \EndFor pops up. \documentclass[titlepage,oneside,12pt]{article} \usepackage[]{algorithm2e,algpseudocode} ...
2
votes
2answers
106 views

Insert loop inside table?

1- I want to make a table with n number of rows ? my wrong code \newcommand{\xx}{ \begin{tabular}{|c|c|c|} \hline \newcount\fooo \fooo=10 \loop 11 & 12 & 13\\ \hline \advance \fooo ...
2
votes
1answer
207 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 ...
2
votes
1answer
138 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
182 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} ...
2
votes
1answer
424 views

Place symbols/nodes at intersection between an arc and some horizontal lines with \foreach in TikZ

I'd like to place an symbol I've defined at all the intersection point between an arc and some horizontal lines: I know how to use \foreach for other cases, but I'm really not sure how to setup the ...
2
votes
3answers
216 views

Process Last Item in \ForEach (forarray package)

The following command of the forarray package \ForEach{,}{\thislevelitem(\the\thislevelcount) : }}{x,y,z} produces the output x(1) : y(2) : z(3) : I want to have the same output without the last ...
2
votes
0answers
68 views

Passing an array type argument for new command

I've looked around and can't seem to find anywhere, but I was wondering if there is somewhere you can do something like the following: \newcommand{\loopy}[1]{ \begin{tikzpicture} \foreach ...
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} ...
1
vote
1answer
49 views

Centering a table of images

I'm trying to center a table of images; 2 images per table row. Right now the code I have is ugly, and doesn't center on the document. I've tried using \begin{center} and \centering without any luck. ...
1
vote
1answer
201 views

Looping and linking with TikZ

How would you build a grid using a nested foreach, defining one node for each iteration? If I were coding in Python, I would write: nodes = {} for i in range(10): for j in range(5): ...
1
vote
1answer
1k 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 ...
1
vote
1answer
63 views

\pgfdeclareshape: how to define anchors in a loop?

I think my question is quite similar to this and this, however I didn't manage to modify the provided solutions to fit my problem. In the following MWE I am trying to define 8 pin anchors in a ...
1
vote
1answer
63 views

Loop through table for boxplot prepared

I am trying to produce figure with 2 boxplot prepared plots from an inline data file. I grabbed this code from here to use as a starting point. Given that the wrapper code allows the boxplot data to ...
1
vote
0answers
83 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 ...
1
vote
0answers
34 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} ...
1
vote
0answers
46 views

Loop to include multiple files [duplicate]

Possible Duplicate: How to iterate through the name of files in a folder I would like to include all the *.tex files from a directory in a document. To avoid me having to add manually the ...
1
vote
0answers
450 views

Generate trees based on number of nodes and children allowed [closed]

I am doing an experiment, and would like to generate images of Binary Trees and Exponential Trees using LaTeX. The difference between these two structures is the number of children allowed per node ...
0
votes
1answer
33 views

Forloop macro does not work with other macro in condtion

This is my primative code: \documentclass{article} \usepackage{xstring} \usepackage{ifthen} \usepackage{pgfkeys} \newcommand{\setvalue}[1]{\pgfkeys{/variables, #1}} ...
0
votes
1answer
61 views

exsheet print several exams same document

How to print several exams in the same document using exsheets? I need to print several exams using \includequestions[random=1]{easy} \includequestions[random=1]{medium} ...
0
votes
2answers
310 views

Environment with customizable number of table columns

I want to make macros for drawing group of questions with same answers with customizable text, number of answers and design (column widths, alignment, etc.), like this: ...
0
votes
1answer
31 views

Strange extra line after forloop in a tabular table

I'm trying to generate table lines (tabular environment) with forloop macro. I've got strange extra line after forloop. \documentclass {article} \usepackage [utf8] {inputenc} \usepackage [english] ...
0
votes
0answers
18 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.} ...