# [pstricks] psmatrix, new arrow type

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sun Nov 2 10:09:18 CET 2008

Antoine Pairet schrieb:

> Basically, it uses a forloop to generate a psmatrix. Then using \ncnode
> I connect several nodes. This works pretty good. However, I'd like to
> define a new arrow type: an arrow that ends with a circle with a dot in
> its centre.
>
> \ncline{°-°}{nodeA}{nodeB} would link the 2 nodes by a line ending by
> two circles having a dot in their center.

see example

> Moreover, I'd like to have some advices concerning the definition of my
> \nonZero macro. It must put a dot on a node of the psmatrix. I uses
> \ncline[linestyle=none]{*-}{nodeA}{1,1}
> Is there a better method?

not really, but you can do \ncline[linestyle=none]{*-}{nodeA}{nodeA}

> And how about having better brackets than with my code?

do not define counters inside an environment, should be
done always outside.

Herbert

\documentclass[a4paper,10pt]{report}
\usepackage{pst-node,graphicx}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{forloop}
\usepackage{amsmath}
\newcommand\equalValue[2]{\ncline{*-*}{#1}{#2}}%
\newcommand\oppositeValue[2]{\ncline{*-o}{#1}{#2}}%
\newcommand\halfValue[2]{\ncline{#1}{#2}}%
\newcommand\halfOppositeValue[2]{%
\ncline{o-o}{#1}{#2}%
\ncput[npos=0]{\psdot[dotscale=0.5]}%
\ncput[npos=1]{\psdot[dotscale=0.5]}}
\newcommand\nonZero[1]{\ncline[linestyle=none]{*-}{#1}{#1}}%
\newcounter{identRow}%%Counters for the loop
\newcounter{identCol}%
\newcounter{endMatrix}%
\newsavebox\PBox
\newenvironment{symmatrix}[2]{%	% Macro definitions
\setcounter{endMatrix}{#1}%
\addtocounter{endMatrix}{-1}%
\psset{arrowscale=2}
\begin{lrbox}{\PBox}
\begin{psmatrix}[colsep=.5cm,rowsep=.25cm,mnode=dot,dotsize=1.5pt]%
\forloop{identRow}{0}{\value{identRow} < #1}{%
\forloop{identCol}{1}{\value{identCol} < #2}{&}%
\ifnum\theidentRow<\theendMatrix \\\fi}%
\end{psmatrix}}
{\end{lrbox}$\left(\arraycolsep=2pt% \array{c}\usebox\PBox\endarray\right)$}

\begin{document}

\begin{symmatrix}{3}{6}
\equalValue{2,3}{3,6}
\oppositeValue{2,1}{3,4}
\halfOppositeValue{2,2}{3,5}
\nonZero{2,5}
\end{symmatrix}

\end{document}


More information about the PSTricks mailing list