# How does the pspicture positioning work in a page?

I'm having trouble positioning a psframe inside a page with a specific size and it looks like the whole pspicture is shifted in the page. This is a MWE of my code

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone}

\usepackage[english]{babel}
\usepackage[paperheight=16cm,paperwidth=21cm]{geometry}

\pagestyle{empty}

\begin{document}

\psset{algebraic,xunit=1cm,yunit=1cm}

\begin{pspicture}(0,0)(21,16)

\psframe[fillstyle=solid,fillcolor=blue!20,linewidth=3pt,linecolor=black](0,0)(21,16)

\end{pspicture}

\end{document}


As you can see, my page is 21cm wide and 16cm tall. My pspicture has the coordinates (0,0)(21,16) and the xunit and yunit are set to 1cm. My psframe has the same coordinates as the pspicture so what I was expecting once this code is compiled is to have a blue, 16cm x 21cm page with a black frame around it. Instead, what I'm getting is a page with the desired dimensions but the blue background is shifted a bit to the right and up another bit, leaving a white area exposed.

How does pspicture positioning work? How can I fix this code? I can manually shift the frame but I would like a more elegant solution because it seems to me that there is something wrong, or perhaps something missing from this code.

I'd use article and add the following:

• margin=0pt for geometry which makes the text block match the paper size;

• \noindent before the pspicture environment.

The pspicture environment is set like any other textual component (like the letter a, or the number 7. As such, it also is indented with \parindent when it starts a paragraph. The width of this "big character" will be 21cm and have a height of 16cm, exactly what you want.

\documentclass{article}

\usepackage[paperheight=16cm,paperwidth=21cm,margin=0pt]{geometry}

\pagestyle{empty}

\begin{document}

\psset{algebraic,xunit=1cm,yunit=1cm}

\noindent
\begin{pspicture}(0,0)(21,16)

\psframe[fillstyle=solid,fillcolor=blue!20,linewidth=3pt,linecolor=black](0,0)(21,16)

\end{pspicture}

\end{document}

• Thank you very much, Werner. One more thing, if I may... do you know why the standalone class did not work? – Gabu Mar 13 '17 at 20:07
• @Gabu: I know standalone has a specific interface dedicated to pstricks and tikz (supplied during class load: \documentclass[pstricks]{standalone} or \documentclass[tikz]{standalone}) which might mean its interface with those environments are treated differently to what you think. I don't really use standalone, so I'm not that familiar with the inner workings. – Werner Mar 13 '17 at 20:19

Do not use package geometry when using standalone and run it with xelatex:

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