Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following example.

Code

% 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}

Output

enter image description here

Question

I have the desired output but the code is not very elegant; can anyone help me simplify if?

Update 1

So far I have the following:

% 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}

Now, all the lengths are missing and the code can probably be made even 'simpler'.

Update 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}

I have switched back to letting (0,0) be the bottom left corner of the pitch instead of letting (0,0) be the middel. (I have just tried both; what is 'best'?) Furthermore, all the length are now on the figure.

Update 3

Here is the final version. (Thanks to 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}
share|improve this question
    
It is absolutely the same way to simply it as shown in your other example! –  Herbert Apr 22 '13 at 6:04
    
@Herbert Okay. I'll see what I can get done and post it if I find some 'smart' way of doing it. –  Svend Tveskæg Apr 22 '13 at 13:02
    
@Herbert I have tried to simplify the code. I'm wondering if I can make you have a look at it at some point? –  Svend Tveskæg Apr 22 '13 at 22:19
    
It will be more convenient if you provide the important values to construct so we don't need to calculate them. –  stalking is prohibited Apr 23 '13 at 8:47
    
@Bugbusters All the important values are on the output above. (45 and 90 are variables.) I'm not exactly sure what you mean but it might be easier to see from the first code try I gave. –  Svend Tveskæg Apr 23 '13 at 8:53

2 Answers 2

up vote 7 down vote accepted

I do not use siunitx it is overkill for writing only a length. \scriptsize and friends have no argument. The {..} have no meaning.

\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}

enter image description here

Question to Herbert from Svend Tveskæg: Can I use

\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}}
}

instead of

\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}}
}

?

share|improve this answer
    
Great, @Herbert! Good point about {..}. –  Svend Tveskæg Apr 23 '13 at 9:42
    
I edited the code a bit. Forgot to define \Goalwidth->\goalwidth. Makes life easier ... –  Herbert Apr 23 '13 at 9:50
    
Nice. Thank you for simplifying it even further. –  Svend Tveskæg Apr 23 '13 at 9:55
    
dimen=middel? –  stalking is prohibited Apr 23 '13 at 17:13
    
yes, works also, and I leave it as a competition to you why? ... :-) –  Herbert Apr 23 '13 at 17:24

With dimen=medusa!

enter image description here

\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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.