# Not equal spacing on both sides of PSTricks figure

Taking the code of PSTikZ's answer from "PSTricks figure way too big; normal scaling seems not to work" (and putting an \fbox around it to illustrate the problem), I get the following:

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{figure}
\psset{
unit=0.2,
linewidth=1pt
}
\def\lige{33.3}
\newlength\hW \hW=\lige\psunit
\hW=0.5\hW
\centering
\fbox{%
\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}


Why is there more space on the right hand side of the figure than on the left?

P.S. This is a universal problem/"feature" of PSTricks pictures.

-
it has nothing to do with PSTricks! \fbox{a } is the same. – Herbert Sep 10 '13 at 15:17
I agree with Herbert, I don't notice any gap. See my answer but I rewritten your code using standalone and some minor changes in coding style. – kiss my armpit Sep 10 '13 at 15:19
@Herbert Yes, Gonzalo Medina told me what causes the extra space. – Svend Tveskæg Sep 10 '13 at 15:24

There's a spurious blank space after \end{pspicture}; remove it (for example, by commenting it out):

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{figure}
\psset{
unit=0.2,
linewidth=1pt
}
\def\lige{33.3}
\newlength\hW \hW=\lige\psunit
\hW=0.5\hW
\centering
\fbox{%
\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}


-
Thanks! So, to get the correct position of the pspicture, I should always put a % right after \end{pspicture}? – Svend Tveskæg Sep 10 '13 at 14:47
@SvendTveskæg no; not always, just when spurious blank spaces might need to be removed. – Gonzalo Medina Sep 10 '13 at 14:48
Okay. Thank you. (I'll accept your answer when possible in a few minutes.) – Svend Tveskæg Sep 10 '13 at 14:49

First of all, I don't notice any gap with your re-written code below.

To easily locate the peculiarity, it is better to put each your diagram in a single compilable input as follows.

% your-diagram.tex
\documentclass[pstricks,border=0.5pt]{standalone}
\def\lige{33.3}

\psset
{
unit=0.2,
linewidth=1pt,
}

\newlength\R
\newlength\hW

\hW=\lige\psunit
\hW=0.5\hW

\begin{document}
\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{document}


Compile it with latex->dvips-ps2pdf sequence to get a PDF output.

From your main input file, you can import the PDF image with \includegraphics from graphicx package.

% main-input-file.tex
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics{your-diagram}