考虑以下示例。
代码
% pdflatex -shell-escape test.tex
\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\usepackage{siunitx}
\begin{document}
% Paremeters
\def\laengde{90 }
\def\bredde{45 }
\begin{pspicture}(-2,-4)(45,90)
\psset{unit=0.18cm,nrot=:U,dotsize=3pt 2}
\pnodes{P}(0,0)(0,0)%
(0,\laengde)%
(!0 \laengde 2 div)%
(!\bredde \laengde 2 div)%
(!\bredde 2 div \laengde 2 div)%
(!\bredde 2 div 16.5 7.32 2 div add add 16.5)%
(!\bredde 2 div 16.5 7.32 2 div add add 0)%
(!\bredde 2 div 16.5 7.32 2 div add sub 0)%
(!\bredde 2 div 11)%
(!\bredde 2 div 7.32 2 div 5.5 add sub 0)%
(!\bredde 2 div 7.32 2 div 5.5 add sub 5.5)%
(!\bredde 2 div 7.32 2 div 5.5 add add 0)%
(!\bredde 7.32 sub 2 div 0)%
(!\bredde 7.32 add 2 div 0)%
(!\bredde 2 div \laengde 11 sub)
% Outline and middle of the field.
\pspolygon(P1)(P2)(\bredde,\laengde)(\bredde,0)
\psline(P3)(P4)
\pcline[offset=9pt]{|<->|}(P1)(P2)
\ncput*{\scriptsize\SI{\laengde}{\m}}
\pcline[offset=-80pt]{<->}(P3)(P4)
\ncput*{\scriptsize\SI{\bredde}{\m}}
\psdots(P5)(P9)(P15)
\pscircle(P5){9.15}
% Lower part of the field.
\pcline[offset=9pt]{<->}(P7)(P6)
\ncput*{\scriptsize\SI{16.5}{\m}}
\pcline{<->}(!\bredde 2 div 0)(P9)
\ncput*{\scriptsize\SI{11}{\m}}
\psarc(P9){9.15}{37}{143}
\pcline{<->}(P9)(!\bredde 2 div 9.15 2 div add 11 9.15 3 sqrt 2 div mul add)
\ncput*{\scriptsize\SI{9.15}{\m}}
\psline(P10)(P11)(!\bredde 2 div 7.32 2 div 5.5 add add 5.5)(P12)
\psline(P8)(!\bredde 2 div 16.5 7.32 2 div add sub 16.5)(P6)(P7)
\pcline[offset=-6pt]{<->}(P10)(P11)
\ncput*{\tiny\SI{5.5}{\m}}
\psline(P13)(!\bredde 7.32 sub 2 div -2)(!\bredde 7.32 add 2 div -2)(P14)
\pcline[offset=-9pt]{|<->}(!\bredde 2 div 16.5 7.32 2 div add sub 0)(P13)
\ncput*{\scriptsize\SI{16.5}{\m}}
\pcline[offset=-16pt]{|<->|}(P13)(P14)
\ncput*{\tiny\SI{7.32}{\m}}
\pcline[offset=6pt]{|<->}(P14)(P12)
\ncput*{\tiny\SI{5.5}{\m}}
% Upper part of the field.
\psline(!\bredde 2 div 16.5 7.32 2 div add sub \laengde)%
(!\bredde 2 div 16.5 7.32 2 div add sub \laengde 16.5 sub)%
(!\bredde 2 div 16.5 7.32 2 div add add \laengde 16.5 sub)%
(!\bredde 2 div 16.5 7.32 2 div add add \laengde)
\psarc(P15){9.15}{217}{323}
\psline(!\bredde 2 div 7.32 2 div 5.5 add sub \laengde)%
(!\bredde 2 div 7.32 2 div 5.5 add sub \laengde 5.5 sub)%
(!\bredde 2 div 7.32 2 div 5.5 add add \laengde 5.5 sub)%
(!\bredde 2 div 7.32 2 div 5.5 add add \laengde)
\psline(!\bredde 7.32 sub 2 div \laengde)%
(!\bredde 7.32 sub 2 div \laengde 2 add)%
(!\bredde 7.32 add 2 div \laengde 2 add)%
(!\bredde 7.32 add 2 div \laengde)
\end{pspicture}
\end{document}
输出
问题
我有想要的输出,但是代码不是很优雅;有人可以帮我简化吗?
更新 1
到目前为止我有以下内容:
% pdflatex -shell-escape test.tex
\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\begin{document}
% Paremeters
\def\laengde{90 }
\def\bredde{45 }
\psset{unit=0.18cm,dimen=middel}
\begin{pspicture}(-25,-50)(25,50)
% Outline and middle of the field
\psdot(0,0)
\pscircle(0,0){9.15}
\psline(!\bredde 2 div neg 0)(!\bredde 2 div 0)
\psframe(!\bredde 2 div neg \laengde 2 div neg)(!\bredde 2 div \laengde 2 div)
% Lower part of the field.
\psframe(!20.16 neg \laengde 2 div neg)(!20.16 \laengde 2 div neg 16.5 add)
\psframe(!9.16 neg \laengde 2 div neg)(!9.16 \laengde 2 div neg 5.5 add)
\psframe(!3.66 neg \laengde 2 div neg)(!3.66 \laengde 2 div 1.5 add neg)
\psdot(!0 \laengde 2 div neg 11 add)
\psarc(!0 \laengde 2 div neg 11 add){9.15}{37}{143}
% Upper part of the field.
\psframe(!20.16 neg \laengde 2 div)(!20.16 \laengde 2 div 16.5 sub)
\psframe(!9.16 neg \laengde 2 div)(!9.16 \laengde 2 div 5.5 sub)
\psframe(!3.66 neg \laengde 2 div)(!3.66 \laengde 2 div 1.5 add)
\psdot(!0 \laengde 2 div 11 sub)
\psarc(!0 \laengde 2 div 11 sub){9.15}{217}{323}
\end{pspicture}
\end{document}
现在,所有的长度都消失了,代码可能变得更“简单”。
更新 2
% pdflatex -shell-escape test.tex
\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\usepackage{siunitx}
\begin{document}
% Paremeters
\def\laengde{90 }
\def\bredde{45 }
\centering
\psset{
unit=0.18cm,
dimen=middel,
nrot=:U,
dotsize=3pt 2
}
\begin{pspicture}(-5,-5)(45,95)
% Banens omrids og midterfelt.
\psframe(0,0)(\bredde,\laengde)
\psline(!0 \laengde 2 div)(!\bredde \laengde 2 div)
\pcline[offset=9pt]{|<->|}(0,0)(0,\laengde)
\ncput*{\scriptsize{\SI{\laengde}{\m}}}
\pcline[offset=-80pt]{<->}(!0 \laengde 2 div)(!\bredde \laengde 2 div)
\ncput*{\scriptsize{\SI{\bredde}{\m}}}
\psdot(!\bredde 2 div \laengde 2 div)
\pscircle(!\bredde 2 div \laengde 2 div){9.15}
% Den nederste del af banen.
\psframe(!\bredde 2 div 20.16 sub 0)(!\bredde 2 div 20.16 add 16.5)
\psframe(!\bredde 2 div 9.16 sub 0)(!\bredde 2 div 9.16 add 5.5)
\psframe(!\bredde 7.32 sub 2 div 0)(!\bredde 7.32 add 2 div 2 neg)
\pcline[offset=9pt]{<->}(!\bredde 2 div 20.16 add 0)(!\bredde 2 div 20.16 add 16.5)
\ncput*{\scriptsize{\SI{16.5}{\m}}}
\pcline{<->}(!\bredde 2 div 0)(!\bredde 2 div 11)
\ncput*{\scriptsize{\SI{11}{\m}}}
\pcline{<->}(!\bredde 2 div 11)(!\bredde 2 div 4.575 add 11 9.15 3 sqrt 2 div mul add)
\ncput*{\scriptsize{\SI{9.15}{\m}}}
\pcline[offset=-6pt]{<->}(!\bredde 2 div 9.16 sub 0)(!\bredde 2 div 9.16 sub 5.5)
\ncput*{\tiny{\SI{5.5}{\m}}}
\pcline[offset=-9pt]{|<->}(!\bredde 2 div 20.16 sub 0)(!\bredde 7.32 sub 2 div 0)
\ncput*{\scriptsize{\SI{16.5}{\m}}}
\pcline[offset=-18pt]{|<->|}(!\bredde 7.32 sub 2 div 0)(!\bredde 7.32 add 2 div 0)
\ncput*{\tiny{\SI{7.32}{\m}}}
\pcline[offset=6pt]{|<->}(!\bredde 7.32 add 2 div 0)(!\bredde 2 div 9.16 add 0)
\ncput*{\tiny{\SI{5.5}{\m}}}
\psdot(!\bredde 2 div 11)
\psarc(!\bredde 2 div 11){9.15}{37}{143}
% Den øverste del af banen.
\psframe(!\bredde 2 div 20.16 sub \laengde)(!\bredde 2 div 20.16 add \laengde 16.5 sub)
\psframe(!\bredde 2 div 9.16 sub \laengde)(!\bredde 2 div 9.16 add \laengde 5.5 sub)
\psframe(!\bredde 7.32 sub 2 div \laengde)(!\bredde 7.32 add 2 div \laengde 2 add)
\psdot(!\bredde 2 div \laengde 11 sub)
\psarc(!\bredde 2 div \laengde 11 sub){9.15}{217}{323}
\end{pspicture}
\end{document}
我已将 切换回 ,让(0,0)
成为球场的左下角,而不是(0,0)
成为球场的中间点。(我刚刚尝试了两者;哪个是“最佳”?)此外,所有长度现在都在图中。
更新 3
这是最终版本。(感谢 Herbert!)
% pdflatex -shell-escape test.tex
\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\usepackage[locale=DE]{siunitx}
\begin{document}
\def\laengde{\Laengde 2 div }
\def\bredde{\Bredde 2 div }
\def\goalwidth{\Goalwidth 2 div }
\def\halffield{%
\psline(!\goalwidth neg 0)(!\goalwidth neg 2)%
(!\goalwidth 2)(!\goalwidth 0)
\psline(!\goalwidth neg 5.5 sub 0)(!\goalwidth neg 5.5 sub -5.5)%
(!\goalwidth 5.5 add -5.5)(!\goalwidth 5.5 add 0)
\psline(!\goalwidth neg 16.5 sub 0)(!\goalwidth neg 16.5 sub -16.5)%
(!\goalwidth 16.5 add -16.5)(!\goalwidth 16.5 add 0)%
\rput(0,-11){\psdot(0,0)\psarcn(0,0){9.15}{-37}{-143}}
}
\def\Label#1{\ncput*[nrot=:U]{\scriptsize\SI{#1}{\m}}}
% Paremeters
\def\Laengde{90 }
\def\Bredde{45 }
\def\Goalwidth{7.32 }
\psset{
unit=1.8mm,
dimen=middel,
nrot=:U,
dotsize=3pt 2
}
\begin{pspicture}(-25,-50)(25,50)
\psframe(!\bredde neg \laengde neg)(!\bredde \laengde)
\psdot(0,0)\psline(!\bredde neg 0)(!\bredde 0)\pscircle(0,0){9.15}
\rput(!0 \laengde){\halffield}
\rput{180}(!0 \laengde neg){\halffield}
\pcline[offset=9pt]{|<->|}(!\bredde neg \laengde neg)(!\bredde neg \laengde)
\Label{\Laengde}
\pcline{<->}(!\bredde neg \laengde 3 div neg)(!\bredde \laengde 3 div neg)
\Label{\Bredde}
\rput(!0 \laengde neg){%
\pcline[offset=-7pt]{|<->}(!\goalwidth neg 16.5 sub 0)(!\goalwidth neg 0)
\Label{16.5}
\pcline[offset=9pt]{<->}(!\bredde 2 sub 0)(!\bredde 2 sub 16.5)
\Label{16.5}
\pcline{<->}(0,0)(0,11)
\Label{11}
\pcline[offset=-6pt]{<->}(!\goalwidth 5.5 add neg 0)(!\goalwidth 5.5 add neg 5.5)
\ncput*{\tiny{\SI{5.5}{\m}}}
\pcline[offset=6pt]{|<->}(!\goalwidth 0)(!\goalwidth 5.5 add 0)
\ncput*{\tiny{\SI{5.5}{\m}}}
\pcline[offset=-7pt]{|<->|}(!\goalwidth neg -2)(!\goalwidth -2)
\Label{\Goalwidth}
\rput(0,11){%
\pcline{<->}(0,0)(9.15;60)
\Label{9.15}
}
}
\end{pspicture}
\end{document}
答案1
我不使用siunitx
它,因为只写一个长度就太过分了。\scriptsize
朋友之间没有争论。这{..}
毫无意义。
\documentclass{article}
%\usepackage[pdf]{pstricks}
\usepackage{pst-node}
\begin{document}
% Paremeters
\def\Laengde{90 } \def\laengde{\Laengde 2 div }
\def\Bredde{45 } \def\bredde{\Bredde 2 div }
\def\Goalwidth{7.32 }\def\goalwidth{\Goalwidth 2 div }
\def\halffield{%
\psline(!\goalwidth neg 0)(!\goalwidth neg 2)%
(!\goalwidth 2)(!\goalwidth 0)
\psline(!\goalwidth neg 5.5 sub 0)(!\goalwidth neg 5.5 sub -5.5)%
(!\goalwidth 5.5 add -5.5)(!\goalwidth 5.5 add 0)
\psline(!\goalwidth neg 16.5 sub 0)(!\goalwidth neg 16.5 sub -16.5)%
(!\goalwidth 16.5 add -16.5)(!\goalwidth 16.5 add 0)%
\rput(0,-11){\psdot(0,0)\psarcn(0,0){9.15}{-37}{-143}}
}
\psset{unit=1.8mm,dimen=middel,nrot=:U,dotsize=3pt 2}
\begin{pspicture}(-25,-50)(25,50)
\psframe(!\bredde neg \laengde neg)(!\bredde \laengde)
\psdot(0,0)\psline(!\bredde neg 0)(!\bredde 0)\pscircle(0,0){9.15}
\rput(!0 \laengde){\halffield}
\rput{180}(!0 \laengde neg){\halffield}
\pcline[offset=9pt]{|<->|}(!\bredde neg \laengde neg)(!\bredde neg \laengde)
\ncput*{\scriptsize\Laengde m}
\pcline{<->}(!\bredde neg \laengde 3 div neg)(!\bredde \laengde 3 div neg)
\ncput*{\scriptsize\Bredde m}
\rput(!0 \laengde neg){%
\pcline[offset=9pt]{<->}(!\bredde 2 sub 0)(!\bredde 2 sub 16.5)
\ncput*{\scriptsize16.5 m}
\pcline{<->}(0,0)(0,11)\ncput*{\scriptsize11 m}
\rput(0,11){\pcline{<->}(0,0)(9.15;60)\ncput*{\scriptsize9.15 m}}
\pcline{<->}(-7,0)(-7,5.5)\ncput*{\tiny5.5 m}
\pcline[offset=6pt]{|<->}(!\goalwidth 0)(!\goalwidth 5.5 add 0)
\ncput*{\tiny5.5 m}
}
\end{pspicture}
\end{document}
Svend Tveskæg 向 Herbert 提出的问题:我可以使用
\def\halffield{%
\psframe(!\goalwidth neg 0)(!\goalwidth 2)
\psframe(!\goalwidth neg 5.5 sub 0)(!\goalwidth 5.5 add -5.5)
\psframe(!\goalwidth neg 16.5 sub 0)(!\goalwidth 16.5 add -16.5)
\rput(0,-11){\psdot(0,0)\psarcn(0,0){9.15}{-37}{-143}}
}
代替
\def\halffield{%
\psline(!\goalwidth neg 0)(!\goalwidth neg 2)%
(!\goalwidth 2)(!\goalwidth 0)
\psline(!\goalwidth neg 5.5 sub 0)(!\goalwidth neg 5.5 sub -5.5)%
(!\goalwidth 5.5 add -5.5)(!\goalwidth 5.5 add 0)
\psline(!\goalwidth neg 16.5 sub 0)(!\goalwidth neg 16.5 sub -16.5)%
(!\goalwidth 16.5 add -16.5)(!\goalwidth 16.5 add 0)
\rput(0,-11){\psdot(0,0)\psarcn(0,0){9.15}{-37}{-143}}
}
?
答案2
和dimen=medusa
!
\documentclass[pstricks]{standalone}
\usepackage{pst-node,siunitx}
\psset{dimen=medusa,unit=3mm}
\def\Upper{%
\psframe(-22.5,0)(22.5,45)% main rectangle
\qdisk(0,0){3pt}% dot at center
\psarc(0,0){9.15}{0}{180}% semi circle at center
\psframe(-20.16,28.5)(20.16,45)% second rectangle
\qdisk(0,34){3pt}% dot inside second rectangle
\psarcn(0,34){9.15}{-37}{-143}% arc
\psframe(-9.16,39.5)(9.16,45)% third rectangle
\psframe(-3.66,45)(3.66,47)% fourth rectangle
}
\def\Label#1{\ncput*[nrot=:U]{\small\SI{#1}{\cm}}}
\begin{document}
\begin{pspicture}(-24.5,-49)(23,47.5)
\Upper\psscalebox{1 -1}{\Upper}
\psset{arrows=|<*->|*}
\pcline(-22.5,-15)(22.5,-15)\Label{45}% width
\rput(0,-34){\pcline{<->}(0,0)(9.15;60)\Label{9.15}}
\psset{offset=-1}
\pcline(-20.16,-45)(-3.66,-45)\Label{16.5}
\pcline(-3.66,-47)(3.66,-47)\Label{7.32}
\pcline(-9.16,-45)(-9.16,-39.5)\Label{5.5}
\psset{offset=1}
\pcline(-22.5,-45)(-22.5,45)\Label{90}% length
\pcline(3.66,-45)(9.16,-45)\Label{5.5}
\pcline(0,-45)(0,-34)\Label{11}
\pcline(20.16,-45)(20.16,-28.5)\Label{16.5}
\end{pspicture}
\end{document}