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

0
votes
1answer
17 views

Texmaker freezes when iterating over an array and plotting with pgfplots

I have written a latex piece that iterates over two arrays and creates a plot for each entry of the array. However, my Texmaker gets surprised and freezes (I just gets fully processing power of my CPU ...
0
votes
0answers
35 views

How to create several plots in latex using a for loop

I have a bunch of arrays like follow: a[l=3]= (1, 8.099681e-01) (2, 8.099681e-01) (3, 7.399681e-01) (4, 0.000000e+00) (1, 9.600000e-01) (2, 9.600000e-01) (3, 8.800000e-01) (4, 0.000000e+00) a[l=4]= (...
2
votes
1answer
19 views

Pass iteration variable from foreach to custom command

I am trying to figure out why the following code does not work: \documentclass{article} \usepackage{etoolbox} \usepackage{pgffor} \newcommand\setProblemShow[2]{% \csdef{isProblemShow#1}{#2}} \...
2
votes
1answer
22 views

Use for-loop in LuaTeX to include many subchapters

I have many files called 1.tex, ..., 85.tex which I want to include into my document like this: \include{chapters/text/1} [...] \include{chapters/text/85} As I use LuaLaTeX, I thought I could use ...
1
vote
1answer
12 views

Use of forloop-counter inside beamer \only

I'm using LaTeX beamer and the forloop-package to create a for loop, and I want to use the counter inside an \only-command. Here is a MWE (or more like non-working example): \documentclass[12pt]{...
3
votes
2answers
33 views

In an automatic vertical stacking of a certain subsequent number span - how to regulate spacing between those numbers?

On the StackExchange-chat, I received quickly-made MWE's which answered parts of my question; yet remarkably show the experience and knowledge of the person who fabricated them. For example, when I ...
22
votes
5answers
3k views

Empty document, only pagenumber, 500 pages needed

I need a document with 500 empty pages, only the pagenumbering in the foot of the page. This MWE shows 2 pages in the way I'd like to get all 500: \documentclass[pagenumber=footright, DIV=20, ...
0
votes
1answer
29 views

Inline derivative macro

I'm trying to define a macro so that $\D{x^2,y^3}$ expands to $\partial_x^2 \partial_y^3$. I tried \makeatletter \newcommand{\D}[1]{% \@for\@token:={#1}\do{\partial_\@token } } \makeatother ...
2
votes
3answers
59 views

Alternating integers provided in for-loop

The following code prints the labels foo, bar, baz, and qux on alternating sides of a circle. This is being done by for-looping over multiple variables specified in \myInput. The variable responsible ...
0
votes
0answers
45 views

LaTeX code as a Python Subroutine

This is my problem. I have a rather sophisticated LaTeX code, namely master.tex It reads a .csv file as an imput It reads .pdf drawings as an imput It calls other subordinate .tex files It contains ...
5
votes
2answers
138 views

Tikz fill color

At the moment I'm using this command in the preamble to fill the color of the specified row with grey: row 2/.style={ nodes={fill=gray!10} } Unfortunately I have to write this ...
2
votes
2answers
58 views

Pass a list to a keycommand or keyenvironment

I want to define command or environment using the keycommand package and pass a list to one key. In my case this would be a list of images. To be more explicit: How can I make the following ...
1
vote
0answers
21 views

How to create looped output with knitr?

In my thesis, I have found 79 different concepts I need to describe in detail in the appendix. I used R for the analysis, and I want to use knitr for creating that appendix. Each description follows ...
4
votes
2answers
109 views

How to make editorial table from sections

How would it be possible to make an editorial list/table? I'm not asking how to create a list or table, but if it is possible to attach something to \section's and \subsection's in the form of a \...
3
votes
1answer
55 views

TikZ > Is it possible to use the identifier of coordinates as string?

I am drawing pictures with TikZ using loops, for instance \foreach \point in {(i),(j),(k)} {...}. Is it possible to use the name of the coordinates as string to label a node? I'd like to use \node at ...
0
votes
2answers
33 views

If condition controlled with a loop variable

I want to print some images according to a variable being changed in a loop: if variable group is 1, then the image should not be printed. But if the value of group is 2, then the image should be ...
1
vote
0answers
45 views

Produce multiple documents using a loop in LaTex

I want to produce multiple documents in LaTeX. There is a list of values for every document that should be created, in the example it´s \mylist. My first approach was to use the \foreach function to ...
11
votes
3answers
584 views

Repeat characters n times

I wanted to create a new command, which allows me to repeat any characters I want for n times. After some searching and trying, I came up with this: \usepackage{multido} \newcommand{\myrepeat}[2]{% ...
3
votes
2answers
123 views

Writing a recursive matrix pattern

Consider the following matrix \begin{equation} \begin{pmatrix} B_{0,0} & B_{0,1} \\ B_{1,0} & B_{1,1} \end{pmatrix} \end{equation} The next matrix in the iteration is going to ...
2
votes
3answers
110 views

Loop, compare to macro value in condition and multiple macros if true

I seem to be stuck and for now am trying my luck through trial and error to find the right way to do this. Here is a general idea: % I DECLARE NEW MACROS WITH NAMES AS DEFFINITION. AND ASIGN LETTERS ...
2
votes
1answer
33 views

Double for loop with nested for loop dependant on outer

I would like to iterate over an array and then use the current value of the iterator as an argument to the next for loop. So far my code looks as follows but I can't get the syntax correct. \foreach ...
4
votes
1answer
61 views

How to call a command in a loop?

there is a code \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage[english,russian]{babel} \makeatletter \newcommand*{\dothis}[1]{% \stringcases {#1}% {% {a}{so you typed a}% {b}{now ...
2
votes
1answer
53 views

Forloop with tikz-cd

I am trying to write a macro that (for now) takes as input a number n, and outputs a tikz-cd diagram consisting of n consecutive arrows. However the following code leads to an error: You can't ...
3
votes
2answers
115 views

Why does a loop fail to repeat when filling longtable contents?

The following works: \documentclass{article} \usepackage{longtable} \begin{document} \newcount\n \n=0 \begin{longtable}{ccc} \loop \ifnum\n<10 \advance\n by1 hello \repeat \end{...
2
votes
2answers
69 views

How to indent for loop

I would like to write the following pseudo code : data_points.foreach { point => for(i <- point.size()) { do something.... } } But when I try to use \For \EndFor I loose ...
2
votes
3answers
61 views

includegraphics with leading zero in for loop

I would like to include graphics which have a filename with leading zeros. The filenames are: pic_001_test.png pic_002_test.png . . . pic_028_test.png I'm able to output leading zeros in a \...
3
votes
1answer
39 views

Tex csname index off by one inside loop

I'm trying to write a write a simple implementation of a list of notation (more as a technical exercise than for actual use). I've run into a rather strange issue with numberings. The following is my ...
13
votes
3answers
3k views

varioref: \vref or \vpageref at page boundary (may loop)

Sometimes a have situations, where I'm not able to compile a document, because the varioref package result in a loop. Here is a MWE, which result not in an endless loop, but it demonstrate the issue (...
0
votes
0answers
45 views

Variable font size of a text string

I was wondering if it is possible to use \fontsize{<size>}{<line space>} in a loop in order to create a text string of strictly decreasing/increasing font size from, say, 30 to 2. Surely ...
3
votes
1answer
57 views

Import several parts of file at once

As a follow up to this Question Situation I would like to create an excerpt from a script that I have TeX'ed as a compendium of the most important statements (theorems & definitions). I seek ...
4
votes
3answers
79 views

How to use loop with arc in tikz appropriately?

This is my code, as you can see it is pretty simple. But I know it can be written way more easily with the appropriate use of \for. Unfortunately, I am still learning and can't seem to make it work ...
3
votes
1answer
44 views

TeX \@for loop within a section title

I am creating a macro for turning a list of files into a comma-separated list of monospaced file names, and using it as a heading. I have written a short script for doing so: MWE: \documentclass[...
3
votes
2answers
54 views

write tokens to external files / loop unless ifeof does not work for me

I'm trying to write lines including tokens to an external file and read them again in a different document. I face two prolblems: (1) Is there a way around the ugly \unexpanded{} when calling my \...
2
votes
1answer
45 views

Tabbing environment with automatic tab stops

I'm attempting to define a custom tabbing environment which allows me to align subsequent lines of text with elements in a previously generated block which cannot be inside the tabbing environment. ...
4
votes
1answer
77 views

Create Tabular from comma separated parameter list

I tried to find an answer to this but currently I have no idea how to get it to work. I want to create a new command which fills some lines of a tabular based on a given list with variable length ...
2
votes
2answers
41 views

Document with a given number of pages

I would like to create a calligraphy practice book filled with dotted lines but with a given number of pages i.e. 16 or 32 or 64. Any suggestions? \documentclass[a4paper]{article} \usepackage{...
8
votes
2answers
246 views

Foreach loop inside the Tikz picture - Creation of memory cards using Tikz

This question regards creating a memory game using Tikz.I would like to ask for help with creating a loop that will place memory cards on the page. There are many standards, I believe, but let us ...
1
vote
0answers
37 views

How we use while loop in latex to input multiple files in main document

I am trying to input multiple files from different directories in my main LaTeX document and I want to use while loop to do that so that all .tex files can be read from a directory. Please give your ...
4
votes
3answers
149 views

Tikz: deal with exceptions within loops

I am a fan of \foreach loops in tikz, but often find myself in a situation where I want to make an exception for a single iteration of the loop. For example, \documentclass{article} \usepackage{...
1
vote
0answers
30 views

Loops within tikz calendar library

(this post is related to this one) Consider the following MWE: \documentclass{report} \usepackage{tikz} \usetikzlibrary{calendar} \newcommand*{\holidays}[1]{% \def\@holidays{#1}% } \holidays{} \...
4
votes
2answers
172 views

Printing Solutions on Different Page

I have the following source code that generates random questions regarding conversions from Arabic to Roman Numerals. I would like the solutions to be printed on a new page after the exercises end. I ...
3
votes
1answer
74 views

Is there any way to draw the same shapes at different positions efficiently, for example \foreach?

I know there is a similar question, but I do not think it gave the best solution. Here is my code: \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \clip(-0.5,-1) ...
6
votes
1answer
54 views

Generate barcodes with a for loop

I want to create labels with barcodes. The individual barcodes should be a sequence of numbers which identify objects. After some trial and error, the GS1 package seemed to work for me. Since I have ...
4
votes
4answers
174 views

Expandable macro with loops and advanced string functions?

This might be a very basic problem (as a follow-up to this question) but I cannot figure out how to do it: I need a macro \mycmd{sometext} that yields a string depending on the first character of its ...
1
vote
1answer
32 views

Defining newtheorems using loops

I would like to define Theorem x.y say x,y are integers between 1 and 20. Then, I need to write 400 sentences like \newtheorem*{theorem1.1}{Theorem 1.1}. EDIT: I'm typping some old book in a ...
3
votes
2answers
340 views

How can I create copies of a document with a running number?

I am making a questionnaire, to be filled out with pen and paper. I need 40 copies of it, with around 13 pages each. I expect that some participants might take the questionnaire apart, so I have to be ...
3
votes
2answers
48 views

Error in foreach loop when number range defined with a macro

I am having problems to implement a loop that runs over the months of the year and the days of each month. A simple representative example of my current approach is shown below. \documentclass{...
5
votes
3answers
172 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 ...
15
votes
4answers
437 views

Preparing a special exam sheet for every student

I am wondering if there is a way to read the data from an excel file and then somehow using a forloop outside a tabular, get a special exam sheet for each student. Until now, we have been using a ...
2
votes
1answer
43 views

How to print all the picture in the root directory?

I have many pictures in the root directory like this: I want print all of them in .pdf files. It is too effortless to do it one by one. How to do it efficiently. Thank you!