# PSTricks figure way too big; normal scaling seems not to work

Consider the following example:

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{figure}
\def\lige{33.3}
\newlength\hW \hW=\lige\psunit
\hW=0.5\hW
\centering
\psset{
unit=0.2,
linewidth=1pt
}
\begin{pspicture}(-35.5,-18.9)(34.9,18.9)
\psset{
linecolor=red
}
\psarc( \hW,0){\R}{270}{90}
\psarc(-\hW,0){\R}{90}{270}
\psline(-\hW, \R)(\hW, \R)
\psline(-\hW,-\R)(\hW,-\R)
\psset{
linecolor=black,
linestyle=dotted
}
\psline(-\hW,-\R)(-\hW,\R)
\psline( \hW,-\R)( \hW,\R)
\psline(\dimexpr-\hW-\R,0)(\dimexpr\hW+\R,0)
\rput*(0,0){\lige\,cm}
\rput(-\hW,0){\textbf{+}}
\rput( \hW,0){\textbf{+}}
\end{pspicture}
\end{figure}

\end{document}


The figure is way too big and changing the unit option apparently has no effect.

How do I fix this?

P.S. The figure used to have the right scale so I have obviously introduced something 'fishy' but I haven't got a clue as to what that is.

-

I noticed your code contains a logical bug. The canvas size must be

(-\dimexpr\hW+\R,-\radius)(\dimexpr\hW+\R,\radius)


So now my answer has extra value. Why don't accept it? :-)

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{figure}

\centering
\psset{
unit=0.2,
linewidth=1pt
}
\def\lige{33.3}
\newlength\hW \hW=\lige\psunit
\hW=0.5\hW
\psset{
linecolor=red
}
\psarc( \hW,0){\R}{270}{90}
\psarc(-\hW,0){\R}{90}{270}
\psline(-\hW, \R)(\hW, \R)
\psline(-\hW,-\R)(\hW,-\R)
\psset{
linecolor=black,
linestyle=dotted
}
\psline(-\hW,-\R)(-\hW,\R)
\psline( \hW,-\R)( \hW,\R)
\psline(\dimexpr-\hW-\R,0)(\dimexpr\hW+\R,0)
\rput*(0,0){\lige\,cm}
\rput(-\hW,0){\textbf{+}}
\rput( \hW,0){\textbf{+}}
\end{pspicture}
\end{figure}

\end{document}

-
Note: I did not copy the existing answer! –  Donut E. Knot Sep 10 at 13:55
Just fine. :) Thank you for the answer too. –  Svend Tveskæg Sep 10 at 13:57
I could just as well have chosen your answer. –  Svend Tveskæg Sep 10 at 14:04
There you go... accepted. –  Svend Tveskæg Sep 10 at 14:29
@SvendTveskæg: Thank you for accepting it, it helped me to increase my reps so I can offer the next bounty for someone. –  Donut E. Knot Sep 10 at 14:31
show 1 more comment

Another way is to do the calculations on the Postscript side. This must be enabled with \SpecialCoor, and allows to access the ! notation.

A simple addition then is done like in \pnode(! 1 2 add 1){A}, which is equivalent to \plot(3, 1){A}.

So your example could likewise be written as:

\documentclass[pstricks, border=3pt]{standalone}

\begin{document}
\def\lige{33.3}
\def\hW{16.65 }

\SpecialCoor

\psset{%
unit=0.2,
linewidth=1pt
}%
\begin{pspicture}(-35.5,-18.9)(34.9,18.9)
\psset{linecolor=red}
\psarc(\hW,0){\R}{270}{90}
\psarc(-\hW,0){\R}{90}{270}
\psline(-\hW, \R)(\hW, \R)
\psline(-\hW,-\R)(\hW,-\R)
\psset{
linecolor=black,
linestyle=dotted
}
\psline(-\hW,-\R)(-\hW,\R)
\psline( \hW,-\R)( \hW,\R)
\psline(! -\hW \R sub 0)(!\hW \R add 0)
\rput*(0, 0){\lige\,cm}
\rput*(! -\hW -0.5 \R mul add 0){\R\,cm}
\rput*(! \hW 0.5 \R mul add 0){\R\,cm}
\rput(-\hW,0){\textbf{+}}
\rput( \hW,0){\textbf{+}}
\end{pspicture}

\end{document}


Note, that I defined \R as \radius\space, and explicitely left a space after the number in \hW, so one does not always have to write e.g. (!\hW\space \radius\space add 0) in order to get the required white spaces, but with the above definitions it writes as (!\hw \R add).

-
Thank you. I was aware of the (type of) solution, too. (Note: It is actually \def\hW{16.65 } and not 50/3. –  Svend Tveskæg Sep 10 at 14:24
Unfortunately, PostScript expressions cannot be used to specify the canvas size. –  Donut E. Knot Sep 10 at 14:29