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.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted
\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

share|improve this answer

You can use \RaggedLeft from ragged2e package.

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

enter image description here

share|improve this answer
    
Works in this simple example but does not when content of \pbox is more complex. –  drasto Mar 3 '13 at 2:40
    
@drasto Can you show a code where this is not working? –  Harish Kumar Mar 3 '13 at 6:15
    
I would like to but I'm afraid I cannot :( Licencing issues. I tried to isolate the cause and post some example but it is taking too much time - code that creates content of \pbox is rather complex. Anyway, solution from @JLDiaz answer works well. –  drasto Mar 4 '13 at 1:38

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.