# Why do I have to put fillcolor setting inside preview environment?

It seems to me this problem related to PSTricks so I have to modify the previous question.

\psset{fillstyle=solid,linecolor=red} that I define globally outside the preview environment can affect the graphics object. But why do I have to put \psset{fillcolor=green} inside the preview environment to make it works?

\documentclass[preview,border=12pt]{standalone}
\usepackage{pstricks}
\psset{fillstyle=solid,linecolor=red}

% the following setting will be ignored by preview
% \psset{fillcolor=green}

\begin{document}
\preview
% Thus the setting must be inside the preview, does it seem strange to you?
\psset{fillcolor=green}
\psframebox{Karl's students}
\endpreview
\end{document}


Is fillcolor very special in this case?

-
I think that's how preview works. Only the stuff between the preview environment gets executed after \begin{document}. Otherwise use crop option instead of preview in the class options. –  percusse Mar 15 '13 at 15:05
@percusse: See my update because I just found that it is heavily related to fillcolor option. –  Who is crazy first Mar 15 '13 at 15:07
It's not related to \preview. The issue comes up whether you use preview or not. It seems to have to do with where you call \psset. Setting things in the preamble doesn't always have the desired effect. Not sure why at this point. If you place your \psset{fillcolor=green} immediately after begin{document} it will work, but not if you place it inside the preamble. –  A.Ellett Mar 15 '13 at 18:00

If you look inside pstricks.sty, at the very end of the package you will find the following line:

\AtBeginDocument{%
\psset{fillcolor=white}%      hv 0.33
\let\pst@endcolor=\relax%
%  \let\pst@color=\relax%
% LaTeX used \color@endgroup' instead. RN 2004-05-06
}


Thus trying to set fillcolor inside the preamble will be defeated once you hit \begin{documnent}

-

use

\AtBeginDocument{\psset{fillstyle=solid,linecolor=red}}

-
But what is the purpose of setting fillcolor=white at the begin document in pstricks.sty? –  Who is crazy first Apr 4 '13 at 15:06
Problems when there is no defined fillcolor –  Herbert Apr 4 '13 at 15:10
Why wasn't it put at the bottom of pstrick.sty but not inside \AtBeginDocument (because our global \psset{} is always below \usepackage{pstricks})? –  Who is crazy first Apr 4 '13 at 15:16
because no one should set it to undefined –  Herbert Apr 4 '13 at 15:24
I meant \psset{fillcolor=white} should be defined at the bottom of pstricks.sty but not inside \AtBeginDocument{}. So this setting can be overridden by us via \psset{fillcolor=<other color>} that we put below \usepackage{pstricks}. –  Who is crazy first Apr 4 '13 at 15:28

This weird feature has been disabled in the current pstricks.sty`.

-
@texenthusiast: No. It has not been mentioned in the news letter yet. –  Who is crazy first Apr 7 '13 at 6:00