\parbox 在图形环境中的不良行为

\parbox 在图形环境中的不良行为

我想将 放在\parbox由 绘制的图形中pstrickspspicture环境位于 环境内部figure。例如:

\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}

图形环境中的示例

由于某种原因\parbox不是对齐,就像在 a 中一样\parbox,但它居中。但是,如果我不将pspicture环境放在 afigure环境中,那么\parbox 合理的,如下例所示:

\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}

没有图形环境的示例

我怎样才能将对齐的文本放入环境pspicture内的figure?换句话说,我该如何修改第一个例子,使文本对齐\parbox(而不是居中)?如果有其他可行的替代方案\parbox(即在这种情况下对齐),我也可以接受。

答案1

在肠道深处revtex4-1它实际上附加\centering\@parboxrestore浮点数的开头:

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

\@xfloat@prep是一个调用的宏,用于为浮动环境准备一些预设。

这意味着\parbox浮点型中的所有构造都将以 发出\centering。避免这种情况的最快方法是\let\centering\relax在使用 之前发出\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}

为了采取更全球化的方法,只需\@xfloat@prep在序言中重新定义:

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

答案2

使用表格而不是\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}

相关内容