Normally, text that does not fit into the width of a parbox sticks out on the right side:

\fbox{\parbox[t]{1cm}{\strut\raggedleft This \mbox{doesnotfit}}}

looks like this:

   |  This|

However, I really want the overflow to occur on the left side, the right side of the parbox should stay justified at all costs, i.e. I want:

    |  This|

Is there a way to do that?

  • But the text does not stick out on both sides, as you can see using and \fbox: \documentclass{article} \begin{document} \fbox{\parbox[t]{1cm}{\strut\raggedleft This \mbox{doesnotfit}}} \end{document} – Gonzalo Medina Mar 13 '12 at 1:35
  • @Nikratio It normally sticks to the right, not at both sides. perhaps you should explain in a bit more detail what is the ultimate goal you want to achieve. – Yiannis Lazarides Mar 13 '12 at 1:35
  • @GonzaloMedina Indeed, I corrected the question accordingly. But I still want the text to stick out on the left only.. – Nikratio Mar 13 '12 at 1:46
  • @YiannisLazarides The ultimate goal is really just to have the text stick out on the left instead of on the right. I have a document where this would look much nicer. – Nikratio Mar 13 '12 at 1:47

enter image description here


\hrule width 1cm

\noindent \parbox[t]{1cm}{
\leftskip 0pt  plus \hsize minus \hsize

\strut  This \mbox{doesnotfit}}
  • Works great, thanks! But could you explain what exactly the \leftskip 0pt plus \hsize minus \hsize does? – Nikratio Mar 13 '12 at 2:00
  • If the box goes overfull it will stick out on the right, so the trick is to add enough shrink glue that the left margin can go negative and back space enough so it fits. You can't add infinite shrink glue as that upsets the paragraph breaker, but you can make it "big enough" finite glue. So here the right margin can vary between -\hsize and \hsize so as long as your text isn't twice as wide as the box you are putting it in, you have enough negative space, otherwise you can increase that as required. – David Carlisle Mar 13 '12 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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