Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pgffor]

The package pgffor implements the foreach module of tikz-pgf in a standalone package.

0
votes
1answer
32 views

dimension to large in pgffor

I have this error: Dimension to large. } the code is: \documentclass{report} \usepackage{pgffor} \parindent=0cm \begin{document} \foreach \n in {1,...,20000}{ Hola a todos. el numero es \n \\...
3
votes
1answer
45 views

Defining a tikz-shape for block mode diagrams

What I want to do I want to draw diagrams of operation modes of block ciphers like this one of the ECB mode. I did this before without defining shapes for particular parts of the diagram. However, ...
5
votes
2answers
266 views

Randomly choose a symbol each time the document compiles

I need to randomly change which symbol is attached to a particular command every time I compile my script. I had hoped that this would be possible using the pgffor package, as in the minimal example ...
0
votes
1answer
16 views

Looping over lists and using its elements as parameters to invoke macros

I'm trying to automatize the generation of certificates of participation for an event. I'm trying to have LaTeX iterate over a list of pairs of the form {author, talk} using pgffor like in the snippet ...
8
votes
2answers
461 views

Why does pgffor estimate that 0.1-0=0.100005 in a \foreach loop?

In the manual on page 902, it says that Normally, when a list item ... is encountered, there should already have been two list items before it, which where numbers. Examples of numbers are ...
1
vote
1answer
51 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/...
2
votes
1answer
44 views

Dynamic macro definition in a `foreach` loop

I created a command to dynamically define vector macros: \newcommand{\makevec}[1]{\expandafter\def\csname #1\endcsname{\vec{#1}}} which works as I expected. But then I tried to modify this command ...
2
votes
1answer
56 views

Building up and joining “internal” lists

How can I append to a pgfkeys-style comma-separated list? Or, alternatively, how can I define a macro to join an etoolbox list with a delimiter? For an environment I'm designing, I want to accumulate ...
3
votes
1answer
88 views

Alpha counter in a foreach loop

I need an alpha counter in a foreach loop : \documentclass{article} \usepackage{tikz} \makeatletter \newcommand{\TRAA}[1]{% % node/angle list \foreach \x/\y [count=\i from 1] in {#1} {% ...
0
votes
0answers
64 views

\csname problem

I try to pass a list of nodes and angles to a command, and I need to name them for a futur use, but I make a mystake that I don't understand. \documentclass{article} \usepackage{pgffor} \...
2
votes
1answer
54 views

Testing membership in a list

My question is similar to the one asked in ASdeL's question, except I am testing a loop variable against a predefined set. It seems that none of the solutions there are working for me because \imgidx ...
3
votes
2answers
67 views

Math line breaks in user defined macros

I have been defining a mathematic formula using NewDocumentCommand. This works well, but I do manage to get line breaks. A minimal working example can be found below. Part of the construction is ...
2
votes
2answers
326 views

What is wrong with this \foreach statement?

The code below \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} % draw two line segments \draw (0,0) node [below] {$s_i$} -- (2,0) node [...
3
votes
1answer
103 views

loop over list defined with newcommand

I try to automate generating same tables. With a \newcommand a comma separated list of filenames is defined. I want to iterate over these files, import them and concat them to a single table. Sounds ...
0
votes
1answer
91 views

How can I increase or decrease height between of two lines?

I want to draw some lines with dots and line. This is my code. \documentclass{book} \title{Multidotfills} \usepackage{pgffor} \newcommand{\foreachmultidots}[1]{\foreach \n in {1,...,#1}{\par\...
1
vote
2answers
84 views

How to access length of inner list in pgffor

I have a list of lists, and I'm using nested \foreach loops to iterate through them. By using [count=\var], I'm able to use \var to access the length of the outer loop (after I've iterated through). ...
2
votes
1answer
136 views

Accessing a list at a certain index

I want to define the following command, which is to render an arbitrary number of subfigures. The argument is a nested list: \multifig{{{fig_1, T0D0, TODO}, {fig_2, T0D0, TODO}}} Is the following ...
1
vote
1answer
63 views

Commands Macros within tabular environments -Automation

I want to create a table based on a comma separated data as follows: \documentclass{article} \usepackage{pgffor} \usepackage{multirow} \usepackage{float} \newcommand{\cases}{a , b} \newcommand{\...
1
vote
1answer
73 views

\renewcommand inside for cycle won't work

In the following MWE I'll be providing the command \asdasd, and then try to give it the definition "asdasd" through the command \renewcommand inside of a for cycle. I don't know what's going wrong ...
4
votes
2answers
113 views

infinite loop, csname and forloop function

I want to define some commands that finish with "a", "b", "c"... and totalize the number of them, how can I do this?? \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{ifthen} \...
5
votes
2answers
388 views

foreach LaTeX input file, output a PDF file

I have a bunch of tables saved in separate files and folders which I have compiled with a master file, commenting the name of each file in the master file one by one and tediously renaming the ...
3
votes
2answers
92 views

Table gets broken when in a loop

Here is the MWE: \documentclass{article} \usepackage{pgffor, geometry, tabu, booktabs} \geometry{ a4paper, portrait, margin=1in } \begin{document} Here is creating the table using a loop\\[...
2
votes
2answers
158 views

tasks environment vs. pgffor's foreach

I want to \foreach on a list and create task (via package tasks) inside a question. A MWE: \documentclass{article} \usepackage[magyar]{babel} \usepackage[utf8x]{inputenc} \usepackage{t1enc} \...
5
votes
3answers
336 views

Best way to loop over the value of a pgfkey key that is a csv list?

Using pgfkeys, suppose that I have a key whose value is a comma separated list: \pgfkeys{/a list/.initial = {1,2,3}} Question What is the correct way to iterate over this list using \foreach (from ...
5
votes
1answer
83 views

Need a second \end{choices} for exam class with pgf foreach?

I cannot figure out the reason for this weird occurrence. If I declare my exam to print answers, I get an error that ! LaTeX Error: \begin{choices} on input line 21 ended by \end{questions} ! LaTeX ...
1
vote
2answers
76 views

Value of counter from pgffor in a complex example

From this answer I learned how to print rows into 1 column table using pgffor: | 1 | | 2 | | 3 | Code looks like this: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{pgffor} \...
1
vote
1answer
54 views

How to get the value of counter in pgffor while using \expandafter

I looked into this answer and tried to improve it. My goal is to get this table: | 1 | | 2 | | 3 | But instead I get this: | 1 | | 1 | | 1 | Code: \documentclass{article} \usepackage[utf8]{...
2
votes
1answer
469 views

Foreach loop in tabular, missing endgroup inserted

I'm trying to create a table using the foreach loops made available in the pgffor package. Using the following code, I am able to generate the right contents, but not aligned properly. \begin{tabular}...
2
votes
1answer
64 views

\pgfforeachungrouped with three arguments

This is a follow-up to a previous question of mine, with a slight addition. I would like to loop over data in a file and give the plot styles as a list. In the old question I gave only a color and an ...
11
votes
1answer
665 views

foreach with colors leads to “undefined control sequence”

The following MWE works nicely when I remove the optional argument [\forcol] from the \addplotcommand or when I change it to red, for example. Though I would like the curves to have different colors ...
4
votes
2answers
82 views

Loading an array of fontfaces with fontspec and pgffor

I'm trying to produce a document to compare a bunch of fontfaces. I'd like to parse an array to load and try them all. This is what I have done: \documentclass{article} \usepackage{lipsum} \...
2
votes
4answers
165 views

Programming a step function- part2

Based on a macro given by egreg in this question: Programming a step function I obtain a program which tests in which interval is a number \alpha, between the numbers bone, btwo, bthree, bfour. I use ...
2
votes
0answers
247 views

How to use sagesilent (or verbatim) environment in pgffor loops?

I want to create different versions of an exam paper and corresponding sample solutions using sagetex. I need to assign variables for more involved computations, so I am reliant on the sagesilent ...
4
votes
1answer
498 views

How can I use \foreach in math environments?

I'm looking for a way to generate in a loop the rows of an align environment, or IEEEeqnarray or some such thing. I can see that \foreach works in math mode (inside \[ \] e.g.), but something like ...
3
votes
1answer
102 views

Using pgffor and line breaks inside math environments

Today I decided to try to typeset a humorous list enumerating all 7! valid iterated integrals for a 7-dimensional integral (It takes 361 pages in the version that does compile) but I'm running into ...
1
vote
1answer
30 views

error when using expandafter for databib command in indexing command in foreach loop

I'm trying to create an author index using the databib package (datatool) bundle. I can loop over the entries in a BibTeX database and for each entry, loop over the authors using the \foreach command ...
2
votes
1answer
122 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
1answer
269 views

Problem using macro with TikZ foreach

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

mdframed gobbles item label from description environement when \foreach is used

The following works: description in mdframed. foreach in description. but there is some strange behavior when using foreach in description in an mdframed environment in that the \item labels after ...
2
votes
1answer
109 views

How do I assess the length of text within a pgffor \foreach loop [duplicate]

I would like to be able to write something like the following: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \newlength\aelengtha \newlength\aelengthb \newlength\aelengthc \begin{...
12
votes
2answers
835 views

\foreach with \newcommand how to use them together?

What I want to do is to shorten this \newcommand with a \foreach since this is just a very little part of what I will use. \newcommand{\CC}{{\mathbb C}} % the set of complex numbers \newcommand{\NN}{...
5
votes
5answers
4k views

How can I multiply two numbers?

I use pgffor package and I have \foreach \n in {1,...,10}{**something I want**} How can I print n*(n+1) for each n? When I write just \n*(\n+1) instead of **something I want**, 1(1+1)2(2+1)3(3+1).....
6
votes
1answer
582 views

Feature (bug?) of dots notation in foreach-statement

I want to draw something in tikz where the range of an inner loop depends on an outer loop (by construction of the math involved). I need to differentiate between even and odd number in the inner loop,...
4
votes
1answer
118 views

Make catchfile work with pgffor's foreach

Consider the following MWE, extracted from my solution to this question: \begin{filecontents*}{demolist1.dat} 1,2,3 \end{filecontents*} \begin{filecontents*}{demolist2.dat} {1,0,2},{0,3},{1,1} \end{...
6
votes
1answer
658 views

Why is the `pgffor` package messing with my scope?

I have a several rather lengthy documents with numbered points (catechism questions) that I would like to be able to selectively include in other documents using a utility function that uses a range ...
4
votes
1answer
353 views

PGF foreach: elegant way to handle empty list

I am writing a simple animation in beamer using tikz. The code is as follows \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{frame}[fragile]\relax \...
5
votes
2answers
254 views

Variable in \foreach,

I would like to show you my problem. Here you have the script to generate a picture.Now I need to generate a second picture in which the arrows are not equally spaced any more. \documentclass[...
4
votes
1answer
167 views

Extract from a token containing a list with math content

I have a token which contains a list consisting of: a date in YYYY-MM-DD format, followed by a colon, and some text which may contain math. The text will consist of a sentence or two (i.e., no ...
8
votes
2answers
767 views

Error with chronology and babel packages : “! Paragraph ended before \pgffor@next was complete.” [closed]

I am trying to use the chronology package in a report that includes babel. My distribution : pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) On below my MWE : \documentclass{article} \...
11
votes
1answer
146 views

PGF's `foreach` recognises when there are no list items and doesn't run the code. Is this guaranteed?

The PGF \foreach macro behaves differently when the item list is totally empty than it does when a single item happens to be empty. \documentclass{article} \usepackage{pgffor} \begin{document} \...