# Definition of PSTricks constant (again) and improvement of code

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

Code

% pdflatex -shell-escape test.tex

\documentclass{article}

\usepackage[locale=DE]{siunitx}

\begin{document}

\begin{figure}
\def\lige{33.3}
%\edef\laengde{\dimexpr\bredde+\lige\relax\space}
\centering
\psset{unit=0.168cm}
% \psset{unit=\psunit}
\begin{pspicture}(\laengde,\bredde)
\psset{linestyle=dotted,arrows=|*-,offset=0pt}
\ncput*{\SI{\lige}{\cm}}
\end{pspicture}
\end{figure}

\end{document}


Output

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).

-
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. –  texenthusiast Apr 25 '13 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". –  Svend Tveskæg Apr 25 '13 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 :). –  texenthusiast Apr 25 '13 at 15:10
@texenthusiast You are welcome to edit my post. I have to go now for today. –  Svend Tveskæg Apr 25 '13 at 15:11
I have no idea on this topic so i don't deem fit for rephrasing it :) –  texenthusiast Apr 26 '13 at 4:29

Another symmetrical object. Origin is the center:

\documentclass{article}
\usepackage[locale=DE]{siunitx}
\begin{document}

\psset{unit=1.68mm,linewidth=1pt}
\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(-\hW,0){\textbf{+}}\rput(\hW,0){\textbf{+}}
\end{pspicture}

\end{document}

-
Really great, as always! –  Svend Tveskæg Apr 26 '13 at 4:08
Unfortunately \dimexpr does not fully support algebraic expressions such as trigonometric expressions, logarithmic expressions, etc. Then this answer is just a special lucky case. :-) –  The Last Error Apr 26 '13 at 5:40

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

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

\const[1]{Width}{33.3}
\const{Length}{Width+Height}

\psset{unit=0.168cm}

\begin{document}
\begin{pspicture}(\Length,\Height)
\def\Semi{%
\psline(P0)(P1)
\pcline[linestyle=dotted](P1|0,0)(P1)
\ncput{\psline(-3pt,0)(3pt,0)\psline(0,-3pt)(0,3pt)}
}\Semi
\ncput*{\SI{\Width}{\cm}}
\end{pspicture}
\end{document}


## Note:

Next time please use English names for the constants.

-
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. –  Svend Tveskæg Apr 25 '13 at 14:55
Okay. \bredde = 2*\radius and \laengde = \bredde+\lige. (The \edefs are wrong.) –  Svend Tveskæg Apr 25 '13 at 15:00
@Bugbusters I won't see your (or any others) post before tomorrow. Good day to everyone. –  Svend Tveskæg Apr 25 '13 at 15:10
@Bugbusters can you do a favour of making this title more clear based on comments below Q :) –  texenthusiast Apr 25 '13 at 15:15
@texenthusiast: I think I should not rephrase the title as the questioner should always provide more descriptive and specific title. :-) –  The Last Error Apr 26 '13 at 7:26
show 1 more comment