Tag Info

Hot answers tagged

9

I think the problem arises because when the sprial changes direction two squares are drawn at each corner. For example, if the spiral is moving right, when the x < x_max condition is not met the direction is changed but the y coordinate is not moved up so the next square is drawn in the same place as the last square. I've corrected this in the code below ...


7

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

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 = ...


2

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 ...



Only top voted, non community-wiki answers of a minimum length are eligible