# [OS X TeX] logical and arithmetic commands in pstricks

Nitecki, Zbigniew H. Zbigniew.Nitecki at tufts.edu
Tue Jun 14 19:33:38 CEST 2016

```I am trying to use the package ifthen (perhaps with some arithmetic package—calc?) to do the following:
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:

the first, \stay{i}{i+1}{j}, joins edge Vij to edge V(i+1)j  (i.e., joins corresponding vertices at successive levels);
since I wasn’t sure how to internally compute i+1 from i, I just input both by hand:

\newcommand{\stay}[3]{\ncline{V#1#3}{V#2#3}}%
% Usage: [V13,V23]: 2=1+1, and join position 3 at level 1 to itself

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:

\newcommand{\cross}[4]{
\ncline{V#1#4}{V#2#3}
\ncline[border=2 pt]{V#1#3}{V#2#4}
} %Usage: [V13,V24] crosses over [V14,V23]--ie,2=1+1, and cross 3 to 4 (over)

This is to be a braid diagram, so I want at each level to introduce a single crossing, and “stay” in all other positions.
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].
(N is the number of vertices at each level.
For example, the intention is that \Tp{5}{1}{3} is equivalent to

\stay{1}{2}{1}
\stay{1}{2}{2}
\cross{1}{2}{3}{4}
\stay{1}{2}{5}

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

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:

\newcommand{\Tp[3]{\multido{\ii=1+1}{#1}{
\ifthenelse{\(\ii<#3}\) \or \(\ii>1+#3\)}
{\stay{#3}{#1+#3}{#2}}
{\ifthenelse{\ii=#3}{\cross{#2}{1+#2}{#3}{1+#3}} {}
}
}
}%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

Running the attached (which uses these definitions) gives me an error,

./BraidPictureTest copy.tex:33: Illegal parameter number in definition of \rese
rved at a.
1
l.33 }
%Usage:\Tp{N}{i}{j} joins vertices at level i, other than Vj and V(j+1...

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.

Any suggestions?  I am not sure even how to find the right documentation to correct this.

Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155

telephones:
Office    (617)627-3843
Dept.    (617)627-3234
Dept. fax    (617)627-3966
http://www.tufts.edu/~znitecki/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/macostex-archives/attachments/20160614/c60f48dd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BraidPictureTest copy.tex
Type: application/octet-stream
Size: 1708 bytes
Desc: BraidPictureTest copy.tex
URL: <http://tug.org/pipermail/macostex-archives/attachments/20160614/c60f48dd/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BraidPictureTest copy.log
Type: application/octet-stream
Size: 8456 bytes
Desc: BraidPictureTest copy.log
URL: <http://tug.org/pipermail/macostex-archives/attachments/20160614/c60f48dd/attachment-0003.obj>
-------------- next part --------------
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://www.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
```