# How to mimic the behavior of \ncput* but without the unwanted opaque effect?

My objective is to have a label with transparent background but any connecting curve passing through the hypothetical box of the label must be hidden.

## Opaque Label

\ncput* produces an opaque label as follows. So it does not fit into my objective.

\documentclass[pstricks,multi]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}[showgrid=false](4,4)
\pstGeonode[PosAngle={90}]
(1,1){A}
(3,3){B}
\ncarc[arcangle=-30,linestyle=dashed,linecolor=gray]{A}{B}
\ncput*[nrot=:0]{$2\sqrt2$}
\end{pspicture}

\end{document}


## Transparent Label

The following is my attempt to mimic the code above but with transparent background for the label. However, I failed to mimic the connecting curve.

\documentclass[pstricks,multi]{standalone}
\usepackage{pst-eucl}

\begin{document}

\begin{pspicture}[showgrid=false](4,4)
\pstGeonode[PosAngle={90}]
(1,1){A}
(3,3){B}
\ncarc[arcangle=-30,linestyle=none]{A}{B}
\ncput[nrot=:0]{\psDefBoxNodes{obj}{$2\sqrt2$}}
\pcarc[arcangle=-30,linestyle=dashed,linecolor=gray](A)([nodesep=3pt]{A}obj:Cl)
\pcarc[arcangle=-30,linestyle=dashed,linecolor=gray]([nodesep=3pt]{B}obj:Cr)(B)
\end{pspicture}

\end{document}


How to solve this issue?

-
I guess \ncput* was made in hurry with a hot needle. –  kiss my armpit Feb 11 '13 at 15:46
I'm a bit confused about what you're asking for. You can use ncput without the star, but you do seem to want a portion of the connecting curve occluded. Can you provide a fuller example to help see how this issue is interfering with another effect? Right now it seems you want two conflicting properties: opacity and non-transparency. –  A.Ellett Feb 11 '13 at 15:50
Or, you can use a \makebox as in  \ncput*[nrot=:0]{\makebox[1em]{$2\sqrt2$}} and not cover as much with the label. Or pair up \makebox with \raisebox. –  A.Ellett Feb 11 '13 at 15:53
@A.Ellett: Shortly speaking, how to make \ncput* produce a transparent label but hide the connecting curve inside its hypothetical frame box? –  kiss my armpit Feb 11 '13 at 15:53
pstricks hides things (like the portion of the connecting curve) by placing opaque boxes on top of each other. It doesn't simply wipe out the curve. –  A.Ellett Feb 11 '13 at 15:58

I've defined a macro for a simple quadratic bezier curve to connect two points. But, I've also added two parameters to allow you to specify the start and end of the portion of the bezier curve you want plotted.

The command is arguments are

 \mybeziercurve[options]{<t-start>}{<t-end>}{<n-start>}{<n-control>}{<n-end>}


where

t-start    is a value between 0 and 1
t-end      is a value between 0 and 1 (ideally larger than t-start)
n-start    is the first node to be connected
n-control  is a node to control the effect of the bezier curve
n-end      is the second node to be connected


There is also a command to place a point along the bezier curve

\myputnodeoncurve{<pos>}{<node-start>}{<control-node>}{<node-end>}{<new-node>}


where

pos  should be a number between 0 and 1

other parameters are as for \mybeziercurve


Please note that this implementation requires that you're using pst-eucl since I'm using pst-eucl's postscript dictionary.

# Here's a MWE

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pst-eucl}

\makeatletter
\newcommand{\@my@bezier@curve}[4]
{%
tx@EcldDict begin
%% x coordinate
1 #1 sub
1 #1 sub
/N@#2 GetNode 0 mul add     mul
#1
%--
#1
1 #1 sub
/N@#3 GetNode 0 mul add     mul
#1
\pst@number\psxunit div
%% y coordinate
1 #1 sub
1 #1 sub
/N@#2 GetNode exch 0 mul add     mul
#1
%--
#1
1 #1 sub
/N@#3 GetNode exch 0 mul add     mul
#1
\pst@number\psyunit div
end
}

\newcommand{\mybeziercurve}[6][]
{%
\def\@ParamStart{#2}%
\def\@ParamEnd{#3}%
\parametricplot[plotstyle=line,plotpoints=100,#1]
{\@ParamStart}{\@ParamEnd}{ \@my@bezier@curve{t}{#4}{#5}{#6} }
}
%% a macro to place a node on the curve for labeling purposes
\newcommand{\myputnodeoncurve}[5]
{%
\pnode( !\@my@bezier@curve{#1}{#2}{#3}{#4} ){#5}%
}
\makeatother
\pagestyle{empty}
\begin{document}

\begin{pspicture}[showgrid=false](0,0)(4,4)
\pstGeonode[PosAngle={-135,45,-45},
PointName={default,default,none},
PointSymbol={default,default,none}]
(2,1){A}
(3,3){B}
(3,1){C}

\pstRotation[RotAngle=130,PointName=none,PointSymbol=none]{A}{C}[D]
\pstTranslation[DistCoef=-1.5,PointName=none,PointSymbol=none]{C}{D}{C}[D]

\mybeziercurve[linecolor=black,linewidth=0.4pt,linestyle=dashed]{0}{0.35}{A}{D}{B}
\mybeziercurve[linecolor=black,linewidth=0.4pt,linestyle=dashed]{0.65}{1}{A}{D}{B}

\myputnodeoncurve{0.5}{A}{D}{B}{E}
\rput(E){$\sqrt{2}$}

\end{pspicture}
\end{document}


# Something which looks more like what you want

\begin{pspicture}[showgrid=false](0,0)(4,4)
\pstGeonode[PosAngle={-135,45,-45},
PointName={default,default,none},
PointSymbol={default,default,none}]
(2,1){A}
(5,5){B}
(5,1){C}
\mybeziercurve[linecolor=black,linewidth=0.4pt,linestyle=dashed]{0}{0.40}{A}{C}{B}
\mybeziercurve[linecolor=black,linewidth=0.4pt,linestyle=dashed]{0.60}{1}{A}{C}{B}

\myputnodeoncurve{0.5}{A}{C}{B}{E}
\rput(E){$\sqrt{2}$}
\end{pspicture}


Your selection of where to place the control point will allow you to better shape the curve.

%% command to get angle
\newcommand{\mygetangle}[2]
{   !
tx@EcldDict begin
/N@#1 GetNode 0 mul add sub
/N@#2 GetNode exch 0 mul add
/N@#1 GetNode exch 0 mul add sub
exch
atan
end
}


And then you can slope the label accordingly using

\begin{pspicture}[showgrid=false](0,0)(4,4)
\pstGeonode[PosAngle={-135,45,-45},
PointName={default,default,none},
PointSymbol={default,default,none}]
(2,1){A}
(5,5){B}
(5,1){C}

\mybeziercurve[linecolor=black,linewidth=0.4pt,linestyle=dashed]{0}{0.40}{A}{C}{B}
\mybeziercurve[linecolor=black,linewidth=0.4pt,linestyle=dashed]{0.60}{1}{A}{C}{B}

%% Setting points to get slope of omitted section
\myputnodeoncurve{0.40}{A}{C}{B}{E1}
\myputnodeoncurve{0.50}{A}{C}{B}{E}
\myputnodeoncurve{0.60}{A}{C}{B}{E2}
\rput{\mygetangle{E1}{E2}}(E){$\sqrt{2}$}


\end{pspicture}

-
Oh my ghost! There are 14 revisions. :-) –  kiss my armpit Feb 12 '13 at 0:51