# Why does \rput(0,0) translate my picture?

Using rput, I noticed it misplaces my objects. By testing, I found two strange behaviours:

1. \rput(0,0) { object } moves my objects a little bit. Doing latex on the following code:

\documentclass{article}
\usepackage{pst-all}
\begin{document}
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}
\begin{pspicture}(350,150)
\rput(0,0) {
\pscustom[linestyle=none,fillstyle=solid,fillcolor=green]
{
\newpath
\moveto(75,150)
\lineto(65,125)
\lineto(75,135)
\lineto(85,125)
\closepath
}
}
\pscustom[linestyle=none,fillstyle=solid,fillcolor=red]
{
\newpath
\moveto(75,150)
\lineto(65,125)
\lineto(75,135)
\lineto(85,125)
\closepath
}
\end{pspicture}
\end{document}


produces a red arrow over green arrow, but one can see the green arrow slightly misplaced.

2. \rput(0,0) { { object } } moves it even more. Example:

\documentclass{article}
\usepackage{pst-all}
\begin{document}
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}
\begin{pspicture}(350,150)
\rput(0,0) {
{
\pscustom[linestyle=none,fillstyle=solid,fillcolor=green]
{
\newpath
\moveto(75,150)
\lineto(65,125)
\lineto(75,135)
\lineto(85,125)
\closepath
}
}
}
\pscustom[linestyle=none,fillstyle=solid,fillcolor=red]
{
\newpath
\moveto(75,150)
\lineto(65,125)
\lineto(75,135)
\lineto(85,125)
\closepath
}
\end{pspicture}
\end{document}


latex --version gives:

    pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014/Arch Linux)
kpathsea version 6.2.0


Why is that, how to fix it?

• Welcome to TeX.SX! You are inserting some unneeded space in your 15th line of code. It should be \closepath}% – LaRiFaRi May 26 '15 at 15:49
• Note that if you use two \rputs, there is no problem. – Bernard May 26 '15 at 15:58
• @Bernard: it has nothing to do with one or two \rput – user2478 May 26 '15 at 15:59
• @Herbert: I've read your limpid explanation. There remains that using two \rput avoids unwanted space. It was only an observation. – Bernard May 26 '15 at 16:03
• @Bernard if you use two \rput (with spurious spaces in each) it just means that you get the unwanted displacement in both cases, so the arrows line up, but that just means they are both wrong, not that the problem has gone. – David Carlisle May 26 '15 at 16:14

Use 

\rput(...){%
... %
}


\rput(0,0){%
\pscustom[linestyle=none,fillstyle=solid,fillcolor=green]
{
\newpath
\moveto(75,150)
\lineto(65,125)
\lineto(75,135)
\lineto(85,125)
\closepath
}%
}


Otherwise you'll get two unwanted spaces. \pscustom itself removes spaces but the argument of \rput is handled as default TeX and will keep spaces.

• Nice. If you don't mind, could you explain me why rput[Br](0,0) makes the displacement and rput[Bl](0,0) does not? (I have found such workaround) – Piotr May 27 '15 at 22:35
• In fact, I use code like \rput(200,0) { \input{file.pst} } and the code for arrows and other stuff is in file.pst. And this file may be large, so I am not keen on editing it by hand, adding % at the end of many lines. I guess I could add % at the end of every line, yeah? – Piotr May 27 '15 at 22:45
• Use \rput(200,0) {\input{file.pst}} without spaces before and after the \input macro – user2478 May 28 '15 at 4:13
• This does not help. – Piotr May 29 '15 at 12:06
• then you have some more spaces in the file.pst – user2478 May 29 '15 at 13:22

Using a left anchor

\rput[Bl] (0,0) {
(...)
}


does the trick (tl and bl are also possible instead of Bl).

Also deleting unnecessary spaces as in

\rput(...){%
... %
}
`

solves the problem, but is not convenient when including external files, which would have to contain no extra spaces.