# Why is there a gap on the right side of child image imported from within the main input file?

## Child input file

% Child.tex
\documentclass{standalone}
\usepackage{pstricks}
\pagecolor{yellow}

\setlength\PreviewBorder{0pt}

\begin{document}
\begin{pspicture}(4,3)
\psframe[linecolor=red](4,3)
\end{pspicture}%
\end{document}


## Main input file

% Main.tex
\documentclass{article}
\usepackage{standalone}
\usepackage{pstricks}
\fboxsep=0pt

\begin{document}
\fbox{\input{Child}}
\end{document}


Main.tex, which is compiled with xelatex.exe, produces the following result. Why is there a white gap on the right side of the imported image?

-

You get a space because of the line break after the \end{document} in the child document. You need to place the usual % there to avoid it. Alternatively using \input{Child}\unskip} should also do it.
It might be a good idea to add \endinput after \end{document} in documents used with standalone. –  egreg Jul 30 '11 at 22:33
@egreg: The \end{document} (in sub-files) already contains \endinput (of course! :-) ). I now added \@ignoretrue as well which removes the space. It's funny that the line break is still taken as space even with the \endinput in place. –  Martin Scharrer Jul 30 '11 at 22:39
I don't want to create a new question just for asking this: "Is there an option to use in a child input file such that I no longer need to specify \setlength\PreviewBorder{0pt} explicitly in each child input file?" –  xport Jul 30 '11 at 22:47
@xport: There is the border class option for the standalone class, e.g. border=0pt. Note that if you \input child documents then the source code is read and preview is not used. –  Martin Scharrer Jul 31 '11 at 0:27