# Tag Info

0

Thanks to the inspiration from David's and Joseph's use of #1 as placeholder for the loop counter, I was able to improve the implementation that I've given in the question. I'll post it here mostly as a learning exercise for anyone who happens to have a similar use case. This version only expands the loop counter and leaves all other tokens alone, removing ...

3

I get the same output files with the following test.tex file: \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,fit} \usepackage[pgf]{dot2texi} \newtoks\dtttoks \begin{document} \begingroup \global\dtttoks={} \foreach \x / \y in {0/1,1/2,2/3}{ \edef\temp{a\x\space -> a\y\space [label = ...

6

There are a number of possible approaches to doing this without the complexity: I'll cover a couple using expl3. First, if you don't mind keeping things non-expandable then you could do something like \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_new_protected:Npn \For #1#2#3#4 { \int_step_inline:nnnn {#1} {#2} {#3 - 1} {#4} } ...

6

This loop just uses expansion. In order to use #1 as the loop counter it is easiest to define it anew each time, if you didn't want access to the counter you could more easily use \myrepeat{5}{some code} Note i didn't use \repeat as that name is taken in the existing \loop syntax. \documentclass{article} \def\myrepeat#1{\ifnum#1=0 ...

5

Thanks to the pointer given in the comment by Please don't touch, at Iterate through folder foreach picture, possible?, the following modifications to that MWE allow the picture range to be specified as arguments 3 and 4 to \IterateImages. The logic that allows the ranging of the inserts is given by the code: ...

3

A solution for all named colors: \documentclass[pstricks,border=12pt,dvipsnames]{standalone} \usepackage{pst-node,pst-plot} \def\R[#1,#2]{(1+3*(#2+1)/#1) AlgParser cvx exec } \newcounter{Color} \setcounter{Color}{0} \def\object#1#2#3{% \pscustom[fillstyle=solid,fillcolor=#1,linewidth=0.1pt]{% \psarc(0,0){!\R[#3,#1] }{(A#1)}{(A#2)} ...

2

The problem in your code comes from the way you use \equal. Instead of having \x\equal{#1}{true}, you should use \equal{#1}{\x}. Note that \equal is case-sensitive, and some converting should be used if you need the filename lowercased but the displayed name starting with an uppercase. The menukeys package provided by Tobi is indeed of interest in your ...

10

Here is a very simple solution: \documentclass{article} \usepackage{tikz} \def\firstlist{0,1,2} \def\secondlist{0,1,2} \newcommand{\testa}{ \foreach \x [count=\c,evaluate=\c as \y using {{\secondlist}[\c-1]}] in \firstlist { \draw(0,\x)--(1,\y); } } \begin{document} \begin{tikzpicture} \testa \end{tikzpicture} \end{document} An extended ...

7

You could always "roll your own" solution, but it would require considerable work to make it look as nice as \foreach: \documentclass[tikz,border=5]{standalone} \makeatletter \def\attxt{@} \long\def\frch#1#2#3{\long\def\frchaction##1##2{#3}% \def\lsta{}\def\lstb{}% \edef\lst{#1,@,/#2,@,}\expandafter\@frch\lst\@} \def\@frch#1,#2/#3,#4\@{% ...

10

You can count how many elements there are in one of the arrays and use that number as the foreach limit. Then every spin accesses one element of the arrays; \documentclass[tikz]{standalone} \def\firstlist{{0,1,2}} % <== Notice the double brace for array notation \def\secondlist{{0,1,2}} \newcommand{\testa}{ \pgfmathdim{\firstlist}%Get the number of ...

9

I'm not so sure you want to do it. ;-) \documentclass{article} \usepackage{xparse} \def\xforeach#1#{\xforeachaux{#1}} \ExplSyntaxOn \NewDocumentCommand{\xforeachaux}{mm} { \carlitos_xforeach:nn { #1 } { #2 } } \seq_new:N \l_carlitos_xf_first_seq \seq_new:N \l_carlitos_xf_second_seq \seq_new:N \l_carlitos_xf_list_seq \cs_new_protected:Npn ...

0

As egreg mentioned in a comment: it is well-known problem. Moderators feel free to close it as duplicate (I'd like to see the link to discussion of similar issue though). So far I stick to a workaround: generate less by one rows in \forloop and then manually add code for the last line. Concerning example given in the question the solution is as follows. ...

2

EDIT II Here is a fully functional solution. The MWE example is yours. My code puts the watermarks on pages 2,4,5,6 and 7 and adds hyperlinks back to them at the end of the document. I'll make some comments below. \documentclass{article} \usepackage[contents={Watermarked!},pages=some]{background} \usepackage[colorlinks]{hyperref} \pagenumbering{arabic} ...

Top 50 recent answers are included