[Tex/LaTex] makebox with minimum width

horizontal alignmentspacing

I use makebox to create padded texts, however when the text in the box overflows, it overlaps with the following content. To demonstrate, enter image description here

The thing I want is a box that when the text is shorter than the given width, it works just as a normal makebox, however, when the text overflows, it should act as without a makebox, like the fourth line.

To be clear, what I want is something like:


Best Answer

  \ifdim\mylen < #1
  \myflexbox{good} padding

  \myflexbox{notbad} padding

  \myflexbox{it overlaps!} padding

  it overlaps! padding


enter image description here

Related Question