Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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\radius{19.2}
\def\lige{33.3}
\newlength\R \R=\radius\psunit
\newlength\hW \hW=\lige\psunit
\hW=0.5\hW
 \centering
\fbox{%
  \begin{pspicture}(-\dimexpr\hW+\R,-\radius)(\dimexpr\hW+\R,\radius)
   \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*(\dimexpr-\hW-0.5\R,0){\radius\,cm}
    \rput*(\dimexpr \hW+0.5\R,0){\radius\,cm}
    \rput(-\hW,0){\textbf{+}}
    \rput( \hW,0){\textbf{+}}
  \end{pspicture}
}
\end{figure}

\end{document}

output

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.

share|improve this question
    
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. –  Oh my ghost 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

2 Answers 2

up vote 2 down vote accepted

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\radius{19.2}
\def\lige{33.3}
\newlength\R \R=\radius\psunit
\newlength\hW \hW=\lige\psunit
\hW=0.5\hW
 \centering
\fbox{%
  \begin{pspicture}(-\dimexpr\hW+\R,-\radius)(\dimexpr\hW+\R,\radius)
   \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*(\dimexpr-\hW-0.5\R,0){\radius\,cm}
    \rput*(\dimexpr \hW+0.5\R,0){\radius\,cm}
    \rput(-\hW,0){\textbf{+}}
    \rput( \hW,0){\textbf{+}}
  \end{pspicture}%
}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
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\radius{19.2}
\def\lige{33.3}

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

\newlength\R
\newlength\hW  

\R=\radius\psunit
\hW=\lige\psunit
\hW=0.5\hW

\begin{document}
\begin{pspicture}[showgrid=false](-\dimexpr\hW+\R,-\radius)(\dimexpr\hW+\R,\radius)
    \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*(\dimexpr-\hW-\R/2,0){\radius\,cm}
    \rput*(\dimexpr\hW+\R/2,0){\radius\,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.

enter image description here

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}
\caption{Your diagram in action}
\label{fig:your-diagram}
\end{figure}
\end{document}

Advantages of separation of concern method:

  • You can notice, find, and solve any peculiarities, errors, etc easily.
  • You can reuse your diagram for other projects.
  • Your main input file becomes cleaner and tidier.
  • The compilation time can be significantly reduced as you don't have to recompile the unchanged diagrams.
share|improve this answer
1  
Isn't it a little bit tautological to suppress the problem and then say that you don't notice it? ;-) –  Gonzalo Medina Sep 10 '13 at 16:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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