Questions tagged [for-loop]
The for-loop tag has no usage guidance.
35
questions
2
votes
2
answers
158
views
How to use loop for creating defined number of newcommands counting authors
For my template I want to create possibility to define a number of authors and automatically create a respective number of variables/commands which save the name of any author and make it able to ...
2
votes
1
answer
39
views
Writing a for loop that iterates through filenames in a text file
I would like to create beamer slides where each slide contains an image. I have a file that contains a list of all the image locations.
This is my code:
\documentclass{beamer}
% Import necessary ...
0
votes
1
answer
66
views
Parallel looping through multiple arrays
I do not know what is wrong with my code. The error message
Package PGF Math Error: Unknown function `red' (in '{ red,green,blue,purple
occurs during compiling this code:
\documentclass{article}
\...
3
votes
4
answers
344
views
Using loop in newcommand to build longer equal sign
Following Is there a wider equal sign? and "For loop" in newcommand, I have come up with the naive command:
\newcount\tmp
\newcommand{\eqlong}[1][2]{% need this to prevent extra vertical ...
1
vote
1
answer
261
views
Help with looping through a folder to insert all images within
I have a folder within overleaf of images, which I'd like to include as figures in the document.
However, I'm having some trouble with calling the "for" loop. May I ask for some assistance ...
2
votes
1
answer
45
views
Nodes anchors in foreach loop
I need to change the anchor of a node depending on the sign. For example, if the sign is "-", then the anchor is "north", otherwise "south". To do this, I implemented the ...
0
votes
1
answer
142
views
Part 2: Custom Tags and Questions in Exam Class
This is an expansion of the problem I posted, which @John Kormylo has provided a solution for.
https://tex.stackexchange.com/questions/640726/create-custom-tags-for-questions-in-exam-class
Here is ...
4
votes
2
answers
133
views
Dynamic number interval conversion table
I am a teacher and I need to use for all of my exams a table converting intervals of so called "value points" to points comprised between 0 and 20. I use the following table:
\documentclass[...
2
votes
1
answer
135
views
Create table with for loop (\Numpoint loops) and formula
Im trying to get a table added to my exam tex file that shows the grade earned based on all possible amounts of scorable points.
I am running intwo two issues:
The amount of \numpoints of the {exam} ...
6
votes
2
answers
539
views
Why doesn't this \foreach work?
I don't understand why this doesn't work. I changed x to y and z but it didn't work. Any ideas?
\documentclass[11pt]{article}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\begin{...
1
vote
1
answer
413
views
How to procedually set column type in pgfplotstable for each column individually?
For a project I am working on, I would like to write a wrapper macro \fancyTable, which communicates with pgfplotstable in the background. The user should be able to specify the column alignment as a ...
5
votes
2
answers
248
views
Concatenate a variable with a string in a loop
I want to use subfile within a loop to add new pages to a document, depending on the number of lines in a .txt file. The .txt may look like this:
000100020003
The .tex Subfiles are A0001.tex, A0002....
1
vote
1
answer
61
views
How to use a loop for labels on line graphs in pgfplots
I want to do a graph like below. Showing the duration of an intervention in a country.
generated by this code:
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
xticklabel={\day/\month}...
1
vote
1
answer
485
views
Updating R Counter in for loop
I have written a for loop in LaTeX using the forloop package, and on each iteration, I would like to use a different subset of a vector that is defined in an R chunk above. However, each iteration of ...
2
votes
2
answers
99
views
Braces in a \@for loop
While writing macros to manipulate the items of a list with a
\@for loop, I have found that braced items behave differently depending on whether they have a leading space or not:
\documentclass{...
0
votes
0
answers
47
views
For loop in tabular with multicolumn
Can I do this without adding a new line and then remove the new line? I would like to skip \\[-0.4cm]. It just feels wrong
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\...
1
vote
2
answers
43
views
Looking up strings by an index [closed]
I'm using \pgfplotsinvokeforeach{0,1,2} {...} and would like to somehow dispatch on #1 to get one of three strings:
$s_A$ if #1 == 0
$s_B$ if #1 == 1
$s_C$ if #1 == 2
Is there an easy way to do ...
1
vote
2
answers
884
views
How to include many images with a for-loop?
I would like to add many images to my document. The images are located in a folder named ./assets/images/ and are numbered as follows 0.png, 1.png, ..., 100.png. How can I include them using a for-...
4
votes
2
answers
255
views
Scan characters in a string
What I want to do is take some input string, process each character or "token" individually, and output something based on what said character/token is. Is there a way to do this? Perhaps it ...
4
votes
3
answers
381
views
parallel iteration over elements of separate lists
I guess this is a simple problem, but I don't know how to do it in TeX/LaTeX/tikz. What I'd like to do is to iterate over several lists in parallel, and do something with the respective values. One of ...
4
votes
3
answers
731
views
Read file contents to variable and iterate over each character in file (hexdump)
I need to read file content as string (binary file) to variable, then iterate over each character in that string, convert each character to its hexadecimal representation, use comma (or any other ...
2
votes
1
answer
221
views
algorithm Logic: Make Loop for each 3 rows in datatools
i want to make loop with process:
Current: (with below code)
each row create one page
Box A, B, C: Same data from one row of datatool
Need update:
Create one page only \Break=break or each 3 ...
6
votes
1
answer
278
views
How to write a loop to reflect a path (Asymptote)?
I am trying to shorten a code that contains a lot of reflections by writing a loop:
[asy]
unitsize(1.5 cm);
pair A,B,C;
real alpha=(20);
real beta=(10);
real gamma=(180-alpha-beta);
real rad=(pi/180)...
2
votes
1
answer
846
views
How to put texts on a newline in an algorithm (in a nested for-loop)?
I am making an algorithm with a nested for loop, and there are multiple in the loop. They are presented on the same line, but I want them to start on a newline. Any ideas how I can do this?
This is ...
1
vote
1
answer
335
views
Adding additional text to some elements of a loop?
The following question stinks a bit of crazed micro-optimization. But I had written it, and I was a bit curious, so I thought I might as well post it.
The following loop iterates over inserting some ...
0
votes
1
answer
139
views
Looping for Two-column Signature Blocks
I'm trying to create a two-column area for signatures, so folks signing the document are listed in the left column or right column, and there are enough rows to accommodate everyone's signature. Under ...
1
vote
1
answer
188
views
The construction of Rooty helix, code explanation
Could someone please explain some parts of this code? I'm newbie on LaTeX and could not understand some parts.
What does this \foreach \y in {86,38,15} means?
Could you explain with details what is ...
2
votes
2
answers
162
views
Why does this document add empty pages?
I have this document and it adds ONE empty page at the beginning and TWO empty pages at the end - why is that and how can I get rid of those?
So, instead of only 2 pages, I end up with 5!
\...
2
votes
1
answer
334
views
\ForEach fails with underscores
For the automatic generation of reports I'm using the \ForEach loop of the forarray package.
This is just great as it saves me lots of time.
However, there is one issue: When the items I iterate ...
0
votes
1
answer
117
views
\DTLfetch not working with Variable
I have csv database loaded in data variable.
I am trying to fetch value from particular column given an another column name and its value.
I am using following code
\forloop{i}{1}{\value{i} < 30}
{...
1
vote
1
answer
636
views
\forloop problem(undefined control sequence)
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/...
1
vote
1
answer
328
views
How to put bengali serial no on making empty table using for loop?
\documentclass{article}
\usepackage{forloop}
\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{bengali}
\setmainlanguage{bengali}
\setotherlanguage{english}
\newfontfamily\bengalifont[...
1
vote
1
answer
47
views
Repetition inside tabular
Are there any simple way to perform repetition inside a tabular environment?
This is what I intended to do:
\documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\...
5
votes
3
answers
1k
views
etoolbox for loop over range
Is there a way to run a command on a range of consecutive integers (say, 11, 12, 13, 14, 15), specifying only the first and last numbers (11 and 15)? Basically I'm looking for the general LaTeX ...
3
votes
2
answers
157
views
Narrowing a minus sign in math mode (allowable in for loop)
I want to fit the "N-1" into the box below if possible; if I use the solution \text{-}, namely 3/{N\text{-}1}, it gives me an error: Undefined control sequence: } (followed by: )
Is there a way to ...