我有以下代码:
\begin{pspicture}(-1,-1)(2,2)
\psmatrix[rowsep=3cm,colsep=3cm,mnode=circle]
[name=A]A & [name=B]B
\endpsmatrix
\ncarc[arcangle=30]{A}{B} \naput{4}
\ncarc[liftpen=2,arcangle=30]{B}{A}\naput{5}
\end{pspicture}
我如何填充 4 和 5 之间的中心部分?向各个弧线添加填充不会产生正确的结果。
答案1
\documentclass{article}
\usepackage{pst-node}
\begin{document}
\begin{pspicture}(-1,-2)(4,3)
\pnodes(0,0){A}(3,0){B}
\psset{arcangle=30}
\pscustom[fillstyle=solid,fillcolor=black!20,linestyle=none]{
\ncarc{A}{B}\ncarc{B}{A}
}
\pcarc(A)(B)\naput{4} \pcarc(B)(A)\naput{5}
\cnodeput[fillstyle=solid,fillcolor=white](A){A}{A}
\cnodeput[fillstyle=solid,fillcolor=white](B){B}{B}
\end{pspicture}
\end{document}
答案2
您可以添加一个\pscustom
命令:
\documentclass[x11names]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ebgaramond}
\usepackage{array}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\psset{unit = 2,dotsize = 2.5pt}
\begin{document}
\begin{pspicture}(-1,-1)(2,2)
\psmatrix[rowsep=3cm,colsep=3cm,mnode=circle]
[name=A]A & [name=B]B
\endpsmatrix
\ncarc[arcangle=30]{A}{B} \naput{4}
\ncarc[liftpen=2,arcangle=30]{B}{A}\naput{5}
\pscustom[fillstyle =solid, fillcolor=Thistle3!30]{\ncarc[arcangle=30]{A}{B}\psarc(B){0.137}{150}{212}
\ncarc[arcangle=30]{B}{A}\psarc(A){0.145}{-30}{32}}
\end{pspicture}
\end{document}
答案3
我将首先绘制圆弧填充(使用\pscustom
),然后叠加两个端点圆,每个圆都有白色填充以去除圆弧填充的端点:
\documentclass{article}
\usepackage{pst-node}
\begin{document}
\begin{pspicture}
\pnode(0,0){A}% Identify node A
\pnode(3cm,0){B}% Identify node B
\ncarc[arcangle=30]{A}{B}\naput{4}% Place arc labels
\ncarc[arcangle=30]{B}{A}\naput{5}
\pscustom[fillstyle=solid, fillcolor=black!10]{
\ncarc[arcangle=30]{A}{B}% Place arcs and fill
\ncarc[arcangle=30]{B}{A}
}
\pscircle[fillcolor=white,fillstyle=solid](A){3mm}% Place circles
\pscircle[fillcolor=white,fillstyle=solid](B){3mm}
\rput(A){A}\rput(B){B}% Place circle labels
\end{pspicture}
\end{document}