W3cubDocs

/LaTeX

\fbox & \framebox

Synopses, one of:

\fbox{text}
\framebox{text}
\framebox[width]{text}
\framebox[width][position]{text}

Create a box with an enclosing frame, four lines surrounding the space. These commands are the same as \mbox and \makebox except for the frame (see \mbox & \makebox). The \fbox command is robust, the \framebox command is fragile (see \protect).

\fbox{Warning! No work shown, no credit given.}

LaTeX puts the text into a box that cannot be split or hyphenated. Around that box, separated from it by a small gap, are four lines making a frame.

The first two command invocations, \fbox{...} and \framebox{...}, are roughly the same. As to the third and fourth invocations, the optional arguments allow you to specify the box width as width and the position of the text inside that box as position. See \mbox & \makebox, for the full description but here is an example creating an empty box that is 1/4in wide.

\setlength{\fboxsep}{0pt}\framebox[0.25in]{\strut}}

The \strut inserts a vertical height of \baselineskip (see \strut).

These parameters determine the frame layout.

\fboxrule

The thickness of the lines around the enclosed box. The default is 0.2pt. Change it with a command such as \setlength{\fboxrule}{0.8pt} (see \setlength).

\fboxsep

The distance from the frame to the enclosed box. The default is 3pt. Change it with a command such as \setlength{\fboxsep}{0pt} (see \setlength). Setting it to 0pt is useful sometimes: this will put a frame around the picture with no white border.

{\setlength{\fboxsep}{0pt}
 \framebox{%
   \includegraphics[width=0.5\textwidth]{prudence.jpg}}}

The extra curly braces keep the effect of the \setlength local.

As with \mbox and \makebox, LaTeX will not break lines in text. But this example has LaTeX break lines to make a paragraph, and then frame the result.

\framebox{%
  \begin{minipage}{0.6\linewidth}
    My dear, here we must run as fast as we can, just to stay in place.
    And if you wish to go anywhere you must run twice as fast as that.
  \end{minipage}}

See Colored boxes, for colors other than black and white.

The picture environment has a version of this command where the units depend on picture’s \unitlength (see \framebox (picture)).

© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/_005cfbox-_0026-_005cframebox.html