# Undesired behaviour of \parbox within figure environment

I want to put a \parbox in a figure that is drawn by pstricks. The pspicture environment is inside of a figure environment. As an example:

\documentclass[singlecolumn, nofootinbib, notitlepage]{revtex4-1}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pst-poly}

\begin{document}

\begin{figure}[htb]

\begin{pspicture}[showgrid=true](-3,-3)(3,3)
\rput[tl](-2, 2){\parbox{4cm}{I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. }}
\end{pspicture}

\label{some label}
\end{figure}

\end{document}


For some reason, the text within the \parbox is not justified, as it should be the case in a \parbox, but it is centered. However, if I do not put the pspicture environment in a figure environment, then the text in the \parbox is justified, as in the following example:

\documentclass[singlecolumn, nofootinbib, notitlepage]{revtex4-1}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{pst-poly}

\begin{document}

\begin{pspicture}[showgrid=true](-3,-3)(3,3)
\rput[tl](-2, 2){\parbox{4cm}{I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. I want this text to be justified. }}
\end{pspicture}

\end{document}


How can I put a justified text in a pspicture that is inside of a figure environment? In other words, how do I have to modify the first example such that the text in the \parbox is justified (instead of centered)? If there is an alternative to \parbox that works (i.e. which is justified in this situation), I'm fine with that as well.

-
Hmmm.. Seems to have something to do with revtex4-1 as it works fine with XeLaTeX if you use \documentclass{article}. –  Peter Grill Jun 22 '12 at 4:55

## 2 Answers

Deep within the bowels of revtex4-1 it actually appends \centering to \@parboxrestore at the start of a float:

\appdef\@xfloat@prep{%
\appdef\@parboxrestore{\centering}%
}%


\@xfloat@prep is a macro called to prepare some presets for the float environment.

This means that all \parbox constructs inside a float will be issued with \centering. The quickest way to avoid this would be to issue \let\centering\relax before using a \parbox:

\documentclass{revtex4-1}% http://ctan.org/pkg/revtex4-1
\usepackage{pstricks}% http://tug.org/PSTricks/main.cgi/

\begin{document}

\begin{figure}[htb]
\begin{pspicture}[showgrid=true](-3,-3)(3,3)
\rput[tl](-2, 2){\let\centering\relax\parbox{4cm}{I want this text to be justified.
I want this text to be justified. I want this text to be justified. I want this
text to be justified. I want this text to be justified. I want this text to be justified. }}
\end{pspicture}
\label{some label}
\end{figure}

\end{document}


For a more global approach, just redefine \@xfloat@prep within your preamble:

\makeatletter
\def\@xfloat@prep{%
\ltx@footnote@pop
\def\@mpfn{mpfootnote}%
\def\thempfn{\thempfootnote}%
\c@mpfootnote\z@
\let\H@@footnotetext\H@@mpfootnotetext
}%
\makeatother

-

use a tabular instead of a \parbox

\rput[tl](-2, 2){\tabular{p{4cm}}I want this text to be justified.
I want this text to be justified. I want this text to be justified. I want this
text to be justified. I want this text to be justified. I want this text to be
justified.
\endtabular}

-