Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

example within figure-environment

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}

example without figure-environment

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.

share|improve this question
    
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 2

up vote 4 down vote accepted

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:

enter image description here

\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
share|improve this answer

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.