5

Consider the following example.

Code

% pdflatex -shell-escape test.tex

\documentclass{article}

\usepackage{
  auto-pst-pdf,
  pst-eucl
}
\usepackage{siunitx}

\begin{document}

\begin{figure}
\def\indryk{5}
\def\bredde{60}
\pstFPdiv\konstA{2}{3}
\pstFPmul\Bb{\konstA}{\bredde}
\pstFPdiv\konstB{6}{5}
\pstFPmul\Ha{\konstB}{\bredde}
\pstFPdiv\konstC{13}{20}
\pstFPmul\Hb{\konstC}{\bredde}
\pstFPdiv\konstD{7}{5}
\pstFPmul\Hc{\konstD}{\bredde}
\pstFPdiv\radiusA{\bredde}{20}
\pstFPdiv\LabelSeparation{\bredde}{12}
 \centering
  \sisetup{
    round-mode=places,
    round-precision=0
  }
  \psset{
    unit=0.13cm
  }
  \begin{pspicture}(8,10)
   % Bistadet.
   \pnode(\indryk,\indryk){A}
   \pnode(!\indryk\space \indryk\space 13 20 div \bredde\space mul add){B1}
   \pnode(!\indryk\space \indryk\space 16 20 div \bredde\space mul add){B2}
   \pnode(!\indryk\space \indryk\space 19 20 div \bredde\space mul add){B3}
   \pnode(!\indryk\space \indryk\space 22 20 div \bredde\space mul add){B4}
   \pnode(!\indryk\space \indryk\space 25 20 div \bredde\space mul add){B5}
   \pnode(!\indryk\space \indryk\space 28 20 div \bredde\space mul add){B6}
   \pnode(!\indryk\space \bredde\space 2 div add \indryk\space 24 5 3 sqrt mul sub 10 div \bredde\space mul add){C}
   \pnode(!\indryk\space \bredde\space add \indryk\space 28 20 div \bredde\space mul add){D6}
   \pnode(!\indryk\space \bredde\space add \indryk\space 25 20 div \bredde\space mul add){D5}
   \pnode(!\indryk\space \bredde\space add \indryk\space 22 20 div \bredde\space mul add){D4}
   \pnode(!\indryk\space \bredde\space add \indryk\space 19 20 div \bredde\space mul add){D3}
   \pnode(!\indryk\space \bredde\space add \indryk\space 16 20 div \bredde\space mul add){D2}
   \pnode(!\indryk\space \bredde\space add \indryk\space 13 20 div \bredde\space mul add){D1}
   \pnode(!\indryk\space \bredde\space add \indryk\space){E}
   \pnode(!\indryk\space 5 6 div \bredde\space mul add \indryk\space){F}
   \pnode(!\indryk\space 1 6 div \bredde\space mul add \indryk\space){G}
   \pnode(!\indryk\space 1 6 div \bredde\space mul add \indryk\space  4 20 div \bredde\space mul add){H1}
   \pnode(!\indryk\space 1 6 div \bredde\space mul add \indryk\space  7 20 div \bredde\space mul add){H2}
   \pnode(!\indryk\space 1 6 div \bredde\space mul add \indryk\space 10 20 div \bredde\space mul add){H3}
   \pnode(!\indryk\space 1 6 div \bredde\space mul add \indryk\space 13 20 div \bredde\space mul add){H4}
   \pnode(!\indryk\space 5 6 div \bredde\space mul add \indryk\space  4 20 div \bredde\space mul add){I1}
   \pnode(!\indryk\space 5 6 div \bredde\space mul add \indryk\space  7 20 div \bredde\space mul add){I2}
   \pnode(!\indryk\space 5 6 div \bredde\space mul add \indryk\space 10 20 div \bredde\space mul add){I3}
   \pnode(!\indryk\space 5 6 div \bredde\space mul add \indryk\space 13 20 div \bredde\space mul add){I4}
   \pspolygon(A)(B6)(C)(D6)(E)
   \multido{\iB=1+1,\iD=1+1}{6}{\pcline(B\iB)(D\iD)}
   \pcline(G)(H4)
   \pcline(F)(I4)
   \multido{\iH=1+1,\iI=1+1}{4}{\pcline(H\iH)(I\iI)}
   % Betegnelser.
  \psset{
    nrot=:U
  }
   \pnode(!0 1 5 div \bredde\space mul \indryk\space add){J}
   \pnode(!0 7 5 div \bredde\space mul \indryk\space add){K}
   \pcline{|-|}(J)(K)
   \ncput*{\SI{\Ha}{\cm}}
   \pnode(\indryk,0){L}
   \pnode(!\indryk\space \bredde\space add 0){M}
   \pcline{|-|}(L)(M)
   \ncput*{\SI{\bredde}{\cm}}
   \pcline{|<->|}(G)(F)
   \ncput*{\SI{\Bb}{\cm}}
   \pnode(!\indryk\space 2 mul \bredde\space add \indryk\space){N}
   \pnode(!\indryk\space 2 mul \bredde\space add \indryk\space 13 20 div \bredde\space mul add){O}
   \pcline{|-|}(N)(O)
   \ncput*{\SI{\Hb}{\cm}}
   \pnode(!\indryk\space 3 mul \bredde\space add \indryk\space){P}
   \pnode(!\indryk\space 3 mul \bredde\space add \indryk\space 7 5 div \bredde\space mul add){Q}
   \pcline{|-|}(P)(Q)
   \ncput*{\SI{\Hc}{\cm}}
   \pstMarkAngle[
     MarkAngleRadius=\radiusA,
     LabelSep=\LabelSeparation
   ]{B6}{C}{D6}{\footnotesize{\SI{150}{\degree}}}
  \end{pspicture}
