1

Consider the following example. (This is either the last one or the second to last.)

Code

% pdflatex -shell-escape test.tex

\documentclass{article}

\usepackage{auto-pst-pdf,pstricks-add}
\usepackage[locale=DE]{siunitx}

\begin{document}

\begin{figure}
\def\radius{19.2}
\def\lige{33.3}
%\edef\bredde{\dimexpr2*\radius\relax\space}
\pstFPmul\bredde{2}{\radius}
%\edef\laengde{\dimexpr\bredde+\lige\relax\space}
\pstFPadd\laengde{\bredde}{\lige}
 \centering
 \psset{unit=0.168cm}
% \psset{unit=\psunit}
  \begin{pspicture}(\laengde,\bredde)
   \pcline(\radius,0)(!\radius\space \lige\space add 0)
   \psarc(!\radius\space \lige\space add \radius\space){\radius}{270}{90}
   \pcline(!\radius\space \lige\space add 2 \radius\space mul)%
    (!\radius\space 2 \radius\space mul)
   \psarc(\radius,\radius){\radius}{90}{270}
  \psset{linestyle=dotted,arrows=|*-,offset=0pt}
   \pcline(\radius,\radius)(0,\radius)
   \ncput*{\SI{\radius}{\cm}}
   \pcline[arrows=|*-|*](\radius,\radius)(!\radius\space \lige\space add \radius\space)
   \ncput*{\SI{\lige}{\cm}}
   \pcline(!\radius\space \lige\space add \radius\space)%
    (!2 \radius\space mul \lige\space add \radius\space)
   \ncput*{\SI{\radius}{\cm}}
   \pcline(\radius,\radius)(\radius,0)
   \pcline(\radius,\radius)(!\radius\space 2 \radius\space mul)
   \pcline(!\radius\space \lige\space add \radius\space)%
    (!\radius\space \lige\space add 0)
   \pcline(!\radius\space \lige\space add \radius\space)%
    (!\radius\space \lige\space add 2 \radius\space mul)
  \end{pspicture}
\end{figure}

\end{document}

Output

enter image description here

Question

I have the desired output but the code is not very elegant. Furthermore, I still don't get how to use the \psunit (see this answer).

7
  • 1
    Request: Hi :) For PSTricks ignorant users like me and willing to learn, can you give details on "again" in Title means, "improved","elegant" , difference between earlier Q's with elaborate explanation to be understood for dummies like me. Commented Apr 25, 2013 at 15:06
  • @texenthusiast "again" refers to this post, "improved" means that I use a lot of keystrokes to get what I want, and for "elegant", see comment regarding "improved". Commented Apr 25, 2013 at 15:09
  • Is it possible to absorb your comments and detailed explanation inside the question to be concise and clean to help wider audience :). Commented Apr 25, 2013 at 15:10
  • @texenthusiast You are welcome to edit my post. I have to go now for today. Commented Apr 25, 2013 at 15:11
  • I have no idea on this topic so i don't deem fit for rephrasing it :) Commented Apr 26, 2013 at 4:29

2 Answers 2

3

Another symmetrical object. Origin is the center:

\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\usepackage[locale=DE]{siunitx}
\begin{document}

\psset{unit=1.68mm,linewidth=1pt}
\def\Radius{19.2}  \def\lige{33.3}
\newlength\R \R=\Radius\psunit %  relative setting to \psunit
\newlength\hW  \hW=\lige\psunit \hW=0.5\hW

\begin{pspicture}(-\hW,-\R)(\hW,\R)
  \psarc( \hW,0){\R}{270}{90}
  \psarc(-\hW,0){\R}{90}{270}
  \psline[linestyle=dotted](-\hW,-\R)(-\hW,\R)
  \psline[linestyle=dotted]( \hW,-\R)( \hW,\R)
  \psline[linestyle=dotted](\dimexpr-\hW-\R,0)(\dimexpr\hW+\R,0)
  \psline(-\hW, \R)(\hW, \R)  
  \psline(-\hW,-\R)(\hW,-\R)
  \rput*(0,0){\SI{\lige}{\cm}}
  \rput*(\dimexpr-\hW-0.5\R,0){\SI{\Radius}{\cm}}
  \rput*(\dimexpr\hW+0.5\R,0) {\SI{\Radius}{\cm}}
  \rput(-\hW,0){\textbf{+}}\rput(\hW,0){\textbf{+}}
\end{pspicture}

\end{document}
2
  • Really great, as always! Commented Apr 26, 2013 at 4:08
  • 1
    Unfortunately \dimexpr does not fully support algebraic expressions such as trigonometric expressions, logarithmic expressions, etc. Then this answer is just a special lucky case. :-) Commented Apr 26, 2013 at 5:40
5

Using pst-sex package to provide constants in both TeX and PS worlds at the same time.

enter image description here

\documentclass[pstricks,border=1pt]{standalone}
\usepackage{pst-node}
\usepackage{pst-sex}
\usepackage[locale=DE]{siunitx}

\const[1]{Radius}{19.2}
\const[1]{Width}{33.3}
\const{Height}{2*Radius}
\const{Length}{Width+Height}

\psset{unit=0.168cm}

\begin{document}
\begin{pspicture}(\Length,\Height)
    \LoadConstants
    \def\Semi{%
        \pnodes{P}(!Radius Height)(!Radius Width add Height)(!Radius Width add Radius)
        \psline(P0)(P1)
        \psarcn(P2){!Radius}{90}{-90}
        \pcline[linestyle=dotted](P1|0,0)(P1)
        \ncput{\psline(-3pt,0)(3pt,0)\psline(0,-3pt)(0,3pt)}
        \pcline[linestyle=dotted](P2)([nodesep=\Radius]P2)
        \ncput{\rput*{*0}(0,0){\SI{\Radius}{\cm}}}
    }\Semi
    %\rput(!Radius Width add 0){\rput{180}(0,0){\rput(-\Radius,-\Height){\Semi}}}
    %\uput{0}[0]{180}(!Radius Width add 0){\rput(-\Radius,-\Height){\Semi}}
    \rput{180}(!Radius 2 mul Width add Height){\Semi}
    \pcline[linestyle=dotted](!Radius Radius)(!Radius Width add Radius)
    \ncput*{\SI{\Width}{\cm}}
\end{pspicture}
\end{document}

Note:

Next time please use English names for the constants.

6
  • When I uncomment the \pstFPmul commands and try to use the \edef ones instead, the document won't compile. THe problem is probably regarding the unit definition, as Herbert mentioned in the other post. Commented Apr 25, 2013 at 14:55
  • Okay. \bredde = 2*\radius and \laengde = \bredde+\lige. (The \edefs are wrong.) Commented Apr 25, 2013 at 15:00
  • @Bugbusters I won't see your (or any others) post before tomorrow. Good day to everyone. Commented Apr 25, 2013 at 15:10
  • @Bugbusters can you do a favour of making this title more clear based on comments below Q :) Commented Apr 25, 2013 at 15:15
  • 1
    @texenthusiast: I think I should not rephrase the title as the questioner should always provide more descriptive and specific title. :-) Commented Apr 26, 2013 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .