# XeTeX pstricks larger page size is cropped to A4

In a Plain-XeTeX document, if I set the page size to anything bigger than the default page size, (A4 in my case) then all the pstricks elements beyond the size of an A4 page are trimmed of, so only a portion of the image is seen on the page. I've tried to set the page size before and after `\input pstricks`, tried put it in pspicture, put it outside of it, set the pspicture size to (0, 0), (10, 10), used `\pspicture*` instead, nothing could get rid of that cropping region, and draw beyond that. I also tried to use pdf special commands in vain.

The final TeX file I'm trying with is the following:

``````%\special{papersize=500mm,500mm}
\special{pdf:pagesize width 500mm height 500mm}
\hsize=500mm\vsize=500mm
\input pstricks

%\pspicture(0,0)
\psline(-500cm,0)(1mm,0)
\psline(0,100cm)(0,-500cm)
%\endpspicture

Somewhere, over the rainbow.

\bye
``````

I've tried this in the latest of these systems, and none of them worked: MiKTeX 2.9 (64-bit), MacTeX (2013 is the version number I believe?)

The following output can be seen whatever I tried. The vertical line only starts from somewhere about the middle of the page where it should start from above the text, and horizontal line isn't visible at all.

How can I resolve this issue?

• What size are things meant to be? You don't really want a page size of .5x500 metres, do you? Anyway, TeX doesn't recognise `m` as a unit of measure so this won't work as it is. (And I suspect 500m may be somewhat beyond TeX's capacity.) But if it is meant to be 500mmx500mm then I'm not sure how things at the 500cm reach are supposed to appear. Basically, I think this isn't really a TeX problem - at least, not as posted - but rather one of just sorting out the dimensions you want. Note that the PDF produced is 500x500mm when that's what I request (but it fails if I ask for 500mmx500*m*). – cfr Feb 2 '14 at 23:44
• But are you sure you can use `pstricks` with XeTeX when you are producing pdf directly? I thought that the package needed to be used with an alternative compilation target? – cfr Feb 2 '14 at 23:59
• Whoops, "m" was a typo, and meant to be "mm" (but that's beside my problem) The pstricks elements are trimmed to the size of an A4 page aligned to the bottom right. I'm not aware of any other "alternative compilation target," but I'm all ears. I know that at some point XeTeX & pstricks didn't work at all. probably it is still too soon? I'll try my best to clarify my question. – Adam L. S. Feb 3 '14 at 6:14
• Probably the image I've added is a bit huge... – Adam L. S. Feb 3 '14 at 6:25
• Why don't you LaTeX with `standalone` class? Please explain what you want to achieve independent from the compilers. – kiss my armpit Feb 3 '14 at 6:49

## 1 Answer

XeTeX writes the PostScript code of pstricks in a temporary PostScript file and runs the result through the command, that is configured in entry `D` of `TDS:dvipdfmx/dvipdfmx.cfg`, e.g. (TL2013):

``````D  "rungs -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dCompatibilityLevel=%v -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='%o' '%i' -c quit"
``````

Because of `-dEPSCrop` it works fine for EPS images with bounding box, but pstricks code does not have bounding box specifications. Thus the default media size of ghostscript is used (e.g. letter).

Workaround:

A larger (default) paper size can be set by `-sDEFAULTPAPERSIZE=a0` or `-sPAPERSIZE=a0`. The option can be specified in the entry for `dvipdfmx.cfg` or on the command line using an environment variable, e.g.:

``````env GS_OPTIONS=-sDEFAULTPAPERSIZE=a0 xetex test
``````
• This works nice under my Mac. However for some reason `set GS_OPTIONS=-sDEFAULTPAPERSIZE=a0 && xetex test` does not. (It does not produces any errors.) I see from the MiKTeX's `dvipdfmx.cfg` file, that it uses `mgs` instead of `rungs`. The environment variable would be more comfortable to do, because modifying the config file could risk that it would be reverted with the next upgrade. – Adam L. S. Feb 3 '14 at 10:05
• Btw. It is possible to set an EPS bounding box even from the TeX file, isn't it? – Adam L. S. Feb 3 '14 at 10:07
• @AdamL.S.: There are several possibilities to set the environment variable temporarily: `env GS_OPTIONS=... xetex ...`, `GS_OPTIONS=... xetex ...`. – Heiko Oberdiek Feb 3 '14 at 10:18
• @AdamL.S.: I do not know a way to set a bounding box for delegated PostScript specials in XeTeX. – Heiko Oberdiek Feb 3 '14 at 10:18
• `env` is Unix specific and could provide a short term solution, but I need it for Windows (for convenience)--Do you know how to set a bounding box in plain-TeX? – Adam L. S. Feb 3 '14 at 10:31