Home > Typesetting > LaTeX Tip of the Day – \fbox, \mbox, \makebox, \framebox

LaTeX Tip of the Day – \fbox, \mbox, \makebox, \framebox

March 4th, 2009

When typesetting with LaTeX, sometimes you need to take a little control back from the automatic routines that determine linebreaks. Or perhaps you want to manually control the placement of text on a line.
The latex command \makebox[w][position]{content} inserts an unbreakable box of width w (10pt, 2cm, 0.23in, \textwidth will work), where the content is positioned flush left (use the letter l), flush right (r), centered (c), or will fill the box (s). The square brackets mean that those arguments are optional (if you only specify one, LaTeX assumes you’re giving the width). The default positioning is (c), and the default width is just big enough to fit the content (if you specify a width that is too small, the text will overflow onto text outside the box.

examples of \makebox in LaTeX

The command \framebox is exactly the same, except it draws a solid line around the box:

examples of \framebox in LaTeX

The commands \mbox{content} and \fbox{content} are equivalent to \makebox{content} and \framebox{content}, respectively (\mbox and \fbox are robust, so you should use them if possible). To change the thickness of the outline drawn by \fbox to 2pt, add the command \renewcommand{\fboxrule}{2pt} anywhere before the \fbox.

examples of \mbox and \fbox in LaTeX

Note how the boxes make the line overflow.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • Slashdot
  • StumbleUpon

Typesetting , ,

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.