What is it about using \makebox that makes it disregard text body borders / margins, where other boxes respect the margins / text width and friends?

I ask this because it seems like a magic box that you can just throw anything into and do whatever (same with \parbox, I suppose). In TikZ, you have to use the overlay option. Is it due to something implicit like that?

  • 2
    With \makebox you can specify [<size>], [<alignment>], as well as {<content>}. When the size is specified, the content can spill out the sides, even as TeX thinks of the box as only be of the specified size. By throwing in clever use of left/center/right alignment, it provides a mechanism for typesetting stuff at distal locations to the "cursor location". Try \fbox{\makebox[0pt][r]{This appears to the left}}. The box shows where TeX imagines the <content> to be. – Steven B. Segletes Oct 25 '18 at 11:02
  • 1
    Roughly equivalent to \hbox to <width> {\hss <contents> \hss}. Core TeX \hss is like \hfill, only it can shrink. – John Kormylo Oct 25 '18 at 13:28

There is nothing special about \makebox. If you go


then if ... is wider than 1in you will get an overfull box, but it is possible to make the text visually wider without being wider to tex, eg


is not overfull, despite the fact that the X will extend past the 1cm boundary of the box.

\makebox is just a box with (if you use the length option) a specified width but glue added either side that can stretch or shrink an arbitrary amount so that the contents are always exactly the width of the box, even if they appear to extend past it.

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.