[Tex/LaTex] How to right align content of pbox

boxeserrorshorizontal alignment

Lets have simple \pbox example like this:

\documentclass[twoside]{book}
\usepackage{pbox, calc}
\begin{document}
\noindent\fbox{\pbox{\textwidth}{Some text\\Text}}
\end{document}

Here is printed result:

enter image description here

I want that Text on second line to be alighned right. I tried to adjust previous code so that it reads:

\documentclass[twoside]{book}
\usepackage{pbox, calc}
\begin{document}
\noindent\fbox{\pbox{\textwidth}{\begin{flushright}Some text\\Text\end{flushright}}}
\end{document}

When trying to compile it I'm getting following error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

Even with the error there is still some output but it is not entirely correct (too big box margins):

enter image description here

How can I correctly right align content of pbox?

Best Answer

\documentclass[twoside]{book}
\usepackage{pbox, calc}
\def\flushRight{\leftskip0pt plus 1fill\rightskip0pt}
\begin{document}
\noindent\fbox{\pbox{\textwidth}{\flushRight Some text\\Text}}
\end{document}

Result

Related Question