<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="" style="word-wrap:break-word">I am trying to use the package ifthen (perhaps with some arithmetic package—calc?) to do the following:
<div class="">I have an array of vertices Vij, where i denotes a “level” and each level has N vertices, numbered by j. I have two macros that create edges between vertices at level i and level i+1:</div>
<div class=""><br class="">
</div>
<div class="">the first, \stay{i}{i+1}{j}, joins edge Vij to edge V(i+1)j (i.e., joins corresponding vertices at successive levels);</div>
<div class="">since I wasn’t sure how to internally compute i+1 from i, I just input both by hand:</div>
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div class="">\newcommand{\stay}[3]{\ncline{V#1#3}{V#2#3}}%</div>
<div class="">%<span class="x_Apple-tab-span" style="white-space:pre"> </span>Usage: [V13,V23]: 2=1+1, and join position 3 at level 1 to itself</div>
</blockquote>
<div class="">
<div class=""> </div>
</div>
<div class="">the second, \cross{i}{i+1}{j}{j'}, connects Vij to V{i+1}j' and Vij' to V{i+1}j, with the first edge crossing over the second. The intention is that j and j’ are adjacent, but again I didn’t know how to compute j+1 from j internally, either,
so I put them all in by hand:</div>
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div class="">\newcommand{\cross}[4]{</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>\ncline{V#1#4}{V#2#3}</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>\ncline[border=2 pt]{V#1#3}{V#2#4}</div>
<div class="">}<span class="x_Apple-tab-span" style="white-space:pre"> </span>%Usage: [V13,V24] crosses over [V14,V23]--ie,2=1+1, and cross 3 to 4 (over)</div>
</blockquote>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class=""><br class="">
</div>
<div class="">This is to be a braid diagram, so I want at each level to introduce a single crossing, and “stay” in all other positions.</div>
<div class="">So I tried to create a macro \Tp{N}{I}{J} which at level I introduces a crossing [VIJ,V(I+1)(J+1)] over [VI(J+1),V(i+1)J].</div>
<div class="">(N is the number of vertices at each level.</div>
<div class="">For example, the intention is that \Tp{5}{1}{3} is equivalent to </div>
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div class="">\stay{1}{2}{1}</div>
<div class="">\stay{1}{2}{2}</div>
<div class="">\cross{1}{2}{3}{4}</div>
<div class="">\stay{1}{2}{5}</div>
</blockquote>
</div>
<div class="">
<div class=""><br class="">
</div>
</div>
<div class="">(vertices 1,2 and 5 at level 1 join vertices 1,2 and 5 at level 2, respectively, while 3 and 4 at level 1 join 4 and 3, respectively, at level 2, left over right).</div>
<div class=""><br class="">
</div>
<div class="">I *think* I got the logical part right in the following definition, but I haven’t figured out how to do the calculations I want internally—I simply put them in using naive notation:</div>
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div class="">\newcommand{\Tp[3]{\multido{\ii=1+1}{#1}{</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>\ifthenelse{\(\ii<#3}\) \or \(\ii>1+#3\)}</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>{\stay{#3}{#1+#3}{#2}}</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>{\ifthenelse{\ii=#3}{\cross{#2}{1+#2}{#3}{1+#3}} {}</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>}</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>}</div>
<div class="">}%Usage:\Tp{N}{i}{j} joins vertices at level i, other than Vj and V(j+1), to the corresponding vertices at level (i+1), and joins Vj (resp V(j+1)) at level i to V(j+1) (resp Vj) at level (i+1), with a positive overcrossing</div>
</blockquote>
</div>
<div class=""><br class="">
</div>
<div class="">Running the attached (which uses these definitions) gives me an error, </div>
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco">
./BraidPictureTest copy.tex:33: Illegal parameter number in definition of \rese</div>
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco">
rved@a.</div>
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco">
<to be read again> </div>
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco">
1</div>
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco">
l.33 }</div>
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco">
%Usage:\Tp{N}{i}{j} joins vertices at level i, other than Vj and V(j+1...</div>
<div class="" style="margin:0px; font-size:10px; line-height:normal; font-family:Monaco; min-height:14px">
<br class="">
</div>
</blockquote>
<br class="">
</div>
<div class="">while commenting out “\Tp{5}{1}{3}” and uncommenting the four lines that follow (which should constitute what \Tp{5}{1}{3} should accomplish) works fine.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Any suggestions? I am not sure even how to find the right documentation to correct this.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""></div>
</div>
</div>
<div style="word-wrap:break-word">
<div>
<div></div>
</div>
</div>
<div class="" style="word-wrap:break-word">
<div class="">
<div class=""></div>
<div class=""><span class="x_Apple-style-span" style="border-collapse:separate; line-height:normal; border-spacing:0px"><span class="x_Apple-style-span" style="border-collapse:separate; color:rgb(0,0,0); font-family:Helvetica; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<div class="" style="word-wrap:break-word"><span class="x_Apple-style-span" style="border-collapse:separate; color:rgb(0,0,0); font-family:Helvetica; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<div class="" style="word-wrap:break-word">
<div class="">
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica"><br class="x_Apple-interchange-newline">
Zbigniew Nitecki</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">Department of Mathematics</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">Tufts University</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">Medford, MA 02155</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font:normal normal normal 12px/normal Helvetica; min-height:14px; font-size:12px">
<br class="">
</div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">telephones:</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">Office<span class="x_Apple-converted-tab"> </span>(617)627-3843</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">Dept.<span class="x_Apple-converted-tab"> </span>(617)627-3234</font></div>
<div class="" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; font-size:12px">
<font face="Helvetica" size="3" class="" style="font:normal normal normal 12px/normal Helvetica">Dept. fax<span class="x_Apple-converted-tab"> </span>(617)627-3966</font></div>
<span class="x_Apple-style-span" style="font-size:12px"><a href="http://www.tufts.edu/~znitecki/" class="">http://www.tufts.edu/~znitecki/</a></span></div>
</div>
</span><br class="x_Apple-interchange-newline">
</div>
</span><br class="x_Apple-interchange-newline">
</span><br class="x_Apple-interchange-newline">
</div>
<br class="">
</div>
</div>
</body>
</html>