[pstricks] How to use linecolor in text

Herbert Voss Herbert.Voss at fu-berlin.de
Mon Apr 9 21:02:10 CEST 2018



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
> 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/20180409/d0ecc038/attachment.html>


More information about the PSTricks mailing list