# [OS X TeX] Optional arguments

Nitecki, Zbigniew H. Zbigniew.Nitecki at tufts.edu
Sat Jun 18 22:15:15 CEST 2016

I have used optional arguments before, but am stumped concerning my error here.  I am trying to draw edges in a braid diagram which are colored according to different criteria.  The initial setup is a psmatrix which has vertices labelled Vmn;  m denotes the “level” (not necessarily the row number in the matrix) and n is the “strand” number (the graph is such that except for the initial and final levels every vertex has one incoming and one outgoing edge, so that it is a union of disjoint edge paths—each such path is a “strand”).

The basic edge-drawing macro joins the vertex Vmn to V(m+1)n via \cross{m}{m+1}{n}:
> \newcommand{\cross}[3]{\ncline{V#1#3}{V#2#3}}%#1=level, #2=#1+1, #3=strand
To get over-and under-crossings I designate the overcrossing edge last, and use the above with a border added:
> \newcommand{\ocross}[3]{\ncline[border=3pt]{V#1#3}{V#2#3}}%overcross (same data).

These commands produce black edges.  However, sometimes I want to color each strand a different color.
The following allows the color to be automatically determined by the strand number:
>
> \def\strandcolor#1{%
>        \ifcase#1 %
>                \or lightblue%
>                        \or red%
>                                \or blue%
>                                        \or purple%
>                                                \or green%
>        \fi}
>
However, when I have several braid diagrams in the same picture, I may want some correlation between the colors of strands in one braid diagram and another.  So I have the general purpose colored edge drawing macros (essentially the two defined above with added data on line color):
> \newcommand{\ColoredEdge}[4][black]{\ncline[linecolor=#1]{V#2#4}{V#3#4}}%Basic colored edge: #1=color, #2= start level, #3=end level, #4=vertices
>
> \newcommand{\ColoredOverEdge}[4][black]{\ncline[linecolor=#1, border=3pt]{V#2#4}{V#3#4}}%Colored Overcross Edge: #1=color, #2= start level, #3=end level, #4=vertices.  This should follow any undercross.
>
If I have one braid diagram, then the following color its edges automatically according to strand number:
> \newcommand{\ccross}[3]{\ColoredOverEdge[\strandcolor{#3}]{#1}{#2}{#3}}%#1=level, #2=#1+1, #3=strand=color(automatic via strandcolor)
> \newcommand{\cocross}[3]{\ColoredEdge[\strandcolor{#3}]{#1}{#2}{#3}}%#1=level, #2=#1+1, #3=strand=color(automatic via strand color)
whereas if I want to have two braid diagrams in the same pspicture for which correspondingly numbered strands
have the same color, I use
> \newcommand{\colcross}[4]{\ColoredEdge[\strandcolor{#4}]{#1}{#2}{#3}}%#1=level, #2=#1+1, #3=strand,#4=color
> \newcommand{\colocross}[4]{\ColoredOverEdge[\strandcolor{#4}]{#1}{#2}{#3}%overcross (same data)

(and sometimes I just specify the color “by hand”.

My problem is that I keep getting an error message when I use these definitions (earlier versions *not* using the \ColoredEdge or \ColoredOverEdge macros seemed to work fine) and I can’t find the error.  I have attached a “minimal” example which exhibits this behavior, as well as the .log file for the run:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/macostex-archives/attachments/20160618/38e63252/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BraidPictureTest4.tex
Type: application/octet-stream
Size: 3528 bytes
Desc: BraidPictureTest4.tex
URL: <http://tug.org/pipermail/macostex-archives/attachments/20160618/38e63252/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BraidPictureTest4.log
Type: application/octet-stream
Size: 33496 bytes
Desc: BraidPictureTest4.log
URL: <http://tug.org/pipermail/macostex-archives/attachments/20160618/38e63252/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