[pstricks] How to use linecolor in text

Patrice MEGRET Patrice.MEGRET at umons.ac.be
Tue Apr 10 07:25:50 CEST 2018


Dear Herbert,

Wonderful as usual.

Many thanks.

Patrice




De : PSTricks [mailto:pstricks-bounces at tug.org] De la part de Herbert Voss
Envoyé : lundi 9 avril 2018 21:02
À : pstricks at tug.org
Objet : Re: [pstricks] How to use linecolor in text




Am 09.04.2018 um 11:01 schrieb Patrice MEGRET:

I need to draw an alpha decay as a line from point (N,Z) to point (N-2,Z-2) with N=A-Z
To avoid typing all the coordinates, I use a pstricks object and a \pcline in such a way that I have just to give (A,Z) of the atom  and get the correct line taking into account the option [] and the arrows {}.
I have added \naput{#3} to add a text on the line.


\documentclass{report}
\usepackage{pst-node}

\makeatletter
\def\setTextColor#1#2#3#4\@nil{\definecolor{pmAlpDecay}#4}
%% the following commands work like \pcline with the optional argument [] and arrows {}
% \pmAlpDecay[opt]{arrows}(A,Z){text} draw alpha decay line from (A,Z)
% #1 = A
% #2 = Z
% #3 = text
\def\pmAlpDecay{\pst at object{pmAlpDecay}}
\def\pmAlpDecay at i{\pst at getarrows{\pmAlpDecay at ii}}
\def\pmAlpDecay at ii(#1,#2)#3{%
    \begin at OpenObj
    \expandafter\setTextColor\pslinecolor\@nil
    \pcline(! #1 #2 sub #2)(! #1 #2 sub 2 sub  #2 2 sub)%
    \naput{\textcolor{pmAlpDecay}{#3}}%
    \end at OpenObj}
\makeatother

\begin{document}
\begin{pspicture}(5,5)
\pmAlpDecay[linecolor=red]{->}(2,3){text}
\end{pspicture}

\end{document}


Herbert



%% the following commands work like \pcline with the optional argument [] and arrows {}
% \pmAlpDecay[opt]{arrows}(A,Z){text} draw alpha decay line from (A,Z)
% #1 = A
% #2 = Z
% #3 = text
\def\pmAlpDecay{\pst at object{pmAlpDecay}}
\def\pmAlpDecay at i{\pst at getarrows{\pmAlpDecay at ii}}
\def\pmAlpDecay at ii(#1,#2)#3{%
               \begin at OpenObj%
               \pcline(! #1 #2 sub #2)(! #1 #2 sub 2 sub  #2 2 sub)%
               \naput{#3}
\end at OpenObj}

It works well but I would like to put the text in the same color as linecolor by a command like \naput{\textcolor{\pslinecolor}{#3}} but  of course this is too simple to work. Is there a way to transform \pslinecolor in something that can be uses by \textcolor or should I do it directly at the postcscript level.

Best regards,
Patrice





_______________________________________________

PSTricks mailing list

PSTricks at tug.org<mailto:PSTricks at tug.org>

http://tug.org/mailman/listinfo/pstricks

archive: http://www.tug.org/pipermail/pstricks/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20180410/f468d0cd/attachment.html>


More information about the PSTricks mailing list