# Why the option nodesepB(A) of \psbrace for diagonal line is fail?

\documentclass[border=10pt,pstricks,12pt]{standalone}

\begin{document}
\begin{pspicture}[showgrid](4,4)
\pnode(0,0){A}
\pnode(4,4){B}
\psbrace[singleline,linestyle=dashed,ref=lC,linewidth=1pt,nodesepB=0.5cm](A)(B){Text I}
\psbrace[singleline,linestyle=dotted,ref=lC,linewidth=1pt,nodesepB=0.5cm](3,4)(0,1){Text II}
\end{pspicture}
\end{document}


Question:

Only for singleline. This is the function of PSTricks or it can be placed as Asymptote code below!

This is Asymptote code for \psbrace with option singleline. It is written base on

/radius1 \psk@braceWidthOuter def
/Length \pst@tempA \pst@tempB Pyth2 def
/Left { Length \psk@bracePos\space mul } bind def
/Right { Length Left sub } bind def


and

import graph;
import math;

size(15cm,0);
defaultpen(linewidth(1.5bp));
real xmin=0,xmax=4;
real ymin=0,ymax=4;
real dxmin=0.35;
real dxmax=dxmin;
real dymin=dxmin;
real dymax=dxmax;

xaxis(Label("$x$",position=Relative(1),align=2NE),
yaxis(Label("$y$",position=Relative(1),align=N+E),

//--
void pstLabelAB(pair A, pair B, Label L="", pen Labelcolor=currentpen,
real dis=1, real d=6, real posLabel=0.5, bool line=true,
pen fillframe=invisible, pen drawframe=invisible, real xmargin=5pt,real ymargin=5pt,
bool rot=true, filltype Fillbackground=Fill(white),
arrowbar arrow=None, arrowbar bar=None, pen sty=currentpen)
{
pair M,N;
M=A+dis/10*dir(degrees(B-A)+90);
N=B+dis/10*dir(degrees(B-A)+90);
path  h = N--M;
real rotate_angle = degrees(dir(h));
//====
frame f;
box(f,Label(L,invisible),xmargin=xmargin,ymargin=ymargin,p=invisible,filltype=Fillbackground);
label(f,L,Labelcolor,FillDraw(fillframe,drawframe));
}
//---
void psbrace(picture pic=currentpicture, pair A, pair B,
real braceWidthInner=linewidth()/5, real braceWidthOuter=linewidth()/5, real bracePos=0.5,
Label L="", pen textcolor=currentpen, real nodesepB=0, real nodesepA=0.5, real rot=0,
filltype Labelbackground=Fill(invisible),
pen p=currentpen)
{
real Length=abs(B-A), Left=bracePos*Length, Right=Length-Left;
pair A1=A+braceWidthInner*unit(B-A);
transform tr=rotate(90,A1);
pair A2=(tr*A), A3=A2+(Left-braceWidthInner-braceWidthOuter)*unit(B-A);
pair A4=A3+braceWidthOuter*unit(A2-A1);
path pathAfirst=arc(A1,braceWidthInner,degrees(A-A1),degrees(A-A1)+90),
pathAsecond=arc(A4,braceWidthOuter,degrees(A3-A4),degrees(A3-A4)-90);
draw(pathAfirst..relpoint(pathAfirst,1)--relpoint(pathAsecond,0)..pathAsecond,p);
//
pair B1=B+braceWidthInner*unit(A-B);
transform tr1=rotate(-90,B1);
pair B2=(tr1*B),B3=B2+(Right-braceWidthInner-braceWidthOuter)*unit(A-B);
pair B4=B3+braceWidthOuter*unit(A2-A1);
path pathBfirst=arc(B1,braceWidthInner,degrees(B-B1),degrees(B-B1)-90),
pathBsecond=arc(B4,braceWidthOuter,degrees(B3-B4),degrees(B3-B4)+90);
draw(pathBfirst..relpoint(pathBfirst,1)--relpoint(pathBsecond,0)..pathBsecond,p);
//-----------------------------------------
pstLabelAB(A,B,rotate(rot)*L,dis=nodesepB,posLabel=nodesepA,d=0,
xmargin=2,ymargin=2,Labelcolor=textcolor,line=false,Fillbackground=Labelbackground);
}
psbrace((0,0),(4,4),"Text I",rot=0,nodesepB=-10,textcolor=red,dashed+red);
psbrace((0,0),(4,4),"Text I",rot=90,nodesepB=-10,nodesepA=.45,textcolor=red,invisible);
psbrace((3,4),(0,1),"Text II",rot=0,nodesepB=-10,textcolor=red,dotted+blue);
psbrace((3,4),(0,1),"Text II",rot=90,nodesepB=-10,nodesepA=.4,textcolor=red,invisible);
psbrace((0,2),(4,2),"pstricks",rot=90,nodesepB=-10,textcolor=red);
psbrace((0,2),(4,2),"pstricks",rot=90,textcolor=green,invisible);
psbrace((3,0),(3,4),"$\int\limits_1^{\infty}\frac{1}{x^2}\,dx=1$",nodesepB=-8,textcolor=green,dotted);
shipout(bbox(3mm,invisible));


• what exactly do you want? If you want an asymtote solution then delete the PSTricks part! Feb 12, 2020 at 17:38
• @user187802 Excuse me! I can not.
– user197952
Feb 12, 2020 at 17:57

For braces which are not vertikal or horizontal you have to use both: nodesepA (horizontal shift) and nodesepB (vertical shift). For 45 degrees you can use nodesep:

\documentclass[border=10pt,pstricks,12pt]{standalone}

\begin{document}
\begin{pspicture}[showgrid](4,4)
\pnode(0,0){A}
\pnode(4,4){B}
\psbrace[singleline,linestyle=dashed,ref=lC,linewidth=1pt,nodesep=5mm](A)(B){Text I}
\psbrace[singleline,linestyle=dotted,ref=lC,linewidth=1pt,nodesep=-5mm](3,4)(0,1){Text II}
\end{pspicture}
\end{document}


Both is shown in the examples of the documentation.

• only have nodesepA and nodesepB; nodesep, :-(, ... in the documentation, Maybe I fail but I don't see it!
– user197952
Feb 8, 2020 at 3:41
• See package PST-Node. However, choose the same value for nodesepA/B and it will be the same Feb 8, 2020 at 6:29