![标签 \psline 并沿箭头方向定位标签](https://linux22.com/image/375943/%E6%A0%87%E7%AD%BE%20%5Cpsline%20%E5%B9%B6%E6%B2%BF%E7%AE%AD%E5%A4%B4%E6%96%B9%E5%90%91%E5%AE%9A%E4%BD%8D%E6%A0%87%E7%AD%BE.png)
如何使用定位/定向(不会水平放置占用太多空间)在线本身上的标签来标记 \psline 实体?
梅威瑟:
\documentclass{standalone}
\usepackage{pstricks-add, pst-plot}
\usepackage{auto-pst-pdf}
\usepackage{xcolor}
\setlength\parindent{0pt}
\pagestyle{empty}
\begin{document}
\begin{pspicture}(0,0)(18,18)
\psset{linecolor=DodgerBlue4, tickcolor=white, subtickcolor=DodgerBlue4, gridcolor=DodgerBlue4, gridlabelcolor=white}%
\psset{linewidth=0.05pt, tickwidth=0.05pt, ticksize=-2pt 2pt, subticks=2, subtickwidth=0.025pt, labels=none}
\psframe[linewidth=0.05pt](0,0)(18,18)
\psset{gridwidth=0.05pt, subgriddiv=1}
\psgrid(0,0)(18,18)
% insert circles
\pscircle[fillstyle=solid,opacity=0.2, linewidth=0.1](9,9){8}
\pscircle[fillstyle=solid,fillcolor=white,opacity=0.2, linewidth=0.1](9,9){4}
\pscircle[fillstyle=solid,fillcolor=white,opacity=0.2, linewidth=0.1](12,8){4}
\pscircle[fillstyle=solid,fillcolor=lightgray,opacity=0.2, linewidth=0.1](9,6){4}
% insert arrows
\psline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=red](9,9) (12,8)
\psline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=magenta]{->}(9,9) (9,6)
\psline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=blue]{->}(12,8) (9,6)
\psline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=blue]{->}(9,9) (6.5,7)
\end{pspicture}
\end{document}
答案1
您可以添加不可见的\pcline
s,也可以使用\pcline
s 代替\psline
s。下面我说明了几种可能性。(现在有了DodgerBlue4
,非常感谢@Bernad!)
\documentclass[x11names]{standalone}
\usepackage{pstricks-add, pst-plot}
\usepackage{auto-pst-pdf}
\usepackage{xcolor}
%\definecolor{DodgerBlue4}{RGB}{3,3,192}
\setlength\parindent{0pt}
\pagestyle{empty}
\begin{document}
\begin{pspicture}(0,0)(18,18)
\psset{linecolor=DodgerBlue4, tickcolor=white, subtickcolor=DodgerBlue4, gridcolor=DodgerBlue4, gridlabelcolor=white}%
\psset{linewidth=0.05pt, tickwidth=0.05pt, ticksize=-2pt 2pt, subticks=2, subtickwidth=0.025pt, labels=none}
\psframe[linewidth=0.05pt](0,0)(18,18)
\psset{gridwidth=0.05pt, subgriddiv=1}
\psgrid(0,0)(18,18)
% insert circles
\pscircle[fillstyle=solid,opacity=0.2, linewidth=0.1](9,9){8}
\pscircle[fillstyle=solid,fillcolor=white,opacity=0.2, linewidth=0.1](9,9){4}
\pscircle[fillstyle=solid,fillcolor=white,opacity=0.2, linewidth=0.1](12,8){4}
\pscircle[fillstyle=solid,fillcolor=lightgray,opacity=0.2, linewidth=0.1](9,6){4}
% insert arrows
% method 1: insert an invisible \pcline
\psline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=red](9,9) (12,8)
\pcline[linestyle=none](9,9)(12,8)\aput{:U}{label 1}
% method 2: shorter: use \pcline instead of \psline
% note, however, that you need to remove the spaces between the coordinates then
\pcline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=magenta]{->}(9,9)(9,6)
\aput{:U}{label 2}
\pcline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=blue]{->}(12,8)(9,6)
\Aput{label 3}
\pcline[arrows=->,linewidth=2.5pt,linestyle=solid, linecolor=blue]{->}(9,9)(6.5,7)
\bput{:U}{label 4}
\end{pspicture}
\end{document}
答案2
减少击键次数:
\documentclass[x11names,pstricks]{standalone}
\usepackage{pst-node,pstricks-add}
\begin{document}
\begin{pspicture}(0,0)(18,18)
\psset{linecolor=DodgerBlue4, subtickcolor=DodgerBlue4, gridcolor=DodgerBlue4,
linewidth=0.05pt, tickwidth=0.05pt, ticksize=-2pt 2pt, subticks=2, subtickwidth=0.025pt, labels=none}
\psframe[linewidth=0.05pt](0,0)(18,18)
\psgrid[gridwidth=0.05pt, subgriddiv=1](0,0)(18,18)
% insert circles
\pscircle[linewidth=0.1](9,9){8}
\pscircle[linewidth=0.1](9,9){4}
\pscircle[linewidth=0.1](12,8){4}
\pscircle[fillstyle=solid,fillcolor=lightgray,opacity=0.2,linewidth=0.1](9,6){4}
% insert arrows
\psset{arrows=->,linewidth=2.5pt}
\pcline[linecolor=red](9,9)(12,8) \aput{:U}{label 1}
\pcline[linecolor=magenta](9,9)(9,6)\aput{:U}{label 2}
\pcline[linecolor=blue](12,8)(9,6) \Aput{label 3}
\pcline[linecolor=blue](9,9)(6.5,7) \bput{:U}{label 4}
\end{pspicture}
\end{document}