[PSTricks] yet another matrix node definition

Christophe Broult christophe.broult at info.unicaen.fr
Sat May 23 17:59:28 CEST 1998


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------


Hello,

I'd like to define a new kind of matrix node. The problem is that the
text should not be typesetted before being passed to the node
command. I guess the following code should clarify what I want to
obtain.

Thank you for your attention,

Chris


\documentclass{article}

\usepackage{pst-node}

\begin{document}

\makeatletter
\newcommand{\NewIdea}[2]{\@namedef{Idea@#1}{\psframebox{#2}}}
\newcommand{\NewMainIdea}[2]{%
  \@namedef{Idea@#1}{\psframebox[doubleline=true]{#2}}}
\newcommand{\UseIdea}[1]{\rnode{#1}{\@nameuse{Idea@#1}}}
\makeatother

The following works
\NewIdea{foo}{foo idea}
\NewMainIdea{bar}{bar is formatted differently}
\begin{psmatrix}
  \UseIdea{foo} & \UseIdea{bar}
\end{psmatrix}
\ncline{foo}{bar}
but I'd like to be able to define a new node type with something like
the code included at the end of this message (I can't figure out how
to do it myself) and write:

\begin{verbatim}
\MatrixNodeDefinitionWithCmd{UseIdea}{\UseIdea}
\begin{psmatrix}[mnode=UseIdea]
  foo & bar
\end{psmatrix}
\ncline{foo}{bar}
\end{verbatim}

To avoid possible name clashes, I'm defining the commands in their own
name space. That's why I don't want to define the commands
\verb+\foo+, \verb+\bar+ with something like

\makeatletter
\renewcommand{\NewIdea}[2]{\@namedef{#1}{\rnode{#1}{\psframebox{#2}}}}
\renewcommand{\NewMainIdea}[2]{%
  \@namedef{#1}{\rnode{#1}{\psframebox[doubleline=true]{#2}}}}
\NewIdea{foo}{foo idea}
\NewMainIdea{bar}{bar is formatted differently}
\makeatother

and write:

\begin{psmatrix}
  \foo & \bar
\end{psmatrix}
\ncline{foo}{bar}

Thank you,

Chris

\end{document}

%% Code provided by Denis Girou last summer

\makeatletter

% To define personal nodes for the psmatrix environment
% Denis Girou <Denis.Girou at idris.fr> - Aug. 1, 1997
\def\MatrixNodeDefinition#1#2#3{%
% #1=type of node name, #2=macro to apply to the node contents, #3=parameters
% Ex: \MatrixNodeDefinition{MyNodeType}{psframebox}{linecolor=red}
\expandafter\def\csname mnode@#1\endcsname{%
% Modification of \Rnode at ii
\def\Rnode at ii{%
% DG modification begin - Aug. 1, 1997
\setbox\pst at hbox=\hbox{\ifx#3\@empty\else\psset{#3}\fi\csname #2 at ii\endcsname}
% DG modification end
\use at par
\pst at dima=\psk at href\wd\pst at hbox
\advance\pst at dima\wd\pst at hbox
\divide\pst at dima 2
\pssetlength\pst at dimb{\psk at vref}}
\rnode at iii\Rnode at ii{\psm at thenode}}}

% For more sophisticated definitions, we must used low level macro definitions
\def\mnode at MyNodeTypeD{%
% Modification of \Rnode at ii
\def\Rnode at ii{%
% DG modification begin - Aug. 1, 1997
\setbox\pst at hbox=\hbox{\pscirclebox at ii}%
\setbox\pst at hbox=\hbox{\psset{linecolor=red,framesep=0}\pstribox at ii}%
\setbox\pst at hbox=\hbox{\psset{linecolor=yellow,framesep=0}\psframebox at ii}
% DG modification end
\use at par
\pst at dima=\psk at href\wd\pst at hbox
\advance\pst at dima\wd\pst at hbox
\divide\pst at dima 2
\pssetlength\pst at dimb{\psk at vref}}
\rnode at iii\Rnode at ii{\psm at thenode}}

\makeatother


-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list