\end{figure}

\end{document}

Output

enter image description here

Question

I have the desired output but the code is rather messy; can anyone help me simplify if?

  • why do you use always nodes? That are simple rectangles and a triangle? – user2478 Apr 20 '13 at 15:25
  • @Herbert The drawing was made a rather long time ago when I was completely new to PSTricks. I don't do that anymore. – Svend Tveskæg Apr 20 '13 at 15:29
  • I would use $\phantom{{}^\circ}150^\circ$. – Werner Apr 20 '13 at 16:06
  • @Werner: why the \phantom – user2478 Apr 20 '13 at 16:35
  • @Herbert: To centre 150. Of course, you could also \rlap the \circ. It looks better in my opinion. – Werner Apr 20 '13 at 16:38
4

If you need width/height as variables, then change it and use \numexpr for the calculations.

\documentclass{article}
\usepackage[pdf]{pstricks}% pdflatex -shell-escape test.tex
\usepackage{pst-node,multido}
\begin{document}

\psset{unit=1mm,dimen=middle}
\begin{pspicture}(-10,-10)(80,100)
\psframe(60,84)
\psframe(10,0)(50,39)
\multido{\iA=12+9}{3}{\psline(10,\iA)(50,\iA)}
\multido{\iA=39+9}{5}{\psline(0,\iA)(60,\iA)}
\psline(0,84)(!30 15 Tan 30 mul 84 add)(60,84) 
\psarc(!30 15 Tan 30 mul 84 add){3}{195}{345}
\uput{5}[-90](!30 15 Tan 30 mul 84 add){$150^\circ$}
\pcline             {<->}  (10,0)(50,0)\ncput*{40\,cm}
\pcline[offset=-5 ]{|<->|}(0,0)(60,0)  \ncput*{60\,cm}
\pcline[offset=-5 ]{|<->|}(60,0)(60,39)\ncput*[nrot=:U]{39\,cm}
\pcline[offset=-10]{|<->|}(60,0)(60,84)\ncput*[nrot=:U]{84\,cm}
\pcline[offset=5  ]{|<->|}(0,12)(0,84) \ncput*[nrot=:U]{72\,cm}
\end{pspicture}

\end{document}

enter image description here

  • Great, @Herbert. Much appreciated, as usual. – Svend Tveskæg Apr 20 '13 at 16:10
2

Simplifying the existing answer to save 115 keystrokes more while the readability is still kept unchanged. Using siunitx makes our life consistent.

enter image description here

\documentclass[pstricks]{standalone}
\usepackage{pst-node,multido,siunitx}
\psset{unit=1mm,dimen=middle,linejoin=1}

\def\Label#1{\ncput*{\SI{#1}{\cm}}}

\begin{document}
\begin{pspicture}(-10,-10)(80,100)
\multips(0,75)(0,-9){8}{\psframe(60,9)}
\multips(0,0)(50,0){2}{\psframe[fillstyle=solid](10,39)}
\pnode[!0 15 Tan 30 mul](30,84){T}
\pspolygon(0,84)(T)(60,84)
\psarcn(T){3}{-15}{-165}
\uput{4}[-90](T){\ang{150}}
\pcline{<->}(10,0)(50,0)\Label{40}
\psset{arrows=|<*->|*}
\pcline[offset=-5 ](0,0)(60,0)\Label{60}
\psset{nrot=:U}
\pcline[offset=-5 ](60,0)(60,39)\Label{39}
\pcline[offset=-10](60,0)(60,84)\Label{84}
\pcline[offset=5  ](0,12)(0,84) \Label{72}
\end{pspicture}
\end{document}
  • Please reduce 100 keystrokes more if you can. :-) – kiss my armpit Apr 21 '13 at 9:56
  • 1
    Nice simplification. – Svend Tveskæg Apr 21 '13 at 9:56
  • What is the point of linejoin=1? I have never seen this option before. – Svend Tveskæg Apr 21 '13 at 10:04
  • Never mind; I have had a look at page 7 here. – Svend Tveskæg Apr 21 '13 at 10:07
  • 1
    @SvendTveskæg: There are 3 options for linejoin: 0 (default), 1, and 2. You can try the simple example \pspolygon[linejoin=1](0,0)(2,3)(4,0), see the output for each option. – kiss my armpit Apr 21 '13 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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